From 1b00e05d1c96f51e30d579a7db0d316465789a3a Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 01:13:18 +0000 Subject: [PATCH 01/27] Increment 1 (carried from cool-hawk-899): build_movable_set derives from make_decision SoleOwner + admits params De-forks the whole-value move predicate onto the single ownership authority (make_decision) instead of the coarse binding_fan_out re-derivation; adds discriminating witness ownership_movable_test.dag. Co-Authored-By: Claude Fable 5 --- dag/test/claim/ownership_movable_test.dag | 36 +++++++++++++++++++++++ src/v1/05_emit_rust.dag | 2 +- src/v1/ownership.dag | 6 ++-- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 dag/test/claim/ownership_movable_test.dag diff --git a/dag/test/claim/ownership_movable_test.dag b/dag/test/claim/ownership_movable_test.dag new file mode 100644 index 00000000000..0d1828b6f08 --- /dev/null +++ b/dag/test/claim/ownership_movable_test.dag @@ -0,0 +1,36 @@ +module test.claim.ownership_movable + +import v1.compiler.ownership { build_movable_set, make_decision, BindingUsage, EdgeClassification, EdgeKind, OwnershipProof, OwnershipDecision } + +fn proof_one(name: String, consumers: List) -> OwnershipProof { + let usage = BindingUsage { name: name, binding_kind: none, consumers: consumers } + OwnershipProof { + func_name: "fixture", + bindings: map_insert(empty_map(), name, usage), + decisions: [], + fold_acc_unwrap: [] + } +} + +fn edge(k: EdgeKind, s: String) -> EdgeClassification { + EdgeClassification { kind: k, site: s, span_start: 0 } +} + +fn movable_of(proof: OwnershipProof, name: String) -> Bool { + set_contains(build_movable_set(proof: proof, param_names: set_insert(empty_set(), name)), name) +} + +fn witness_read_then_consume_param_is_movable() -> Bool { + let proof = proof_one(name: "acc", consumers: [edge(k: Projected, s: ".seen"), edge(k: Consumed, s: "return")]) + movable_of(proof: proof, name: "acc") +} + +fn witness_double_consume_is_not_movable() -> Bool { + let proof = proof_one(name: "x", consumers: [edge(k: Consumed, s: "a"), edge(k: Consumed, s: "b")]) + movable_of(proof: proof, name: "x") == false +} + +fn witness_zero_consume_is_not_movable() -> Bool { + let proof = proof_one(name: "r", consumers: [edge(k: Read, s: "a"), edge(k: Projected, s: ".f")]) + movable_of(proof: proof, name: "r") == false +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b6ebc308177..de5610fe64a 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1596,7 +1596,7 @@ fn build_ownership_results(modules: List) -> OwnershipBuildResult { proofs |> fold(init: OwnershipBuildResult { ownership_index: empty_map(), read_only_params_index: empty_map() }, f: (acc, entry) => let read_only = if set_contains(callable_set, entry.proof.func_name) { empty_set() } else { build_read_only_params(proof: entry.proof, param_names: entry.param_names) } - let movable = build_movable_set(proof: entry.proof) + let movable = build_movable_set(proof: entry.proof, param_names: entry.param_names) OwnershipBuildResult { ownership_index: map_insert(acc.ownership_index, entry.name, movable), read_only_params_index: map_insert(acc.read_only_params_index, entry.name, read_only) diff --git a/src/v1/ownership.dag b/src/v1/ownership.dag index 1f7b861900b..db8986b0d1c 100644 --- a/src/v1/ownership.dag +++ b/src/v1/ownership.dag @@ -300,9 +300,11 @@ fn is_owned_local(kind: VarBindingKind?) -> Bool { } } -fn build_movable_set(proof: OwnershipProof) -> Set { +fn build_movable_set(proof: OwnershipProof, param_names: Set) -> Set { proof.bindings |> map_values - |> filter(usage => binding_fan_out(usage: usage) == 1 && is_owned_local(kind: usage.binding_kind)) + |> filter(usage => + (match make_decision(usage: usage) { SoleOwner { binding: _, site: _ } => true, _ => false }) + && (is_owned_local(kind: usage.binding_kind) || set_contains(param_names, usage.name))) |> fold(init: empty_set(), f: (acc, usage) => set_insert(acc, usage.name)) } From 4f13b94352251e9711f3c5afb9bc6f7529f9b6e1 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 01:15:00 +0000 Subject: [PATCH 02/27] Design: increment-2 per-site ownership verdict (Perceus last-use) + counted take-owned fallback Co-Authored-By: Claude Fable 5 --- docs/plans/emitter-ownership-defork.md | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 docs/plans/emitter-ownership-defork.md diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md new file mode 100644 index 00000000000..12a510e649e --- /dev/null +++ b/docs/plans/emitter-ownership-defork.md @@ -0,0 +1,116 @@ +# Emitter ownership de-fork: one authority for clone-vs-move, no silent fallback + +Lane: `node://adhoc-0717d295-672` (session snappy-newt-504, parent cool-hawk-899 / PR #6248). +Displaced cost (§6): whole-tree `compile --target dag` measured at ~72 min, ~85–90% of it emit; +the emitter's default-clone paths keep `Rc` refcounts ≥ 2, so every `rc_map_insert` / +`rc_list_push` (`Rc::make_mut`) copy-on-writes the *whole* container per iteration — O(n²) +denominated in the corpus, surfacing as the CI timeout (§5's absorbing-fallback cost signature). + +## The fork (§3) + +The Rust emitter decides clone-vs-move in **three** places, each with its own predicate, +while the correct verdict already exists and is bypassed: + +1. `movable` — from `ownership.dag build_movable_set`; governs whole-value var moves + (`05_emit_rust.dag` `emit_var_ref`, `moves_by_value`). Before increment 1 it re-derived + its own criterion (`binding_fan_out == 1`, `is_owned_local`), conflating Read/Projected + *borrows* with *consumes* and excluding params entirely — so a param passed once by value + still cloned at its use site. +2. `read_only_params` — from `build_read_only_params`; governs param borrows. +3. `owned_bindings` — governs **field** moves (`emit_typed_field_access` StoredField, + `base_is_owned`), and is not built by `ownership.dag` at all: it is an ad-hoc emit-time + set populated only with fold-accumulator names inside `emit_rust_fold_method_call`. + So `acc.seen.clone()` — a field projection on a *parameter*, the dominant `dag_collect` + cost — is governed by set 3, which can never contain it, and the correct verdict + (`make_decision` → `SoleOwner`) is never consulted. + +The single authority is `ownership.dag`'s `OwnershipProof` (`make_decision` over +`semantic_consumer_count`, i.e. Consumed edges only, branch-joined). Everything the emitter +does must be *derived* from it (§5 construction-over-validation: the emitter must not be +able to *state* a second ownership opinion). + +## The silent fallback (§5) + +`emit_typed_fold_lambda` emits `Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone())`. +When the structural proof's residual assumption (the Rc is unshared at runtime) fails, +the arm silently widens to a whole-value clone: ⊤-as-answer standing in for +⊤-as-ignorance. Its frequency is zero-by-construction in every metric we watch, so the +deficit never ranks — the textbook absorbing fallback DESIGN.md §5 names. The rule: +**the arm must refuse or be counted, never silently widen.** + +## Increment 1 — de-fork set 1 (whole-value moves) [in this PR] + +`build_movable_set` now filters on `make_decision(usage) == SoleOwner` and admits params +via a `param_names` argument (call site `build_ownership_results` passes +`entry.param_names`). Borrow edges (Read/Projected/Threaded) no longer disqualify a move; +exactly-one-Consumed does the work. Discriminating witness: +`dag/test/claim/ownership_movable_test.dag` (read-then-consume param movable; double-consume +not; zero-consume not). + +Soundness note: `movable` gates only whole-value *reference* emission; Projected sites emit +the bare ident as a field-access base (no consume), so a single-Consumed binding with any +number of borrow uses moves exactly once, at its consume site — which is the last use in +evaluation order for the SoleOwner shape (borrows precede the consume on every path where +both occur; see increment 2 for the per-site generalization that makes this a proof +obligation instead of an argument). + +## Increment 2 — de-fork set 3 (field moves) on a per-site verdict [design] + +Per-function name-sets cannot express "move `acc.seen` here because `acc` dies on this +path". The verdict moves from per-name to per-site (Perceus-style last-use; `.dag` is pure +and tree-shaped, so last-use is mechanical — no borrow checker needed). + +Model (in `ownership.dag`, the one authority): + +- `EdgeClassification` already carries `span_start` — the site key exists. +- New carrier: `UseSiteVerdict = MoveWhole | MoveField { field: String } | Borrow + | CloneShared { decision: OwnershipDecision }`, produced per (binding, span_start). +- Last-use computation: `walk_expr` already visits in evaluation order. The lossy join is + `merge_branch_usages` / `max_usage_by_fan_out`, which keeps one branch's edge list; + it must instead keep per-branch edge lists so "no later use on any path from this site" + is decidable. A site is `MoveWhole`/`MoveField` iff it is the final use of the binding + on every path through it. +- Generalize `FoldAccUnwrapProof` (the existing structured field-move proof: constructs-acc, + whole-acc-single-use, safe-field-moves) from fold-accumulators to *any* owned-entry + binding, params included: if a binding's uses are exactly distinct field projections + (each field ≤ 1 move per path, no whole-value use after any field move), the binding is + take-owned at entry and each projection emits a move. + +Emitter changes (all *readers* of the proof): + +- `EmitGraphInfo` carries the per-fn `site_verdicts` index instead of the three sets. +- `emit_var_ref`, `emit_typed_field_access`, `emit_cloned_arg` key on + (binding, use-site span) and emit exactly what the verdict says. +- `owned_bindings` is deleted as an authority: the fold accumulator becomes an ordinary + owned-entry binding whose entry take-owned and field moves fall out of the same proof + (`analyze_single_fold` stops being consulted at emit time — the proof rows in + `OwnershipProof.fold_acc_unwrap` already exist and become the only surface). + +## §5 conversion of the fallback [lands with increment 2, first in sequence] + +Replace the emitted `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` with a runtime +helper `v1_rt::take_owned_counted(x, site: &'static str)`: + +- try_unwrap; on failure increment a named per-site counter (same instrumentation family as + `record_source_chars_slice_walked`) and clone **once** — the degradation is typed, + located, countable, and observable in the stats dump; never silent. +- Sites the proof classifies `SharedError` (genuine sharing) stay clones *and are counted*: + that counter ranking is exactly the worklist for persistent-structure/HAMT candidates. +- RED control: a fixture with a deliberately shared init Rc must count 1; the reconciled + fixture must count 0. + +The helper lands in both runtimes: `v1_rt.rs` (seed) and the emitted-runtime template +(`v1_compiler_runtime_rust.rs` source in `.dag`). + +## Guards / acceptance + +- `bootstrap_fixed_point` byte-identical emit fixpoint (blocked-on: v1 self-resolution + repair, sibling clever-swift-531 — until it greens, a v1 `.dag` change can only be + validated by hand-syncing the seed; this PR stays **draft** and does not hand-sync). +- `dag_collect` emit receipt: minutes → seconds on the whole tree. +- `pipeline.rs` ownership ratchets move the right way: `movable_but_cloned` (45) drops, + `try_unwrap_fallbacks` string census goes to 0 *silent* occurrences (the counted helper + replaces the string), stage0 clone census drops (currently ~1138 over budget, FLAG'd). +- Non-collision: stern-dove-88 (PR #6242) fixes the immediate `dag_collect` cost at the + `.dag` source level; this lane is the systemic emitter root (~167 sites). W1's source + change stays valid — moves are strictly cheaper after both. From 1ad357205a45d701e223b2f5b0a8bf7138856a59 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 01:23:50 +0000 Subject: [PATCH 03/27] Stage increment-2: per-site move licenses (backward liveness) + counted take-owned fallback + increment-1 soundness wall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ownership.dag: build_move_site_licenses / license_walk — per-site last-use verdicts computed in reverse evaluation order; zero-span and lambda/foreach captures fail closed; branch arms licensed per-path, liveness merged OR-union. - ownership.dag: build_movable_set additionally requires zero Read/Threaded edges — movable gates every whole-value var-ref emission site, so Read-then-Consume would emit use-after-move (latent hole in the first increment-1 draft; witnesses added). - v1_rt + runtime_rust.dag template + 05_emit_rust.dag fold lambda: silent Rc::try_unwrap(..).unwrap_or_else(clone) replaced by take_owned_counted (per-site located counter, DESIGN.md §5 refuse-or-count). - ownership_movable_test.dag: per-site witnesses (span-0 fail-closed, capture fail-closed, field-then-whole blocked, distinct fields licensed, per-path branch licenses). Validation blocked on the v1 self-resolution fixpoint (clever-swift-531); PR stays draft, seed not hand-synced. Co-Authored-By: Claude Fable 5 --- dag/test/claim/ownership_movable_test.dag | 72 +++++++++- docs/plans/emitter-ownership-defork.md | 37 +++-- src/v1/05_emit_rust.dag | 3 +- src/v1/ownership.dag | 156 ++++++++++++++++++++++ src/v1/runtime_rust.dag | 29 ++++ src/v1/stage0/src/v1_rt.rs | 34 +++++ 6 files changed, 318 insertions(+), 13 deletions(-) diff --git a/dag/test/claim/ownership_movable_test.dag b/dag/test/claim/ownership_movable_test.dag index 0d1828b6f08..0e1771a276f 100644 --- a/dag/test/claim/ownership_movable_test.dag +++ b/dag/test/claim/ownership_movable_test.dag @@ -1,6 +1,6 @@ module test.claim.ownership_movable -import v1.compiler.ownership { build_movable_set, make_decision, BindingUsage, EdgeClassification, EdgeKind, OwnershipProof, OwnershipDecision } +import v1.compiler.ownership { build_movable_set, make_decision, BindingUsage, EdgeClassification, EdgeKind, OwnershipProof, OwnershipDecision, MoveLicenseAccum, record_whole_use_site, record_field_use_site, merge_branch_licenses, move_site_key } fn proof_one(name: String, consumers: List) -> OwnershipProof { let usage = BindingUsage { name: name, binding_kind: none, consumers: consumers } @@ -34,3 +34,73 @@ fn witness_zero_consume_is_not_movable() -> Bool { let proof = proof_one(name: "r", consumers: [edge(k: Read, s: "a"), edge(k: Projected, s: ".f")]) movable_of(proof: proof, name: "r") == false } + +fn witness_whole_read_then_consume_is_not_movable() -> Bool { + let proof = proof_one(name: "x", consumers: [edge(k: Read, s: "read"), edge(k: Consumed, s: "return")]) + movable_of(proof: proof, name: "x") == false +} + +fn witness_threaded_then_consume_is_not_movable() -> Bool { + let proof = proof_one(name: "x", consumers: [edge(k: Threaded, s: "fold_init"), edge(k: Consumed, s: "return")]) + movable_of(proof: proof, name: "x") == false +} + +fn empty_license_accum() -> MoveLicenseAccum { + MoveLicenseAccum { live: empty_map(), licensed: empty_map() } +} + +fn licensed_at(acc: MoveLicenseAccum, name: String, span: Int) -> Bool { + match map_get(acc.licensed, move_site_key(name: name, span_start: span)) { + Present { value: v } => v + Absent => false + } +} + +fn witness_site_last_whole_use_is_licensed() -> Bool { + let acc = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 40, in_capture: false) + licensed_at(acc: acc, name: "acc", span: 40) +} + +fn witness_site_zero_span_fails_closed() -> Bool { + let acc = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 0, in_capture: false) + licensed_at(acc: acc, name: "acc", span: 0) == false +} + +fn witness_site_capture_fails_closed() -> Bool { + let acc = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 40, in_capture: true) + licensed_at(acc: acc, name: "acc", span: 40) == false +} + +fn witness_site_earlier_use_before_whole_is_not_licensed() -> Bool { + let later = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 40, in_capture: false) + let earlier = record_whole_use_site(acc: later, name: "acc", span_start: 10, in_capture: false) + licensed_at(acc: earlier, name: "acc", span: 40) && licensed_at(acc: earlier, name: "acc", span: 10) == false +} + +fn witness_site_field_move_then_whole_use_same_path_blocked() -> Bool { + let later_whole = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 40, in_capture: false) + let earlier_field = record_field_use_site(acc: later_whole, name: "acc", field: "seen", span_start: 10, in_capture: false) + licensed_at(acc: earlier_field, name: "acc", span: 10) == false +} + +fn witness_site_distinct_field_moves_both_licensed() -> Bool { + let later = record_field_use_site(acc: empty_license_accum(), name: "acc", field: "seen", span_start: 40, in_capture: false) + let earlier = record_field_use_site(acc: later, name: "acc", field: "count", span_start: 10, in_capture: false) + licensed_at(acc: earlier, name: "acc", span: 40) && licensed_at(acc: earlier, name: "acc", span: 10) +} + +fn witness_site_same_field_twice_only_last_licensed() -> Bool { + let later = record_field_use_site(acc: empty_license_accum(), name: "acc", field: "seen", span_start: 40, in_capture: false) + let earlier = record_field_use_site(acc: later, name: "acc", field: "seen", span_start: 10, in_capture: false) + licensed_at(acc: earlier, name: "acc", span: 40) && licensed_at(acc: earlier, name: "acc", span: 10) == false +} + +fn witness_site_branch_licenses_are_per_path() -> Bool { + let arm_a = record_whole_use_site(acc: empty_license_accum(), name: "acc", span_start: 40, in_capture: false) + let arm_b = record_field_use_site(acc: empty_license_accum(), name: "acc", field: "seen", span_start: 50, in_capture: false) + let merged = merge_branch_licenses(branches: [arm_a, arm_b]) + let before = record_whole_use_site(acc: merged, name: "acc", span_start: 10, in_capture: false) + licensed_at(acc: before, name: "acc", span: 40) + && licensed_at(acc: before, name: "acc", span: 50) + && licensed_at(acc: before, name: "acc", span: 10) == false +} diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md index 12a510e649e..de468da9d18 100644 --- a/docs/plans/emitter-ownership-defork.md +++ b/docs/plans/emitter-ownership-defork.md @@ -42,17 +42,22 @@ deficit never ranks — the textbook absorbing fallback DESIGN.md §5 names. The `build_movable_set` now filters on `make_decision(usage) == SoleOwner` and admits params via a `param_names` argument (call site `build_ownership_results` passes -`entry.param_names`). Borrow edges (Read/Projected/Threaded) no longer disqualify a move; -exactly-one-Consumed does the work. Discriminating witness: -`dag/test/claim/ownership_movable_test.dag` (read-then-consume param movable; double-consume -not; zero-consume not). - -Soundness note: `movable` gates only whole-value *reference* emission; Projected sites emit -the bare ident as a field-access base (no consume), so a single-Consumed binding with any -number of borrow uses moves exactly once, at its consume site — which is the last use in -evaluation order for the SoleOwner shape (borrows precede the consume on every path where -both occur; see increment 2 for the per-site generalization that makes this a proof -obligation instead of an argument). +`entry.param_names`). Discriminating witness: +`dag/test/claim/ownership_movable_test.dag` (projected-then-consume param movable; +double-consume not; zero-consume not; whole-read-then-consume not; threaded-then-consume +not). + +Soundness (the wall that makes per-name movability sound at all): `movable` gates **every** +whole-value var-ref emission (`emit_rust_expr_var` → `emit_var_ref` is reached for call +args, fold inits, record fields — not just tail returns), so a per-name move license is +sound only if the binding has exactly **one** whole-value use site. `Consumed` is recorded +only at tail position (last in evaluation order); `Read`/`Threaded` edges are whole-value +positions emitted *before* it, so any such edge plus a licensed move = use-after-move. +Hence the rule: SoleOwner **and** zero Read/Threaded edges (`whole_value_borrow_count == 0`). +`Projected` edges stay compatible because field-access bases emit the bare ident +(`emit_typed_expr_base`), never a whole-value consume. The original increment-1 draft +admitted Read-then-Consume; that was a latent use-after-move and is fixed here — the +per-site verdict below recovers those sites soundly. ## Increment 2 — de-fork set 3 (field moves) on a per-site verdict [design] @@ -60,6 +65,16 @@ Per-function name-sets cannot express "move `acc.seen` here because `acc` dies o path". The verdict moves from per-name to per-site (Perceus-style last-use; `.dag` is pure and tree-shaped, so last-use is mechanical — no borrow checker needed). +Status: proof-side machinery is implemented in `ownership.dag` +(`build_move_site_licenses` — a backward liveness walk in reverse evaluation order, +O(AST)) with unit witnesses in `ownership_movable_test.dag`; emitter consumption is the +remaining step. Guards baked in: a zero/absent span never licenses (synthetic nodes fail +closed); lambda/foreach bodies license nothing and poison their captures live; branch arms +compute licenses per-path from the shared continuation liveness and merge by union +(licenses) / OR-union (liveness). The emitter must look up a verdict by the same key the +walk recorded: `name@span_start` of the var node for whole moves, of the field-access node +for field moves. + Model (in `ownership.dag`, the one authority): - `EdgeClassification` already carries `span_start` — the site key exists. diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index de5610fe64a..b9d9173019e 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -5588,7 +5588,8 @@ fn emit_typed_fold_lambda(lambda_expr: Node, acc_type_str: String, elem_type_str let needs_unwrap = acc_name != "" && set_contains(emit_info.owned_bindings, acc_name) if needs_unwrap { let acc_ident = emit_ident(name: acc_name, target: Rust) - concat("|", params_str, "| { let ", acc_ident, " = Rc::try_unwrap(", acc_ident, ").unwrap_or_else(|rc| (*rc).clone()); ", body_str, " }") + let site = concat(lambda_expr.span.file, ":", to_string(value: lambda_expr.span.start), ":", acc_name) + concat("|", params_str, "| { let ", acc_ident, " = v1_rt::take_owned_counted(", acc_ident, ", \"", site, "\"); ", body_str, " }") } else { concat("|", params_str, "| ", body_str) } diff --git a/src/v1/ownership.dag b/src/v1/ownership.dag index db8986b0d1c..ebf9726bbf6 100644 --- a/src/v1/ownership.dag +++ b/src/v1/ownership.dag @@ -300,10 +300,15 @@ fn is_owned_local(kind: VarBindingKind?) -> Bool { } } +fn whole_value_borrow_count(usage: BindingUsage) -> Int { + usage.consumers |> filter(c => match c.kind { Read => true, Threaded => true, _ => false }) |> count +} + fn build_movable_set(proof: OwnershipProof, param_names: Set) -> Set { proof.bindings |> map_values |> filter(usage => (match make_decision(usage: usage) { SoleOwner { binding: _, site: _ } => true, _ => false }) + && whole_value_borrow_count(usage: usage) == 0 && (is_owned_local(kind: usage.binding_kind) || set_contains(param_names, usage.name))) |> fold(init: empty_set(), f: (acc, usage) => set_insert(acc, usage.name)) } @@ -562,3 +567,154 @@ fn analyze_ownership(func_name: String, params: List, body: Node, si: Map< fold_acc_unwrap: fold_proofs } } + +type LiveState { + name: String + whole: Bool + any_field: Bool + fields: Set +} + +type MoveLicenseAccum { + live: Map + licensed: Map +} + +fn move_site_key(name: String, span_start: Int) -> String { + concat(name, "@", to_string(value: span_start)) +} + +fn empty_live_state(name: String) -> LiveState { + LiveState { name: name, whole: false, any_field: false, fields: empty_set() } +} + +fn live_state_of(acc: MoveLicenseAccum, name: String) -> LiveState { + match map_get(acc.live, name) { + Present { value: st } => st + Absent => empty_live_state(name: name) + } +} + +fn record_whole_use_site(acc: MoveLicenseAccum, name: String, span_start: Int, in_capture: Bool) -> MoveLicenseAccum { + let st = live_state_of(acc: acc, name: name) + let movable_here = !in_capture && span_start != 0 && !st.whole && !st.any_field + let licensed = if movable_here { map_insert(acc.licensed, move_site_key(name: name, span_start: span_start), true) } else { acc.licensed } + MoveLicenseAccum { + live: map_insert(acc.live, name, LiveState { name: name, whole: true, any_field: st.any_field, fields: st.fields }), + licensed: licensed + } +} + +fn record_field_use_site(acc: MoveLicenseAccum, name: String, field: String, span_start: Int, in_capture: Bool) -> MoveLicenseAccum { + let st = live_state_of(acc: acc, name: name) + let movable_here = !in_capture && span_start != 0 && !st.whole && !set_contains(st.fields, field) + let licensed = if movable_here { map_insert(acc.licensed, move_site_key(name: name, span_start: span_start), true) } else { acc.licensed } + MoveLicenseAccum { + live: map_insert(acc.live, name, LiveState { name: name, whole: st.whole, any_field: true, fields: set_insert(st.fields, field) }), + licensed: licensed + } +} + +fn merge_live_states(a: LiveState, b: LiveState) -> LiveState { + LiveState { name: a.name, whole: a.whole || b.whole, any_field: a.any_field || b.any_field, fields: set_union(a.fields, b.fields) } +} + +fn merge_branch_licenses(branches: List) -> MoveLicenseAccum { + branches |> fold(init: MoveLicenseAccum { live: empty_map(), licensed: empty_map() }, f: (acc, br) => + let live_merged = map_keys(br.live) |> fold(init: acc.live, f: (lm, k) => + let b_st = match map_get(br.live, k) { + Present { value: s } => s + Absent => empty_live_state(name: k) + } + match map_get(lm, k) { + Present { value: a_st } => map_insert(lm, k, merge_live_states(a: a_st, b: b_st)) + Absent => map_insert(lm, k, b_st) + } + ) + let lic_merged = map_keys(br.licensed) |> fold(init: acc.licensed, f: (l, k) => map_insert(l, k, true)) + MoveLicenseAccum { live: live_merged, licensed: lic_merged } + ) +} + +fn license_walk(acc: MoveLicenseAccum, texpr: Node, in_capture: Bool, si: Map) -> MoveLicenseAccum { + match texpr.expr_data { + ExprVar { binding_kind: _ } => + record_whole_use_site(acc: acc, name: expr_var_name_at(texpr: texpr, source_indices: si), span_start: texpr.span.start, in_capture: in_capture) + + ExprLiteral { value: _ } => acc + + ExprFieldAccess => + let base_node = field_access_base(texpr: texpr) + match base_node.expr_data { + ExprVar { binding_kind: _ } => + record_field_use_site(acc: acc, name: expr_var_name_at(texpr: base_node, source_indices: si), field: field_access_field_at(texpr: texpr, source_indices: si), span_start: texpr.span.start, in_capture: in_capture) + _ => license_walk(acc: acc, texpr: base_node, in_capture: in_capture, si: si) + } + + ExprCall => + texpr.children |> reverse |> fold(init: acc, f: (a, arg) => + license_walk(acc: a, texpr: arg_value(n: arg), in_capture: in_capture, si: si) + ) + + ExprMethodCall => + let args_acc = method_arg_nodes(texpr: texpr) |> reverse |> fold(init: acc, f: (a, arg) => + license_walk(acc: a, texpr: arg_value(n: arg), in_capture: in_capture, si: si) + ) + license_walk(acc: args_acc, texpr: method_receiver(texpr: texpr), in_capture: in_capture, si: si) + + ExprIf => + let t_acc = license_walk(acc: acc, texpr: if_then_branch(texpr: texpr), in_capture: in_capture, si: si) + let e_acc = match if_else_branch(texpr: texpr) { + Present { value: eb } => license_walk(acc: acc, texpr: eb, in_capture: in_capture, si: si) + Absent => acc + } + let merged = merge_branch_licenses(branches: [t_acc, e_acc]) + license_walk(acc: merged, texpr: if_condition(texpr: texpr), in_capture: in_capture, si: si) + + ExprMatch => + let branch_accs = match_arm_nodes(texpr: texpr) |> map(arm_node => + license_walk(acc: acc, texpr: arm_body(n: arm_node), in_capture: in_capture, si: si) + ) + let merged = merge_branch_licenses(branches: branch_accs) + license_walk(acc: merged, texpr: match_scrutinee(texpr: texpr), in_capture: in_capture, si: si) + + ExprLet => + let body_acc = match let_body(texpr: texpr) { + Present { value: b } => license_walk(acc: acc, texpr: b, in_capture: in_capture, si: si) + Absent => acc + } + license_walk(acc: body_acc, texpr: let_value(texpr: texpr), in_capture: in_capture, si: si) + + ExprBlock => + texpr.children |> reverse |> fold(init: acc, f: (a, child) => + license_walk(acc: a, texpr: child, in_capture: in_capture, si: si) + ) + + ExprReturn => + texpr.children |> reverse |> fold(init: acc, f: (a, child) => + license_walk(acc: a, texpr: child, in_capture: in_capture, si: si) + ) + + ExprLambda => + license_walk(acc: acc, texpr: lambda_body(texpr: texpr), in_capture: true, si: si) + + ExprForEach => + let body_acc = license_walk(acc: acc, texpr: foreach_body(texpr: texpr), in_capture: true, si: si) + license_walk(acc: body_acc, texpr: foreach_collection(texpr: texpr), in_capture: in_capture, si: si) + + ExprRecordLit => + texpr.children |> reverse |> fold(init: acc, f: (a, field) => + license_walk(acc: a, texpr: arg_value(n: field), in_capture: in_capture, si: si) + ) + + _ => + texpr.children |> reverse |> fold(init: acc, f: (a, child) => + license_walk(acc: a, texpr: child, in_capture: in_capture, si: si) + ) + } +} + +fn build_move_site_licenses(body: Node, si: Map) -> Map { + let walked = license_walk(acc: MoveLicenseAccum { live: empty_map(), licensed: empty_map() }, texpr: body, in_capture: false, si: si) + walked.licensed +} diff --git a/src/v1/runtime_rust.dag b/src/v1/runtime_rust.dag index ab29f8c17ef..4645b4b0864 100644 --- a/src/v1/runtime_rust.dag +++ b/src/v1/runtime_rust.dag @@ -328,6 +328,35 @@ fn rt_rc_container_ops() -> String { "// containers for O(1) clone cost. Generated code using Rc container templates\n", "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n", "// map_contains_key, map_has) work with Rc via auto-deref.\n\n", + "// take_owned_counted: fail-closed replacement for the silent\n", + "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n", + "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n", + "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n", + "// per emitted site so the deficit frequency stays observable.\n", + "thread_local! {\n", + " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n", + " std::cell::RefCell::new(HashMap::new());\n", + "}\n\n", + "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n", + " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n", + " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n", + " (*rc).clone()\n", + " })\n", + "}\n\n", + "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n", + " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n", + " let mut v: Vec<(String, u64)> = m\n", + " .borrow()\n", + " .iter()\n", + " .map(|(site, n)| (site.to_string(), *n))\n", + " .collect();\n", + " v.sort();\n", + " v\n", + " })\n", + "}\n\n", + "pub fn reset_take_owned_clone_fallbacks() {\n", + " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n", + "}\n\n", "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n", " let mut v = list;\n", " Rc::make_mut(&mut v).push(item);\n", diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 08456124cfb..a0826e3e1bf 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -335,6 +335,40 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. +// take_owned_counted: the fail-closed replacement for the silent +// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: +// a failure arm must refuse or be counted, never silently widen). The ownership +// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose +// per-site frequency must stay observable, so the clone arm counts per emitted +// site (site = ":" of the use-site the emitter rewrote). +thread_local! { + static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = + std::cell::RefCell::new(HashMap::new()); +} + +pub fn take_owned_counted(x: Rc, site: &'static str) -> T { + Rc::try_unwrap(x).unwrap_or_else(|rc| { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); + (*rc).clone() + }) +} + +pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| { + let mut v: Vec<(String, u64)> = m + .borrow() + .iter() + .map(|(site, n)| (site.to_string(), *n)) + .collect(); + v.sort(); + v + }) +} + +pub fn reset_take_owned_clone_fallbacks() { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); +} + pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From 416e9977ca3f0aa6a5099b2219ea7d28e350fdbd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 01:29:16 +0000 Subject: [PATCH 04/27] Wire per-site move licenses through the emitter (whole-value consumption) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - build_ownership_results computes build_move_site_licenses per function; OwnershipBuildResult/EmitGraphInfo carry move_sites_index + per-fn move_sites (TCO functions fail closed to empty: loop-rewritten bodies reuse bindings across iterations, so per-site last-use does not transfer). - emit_var_ref: moves when per-name movable OR move_licensed_at_site (span-keyed name@span, read_only_params excluded, span-0 refused); both callers thread the use-site span the license walk keyed on. - Field-move consumption (entry take-owned generalization, deletes owned_bindings) held for post-fixpoint compile feedback — addendum in docs/plans/emitter-ownership-defork.md. Co-Authored-By: Claude Fable 5 --- docs/plans/emitter-ownership-defork.md | 25 ++++++++++++++- src/v1/04_emit_info.dag | 5 +++ src/v1/04_infer.dag | 2 ++ src/v1/05_emit_rust.dag | 44 +++++++++++++++++++++----- 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md index de468da9d18..03f5e8534dd 100644 --- a/docs/plans/emitter-ownership-defork.md +++ b/docs/plans/emitter-ownership-defork.md @@ -65,7 +65,30 @@ Per-function name-sets cannot express "move `acc.seen` here because `acc` dies o path". The verdict moves from per-name to per-site (Perceus-style last-use; `.dag` is pure and tree-shaped, so last-use is mechanical — no borrow checker needed). -Status: proof-side machinery is implemented in `ownership.dag` +Status: proof-side machinery AND whole-value emitter consumption are implemented; +field-move emitter consumption (entry take-owned generalization) remains. Wired: +`OwnershipBuildResult.move_sites_index` → `EmitGraphInfo.move_sites_index` / per-fn +`move_sites` (TCO functions get an empty map — loop-rewritten bodies reuse bindings across +iterations, so per-site last-use does not transfer; fail closed) → `emit_var_ref` moves +when `movable` (per-name) OR `move_licensed_at_site` (per-site, span-keyed, +`read_only_params` excluded, span-0 refused). Validation-time obligations: (a) a counted +licensed-but-cloned check in `count_ownership_violations` so a span-keying drift is +observable, not a silent clone (parent guard); (b) `count_ownership_violations` / +`ownership_movable_test` call `build_movable_set` with the new `param_names` arg once the +regenerated seed lands (the seed-side Rust test still compiles against the old signature +until then); (c) a by-execution RED/GREEN test for `take_owned_counted` counts. + +Field-move step (not yet wired, design addendum): emitting `base.field` as a move is only +valid on an owned (non-`Rc`) base, so licensed field moves require the generalized entry +take-owned: params whose every use is a `Projected` edge (zero whole-value edges) on a +shared-type param get `let x = v1_rt::take_owned_counted(x, site)` at fn entry; licensed +projection sites then move, unlicensed ones clone the field (cheap `Rc` bump for container +fields). This is what deletes `owned_bindings` as an authority — the fold accumulator +becomes the special case of the same rule. Held for compile feedback (post-fixpoint): +blind-writing the `emit_fn_def` entry rewrite without `cargo build` of a regenerated seed +risks template-level use-after-move that only rustc can adjudicate. + +Model (in `ownership.dag`, the one authority): (`build_move_site_licenses` — a backward liveness walk in reverse evaluation order, O(AST)) with unit witnesses in `ownership_movable_test.dag`; emitter consumption is the remaining step. Guards baked in: a zero/absent span never licenses (synthetic nodes fail diff --git a/src/v1/04_emit_info.dag b/src/v1/04_emit_info.dag index c33796865ea..6ed990da52f 100644 --- a/src/v1/04_emit_info.dag +++ b/src/v1/04_emit_info.dag @@ -49,6 +49,9 @@ type EmitGraphInfo { variant_to_enum: Map owned_bindings: Set + move_sites_index: Map> + move_sites: Map + read_only_params_index: Map> read_only_params: Set @@ -70,6 +73,8 @@ fn empty_emit_graph_info() -> EmitGraphInfo { movable: empty_set(), variant_to_enum: empty_map(), owned_bindings: empty_set(), + move_sites_index: empty_map(), + move_sites: empty_map(), read_only_params_index: empty_map(), read_only_params: empty_set(), diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 890ce75458e..c3a34953445 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -6482,6 +6482,8 @@ fn build_emit_graph_info(modules: List) -> EmitGraphInfo { movable: empty_set(), variant_to_enum: vtoe, owned_bindings: empty_set(), + move_sites_index: empty_map(), + move_sites: empty_map(), read_only_params_index: empty_map(), read_only_params: empty_set(), corpus_repr: rust_corpus_repr(modules: modules) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b9d9173019e..02a319a5151 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -104,7 +104,7 @@ import v1.compiler.infer_emit_info { } import v1.compiler.resolve { get_exported_names } import v1.compiler.infer_resolve { resolve_node, lookup_unit_variant_phantom_type, is_width_nat_type_literal } -import v1.compiler.ownership { OwnershipProof, analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, collect_callable_refs } +import v1.compiler.ownership { OwnershipProof, analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, build_move_site_licenses, move_site_key, collect_callable_refs } import std.induction { SubValueUnknown, InductiveField } import v1.compiler.emit { @@ -1570,11 +1570,13 @@ type OwnershipProofEntry { name: String proof: OwnershipProof param_names: Set + move_sites: Map } type OwnershipBuildResult { ownership_index: Map> read_only_params_index: Map> + move_sites_index: Map> } fn build_ownership_results(modules: List) -> OwnershipBuildResult { @@ -1590,16 +1592,17 @@ fn build_ownership_results(modules: List) -> OwnershipBuildResult { ) let si = m.type_env.source_indices let qualified = concat(authored_name_at(source_indices: si, node: m.module), ".", authored_name_at(source_indices: si, node: item)) - OwnershipProofEntry { name: qualified, proof: analyze_ownership(func_name: authored_name_at(source_indices: si, node: item), params: item.params, body: item.body.value, si: si), param_names: pnames } + OwnershipProofEntry { name: qualified, proof: analyze_ownership(func_name: authored_name_at(source_indices: si, node: item), params: item.params, body: item.body.value, si: si), param_names: pnames, move_sites: build_move_site_licenses(body: item.body.value, si: si) } ) ) - proofs |> fold(init: OwnershipBuildResult { ownership_index: empty_map(), read_only_params_index: empty_map() }, f: (acc, entry) => + proofs |> fold(init: OwnershipBuildResult { ownership_index: empty_map(), read_only_params_index: empty_map(), move_sites_index: empty_map() }, f: (acc, entry) => let read_only = if set_contains(callable_set, entry.proof.func_name) { empty_set() } else { build_read_only_params(proof: entry.proof, param_names: entry.param_names) } let movable = build_movable_set(proof: entry.proof, param_names: entry.param_names) OwnershipBuildResult { ownership_index: map_insert(acc.ownership_index, entry.name, movable), - read_only_params_index: map_insert(acc.read_only_params_index, entry.name, read_only) + read_only_params_index: map_insert(acc.read_only_params_index, entry.name, read_only), + move_sites_index: map_insert(acc.move_sites_index, entry.name, entry.move_sites) } ) } @@ -1618,6 +1621,8 @@ fn emit_rust(typed: ResolvedGraph) -> EmitResult { movable: empty_set(), variant_to_enum: base_info.variant_to_enum, owned_bindings: empty_set(), + move_sites_index: ownership.move_sites_index, + move_sites: empty_map(), read_only_params_index: ownership.read_only_params_index, read_only_params: empty_set(), corpus_repr: base_info.corpus_repr @@ -1718,6 +1723,8 @@ fn emit_module(typed_module: TypedModule, registry: Map) -> Te movable: base_info.movable, variant_to_enum: base_info.variant_to_enum, owned_bindings: empty_set(), + move_sites_index: base_info.move_sites_index, + move_sites: base_info.move_sites, read_only_params_index: base_info.read_only_params_index, read_only_params: empty_set(), corpus_repr: base_info.corpus_repr @@ -3152,6 +3159,12 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map empty_set() } } + let fn_move_sites = if item_is_tco { empty_map() } else { + match map_get(emit_info.move_sites_index, qualified_name) { + Present { value: m } => m + Absent => empty_map() + } + } let fn_emit_info = EmitGraphInfo { type_summaries: emit_info.type_summaries, recursive_type_set: emit_info.recursive_type_set, @@ -3162,6 +3175,8 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map, registry: Map, emit_info: EmitGraphInfo, source_indices: Map) -> String { +fn move_licensed_at_site(emit_info: EmitGraphInfo, name: String, use_span: Int) -> Bool { + if use_span == 0 { false } else { + match map_get(emit_info.move_sites, move_site_key(name: name, span_start: use_span)) { + Present { value: v } => v && !set_contains(emit_info.read_only_params, name) + Absent => false + } + } +} + +fn emit_var_ref(name: String, binding_kind: VarBindingKind?, resolved_type: InferredNode?, use_span: Int, shared_types: Set, registry: Map, emit_info: EmitGraphInfo, source_indices: Map) -> String { if name == "none" || name == "None" { emit_keyword(key: "null", target: Rust) } else if name == "true" || name == "false" { emit_keyword(key: name, target: Rust) } else { - let moves_by_value = set_contains(emit_info.movable, name) + let moves_by_value = set_contains(emit_info.movable, name) || move_licensed_at_site(emit_info: emit_info, name: name, use_span: use_span) let sharing = language_spec(target: Rust).sharing let variant_parent = effective_variant_parent(name: name, binding_kind: binding_kind, resolved_type: resolved_type, emit_info: emit_info, source_indices: source_indices) let ref_str = match variant_parent { @@ -4928,7 +4952,7 @@ fn emit_rust_expr_var(expr: Node, registry: Map, shared_types: match expr.expr_data { ExprVar { binding_kind: binding_kind } => let n = expr_var_name_at(texpr: expr, source_indices: source_indices) - emit_var_ref(name: n, binding_kind: binding_kind, resolved_type: expr.inferred, shared_types: shared_types, registry: registry, emit_info: emit_info, source_indices: source_indices) + emit_var_ref(name: n, binding_kind: binding_kind, resolved_type: expr.inferred, use_span: expr.span.start, shared_types: shared_types, registry: registry, emit_info: emit_info, source_indices: source_indices) _ => emit_error_expr(message: "emit_rust_expr_var expected ExprVar", target: Rust) } } @@ -5662,6 +5686,8 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod movable: emit_info.movable, variant_to_enum: emit_info.variant_to_enum, owned_bindings: set_insert(emit_info.owned_bindings, acc_name), + move_sites_index: emit_info.move_sites_index, + move_sites: emit_info.move_sites, read_only_params_index: emit_info.read_only_params_index, read_only_params: emit_info.read_only_params, corpus_repr: emit_info.corpus_repr @@ -5686,6 +5712,8 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod movable: set_insert(emit_info.movable, acc_name), variant_to_enum: emit_info.variant_to_enum, owned_bindings: emit_info.owned_bindings, + move_sites_index: emit_info.move_sites_index, + move_sites: emit_info.move_sites, read_only_params_index: emit_info.read_only_params_index, read_only_params: emit_info.read_only_params, corpus_repr: emit_info.corpus_repr @@ -6228,7 +6256,7 @@ fn emit_typed_match_arm(arm: Node, registry: Map, scope: Infer ExprVar { binding_kind: body_binding_kind } => let body_name = expr_var_name_at(texpr: arm_b, source_indices: si) if variant_parent_from_binding_kind(binding_kind: body_binding_kind) != none { - emit_var_ref(name: body_name, binding_kind: body_binding_kind, resolved_type: Present { value: Resolved { node: match_result_type } }, shared_types: shared_types, registry: registry, emit_info: emit_info, source_indices: si) + emit_var_ref(name: body_name, binding_kind: body_binding_kind, resolved_type: Present { value: Resolved { node: match_result_type } }, use_span: arm_b.span.start, shared_types: shared_types, registry: registry, emit_info: emit_info, source_indices: si) } else { emit_typed_expr(texpr: arm_b, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) } From d20f288930ad96b3bebda6bdb64e0950c510126f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 01:32:12 +0000 Subject: [PATCH 05/27] Design doc: consolidated validation-time checklist (parent-endorsed sequencing) Co-Authored-By: Claude Fable 5 --- docs/plans/emitter-ownership-defork.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md index 03f5e8534dd..0d2833ca258 100644 --- a/docs/plans/emitter-ownership-defork.md +++ b/docs/plans/emitter-ownership-defork.md @@ -140,6 +140,20 @@ helper `v1_rt::take_owned_counted(x, site: &'static str)`: The helper lands in both runtimes: `v1_rt.rs` (seed) and the emitted-runtime template (`v1_compiler_runtime_rust.rs` source in `.dag`). +## Validation-time checklist (one combined pass when the fixpoint PR #6250 greens) + +1. Regenerate the seed (picks up 2-arg `build_movable_set`, `move_sites` wiring, + `take_owned_counted` emission). +2. Update `pipeline.rs count_ownership_violations` to the 2-arg `build_movable_set` + **in the same change** (it will not compile against the new seed otherwise), and add + the licensed-but-cloned counted check (span-keying drift must be observable). +3. Land the generalized entry take-owned rewrite (field moves; deletes `owned_bindings`) + with rustc feedback. +4. Run `bootstrap_fixed_point` (byte-identical), the `dag_collect` emit receipt (min → s), + and the `take_owned_counted` by-execution RED/GREEN count test. +5. Confirm all ownership witnesses green (per-name and per-site: span-0, capture, + field-then-whole, distinct-fields, same-field-twice, branch). + ## Guards / acceptance - `bootstrap_fixed_point` byte-identical emit fixpoint (blocked-on: v1 self-resolution From 6c904804148851e52d82ab12ec99d45dc9a15597 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 02:38:49 +0000 Subject: [PATCH 06/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/04_method.dag | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v1/04_method.dag b/src/v1/04_method.dag index fd2345a797e..cb5cd096453 100644 --- a/src/v1/04_method.dag +++ b/src/v1/04_method.dag @@ -88,6 +88,7 @@ fn builtin_function_registry() -> Map { let m = map_insert(m, "map_keys", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "map_values", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "reverse", list_of_type_variable(id: "collection_element")) + let m = map_insert(m, "get", with_optional_cardinality(n: type_variable_node(id: "collection_element"))) let m = map_insert(m, "list_push", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "hash_combine", hash_type) let m = map_insert(m, "atom_identity_hash", hash_type) From b637a11ef74c83f681d5af59852c4852668fdb75 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 02:49:34 +0000 Subject: [PATCH 07/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 797 ++++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 2 + .../stage0/src/v1_compiler_infer_emit_info.rs | 4 + src/v1/stage0/src/v1_compiler_infer_method.rs | 62 +- src/v1/stage0/src/v1_compiler_ownership.rs | 364 +++++++- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/tests/src/pipeline.rs | 10 +- 7 files changed, 855 insertions(+), 386 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b45fa7ffa52..edaf8bd9ff0 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, - collect_callable_refs, + analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, + build_read_only_params, collect_callable_refs, move_site_key, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,11 +1401,6 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { - if let Some(host) = - rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) - { - return host; - } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2105,7 +2100,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match wire_item.body.clone() { + match (*wire_item.body).clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2151,7 +2146,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match wc.body.clone() { + match (*wc.body).clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2298,7 +2293,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2316,7 +2311,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2375,7 +2370,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match item.type_annotation.clone() { + match (*item.type_annotation).clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2428,7 +2423,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2453,7 +2448,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -2608,8 +2603,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2625,8 +2620,10 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = - authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at( + (*tm.type_env).clone().source_indices.clone(), + item.clone(), + ); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2662,8 +2659,8 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2682,21 +2679,21 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), item.clone(), ), item.clone(), ) }, ); - module_imports(typed_module.module.clone()) + module_imports((*typed_module.module).clone()) .iter() .cloned() .fold( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2704,7 +2701,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), ) .iter() .cloned() @@ -3251,12 +3248,14 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, + pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, + pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3267,7 +3266,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), + move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3367,7 +3371,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: ownership.move_sites_index.clone(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3437,8 +3448,8 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3446,7 +3457,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3482,16 +3493,16 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -3517,8 +3528,10 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3669,6 +3682,8 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: base_info.move_sites_index.clone(), + move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3697,12 +3712,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); let exported = get_exported_names( - tm.module.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.module).clone(), + (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3727,17 +3742,17 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ @@ -3746,7 +3761,7 @@ pub fn emit_module_full( __result.extend( (*import_specific_names_at( imp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) .iter() .cloned(), @@ -3763,11 +3778,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __result.push(item); @@ -3778,7 +3793,7 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); @@ -3789,7 +3804,7 @@ pub fn emit_module_full( local_type_names, export_sets.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3798,14 +3813,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3866,7 +3881,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3881,7 +3896,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ), "::*;".to_string(), )); @@ -3902,18 +3917,18 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name(scope.type_env.clone(), m.clone()); + let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3922,7 +3937,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3930,7 +3945,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3953,8 +3968,10 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) - == "wire_contract".to_string())) + && (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + i.clone(), + ) == "wire_contract".to_string())) { __result.push(i); } @@ -3968,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3986,26 +4003,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) + let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4123,8 +4140,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4136,8 +4153,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4196,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports(tm.module.clone()), + Some(tm) => module_imports((*tm.module).clone()), None => Rc::new(vec![]), } } @@ -4211,7 +4228,10 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); + __result.push(authored_name_at( + source_indices.clone(), + (*tm.module).clone(), + )); } __result }) @@ -4384,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4476,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4586,7 +4606,8 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() + for imp in + module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4637,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) + for imp in module_imports((*tm.module).clone()) .iter() .cloned() { @@ -4905,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5162,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5198,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5658,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5687,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5826,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - scope.type_env.clone(), + (*scope.type_env).clone(), name.clone(), ) { true @@ -5891,8 +5912,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -7208,7 +7229,7 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), authored_name(env.clone(), item.clone()), @@ -7480,11 +7501,11 @@ pub fn emit_typed_item( }; let item_is_tco = is_tco_eligible( authored_name(env.clone(), item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco { + let fn_read_only = if item_is_tco.clone() { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7495,6 +7516,17 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; + let fn_move_sites = if item_is_tco.clone() { + v1_rt::rc_empty_map::() + } else { + match v1_rt::map_get( + &emit_info.move_sites_index.clone(), + qualified_name.clone(), + ) { + Some(m) => m.clone(), + None => v1_rt::rc_empty_map::(), + } + }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7507,6 +7539,8 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), @@ -7527,7 +7561,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7538,7 +7572,7 @@ pub fn emit_typed_item( item_text.clone(), item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7550,8 +7584,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text.clone(), - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7593,6 +7627,15 @@ pub fn emit_typed_item( } } +pub fn needs_box_wrapping_shared_dominates() -> String { + thread_local! { + static CACHED: String = { + "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7600,34 +7643,31 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { - // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box - // — shared_types dominates the recursive check. Replaced by regen's - // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } - if ((n.children.clone().len() as i64) == 0) { - { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } - } } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; } else { - break false; + if ((n.children.clone().len() as i64) == 0) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; + } else { + break v1_rt::set_contains(&recursive_types, name.clone()); + } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } + } } } } @@ -9561,7 +9601,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9642,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9651,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9669,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9899,19 +9939,19 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_func_inferred( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -9981,7 +10021,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12079,7 +12119,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { + let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -12222,10 +12262,28 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } +pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { + if (use_span.clone() == 0) { + false + } else { + match v1_rt::map_get( + &emit_info.move_sites.clone(), + move_site_key(name.clone(), use_span.clone()), + ) { + Some(v) => { + (v.clone() + && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + } + None => false, + } + } +} + pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, + use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12238,7 +12296,9 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); + let moves_by_value = + (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) + || move_licensed_at_site(emit_info.clone(), name.clone(), use_span)); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12347,7 +12407,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12448,18 +12508,18 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); match find_child_named( base_struct, field, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12469,18 +12529,23 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - let faithful_nat_field = - matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) - && (field_ty_name.clone() == "Nat".to_string() - || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); - faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) + { + let faithful_nat_field = ((emit_info.corpus_repr.clone() + == RustCorpusRepr::FaithfulFreeMonoid) + && ((field_ty_name.clone() == "Nat".to_string()) + || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); + ((faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + (*scope.type_env).clone().source_indices.clone(), + )) + || is_recursive_type_by_name( + (*scope.type_env).clone(), + field_ty_name.clone(), + )) + } } } None => false, @@ -12548,7 +12613,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12611,7 +12676,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -12985,6 +13050,7 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), + expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13007,7 +13073,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13016,11 +13082,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13065,7 +13131,10 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let f = expr_call_func_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_call_expr( f, expr.children.clone(), @@ -13099,8 +13168,10 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = - expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let m = expr_method_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_method_call( expr.clone(), r, @@ -13175,8 +13246,10 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13212,14 +13285,14 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13379,7 +13452,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13398,8 +13471,10 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = - foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let v = foreach_variable_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13507,7 +13582,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13526,7 +13601,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, |expr| { @@ -13759,9 +13834,11 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = - resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); - match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { + let ty_name = resolved_type_name( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); + match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13770,7 +13847,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name(scope.type_env.clone(), child.clone()); + authored_name((*scope.type_env).clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13779,7 +13856,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13888,7 +13965,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13913,7 +13990,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14046,7 +14123,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14061,7 +14138,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14190,7 +14267,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14337,7 +14414,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14405,8 +14482,10 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) - { + match arg_name_at( + a.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { Some(n) => n.clone(), None => "".to_string(), }, @@ -14424,7 +14503,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __found = true; @@ -14450,7 +14529,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14475,7 +14554,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14593,7 +14672,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14650,11 +14729,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14715,7 +14794,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14908,7 +14987,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14926,7 +15005,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -14970,7 +15049,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15017,7 +15096,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15039,6 +15118,19 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); + let site = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + lambda_expr.span.clone().file.clone(), + ":".to_string(), + ), + (lambda_expr.span.clone().start.clone()).to_string(), + ), + ":".to_string(), + ), + acc_name.clone(), + ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15046,16 +15138,22 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), + ), + acc_ident.clone(), + ), + " = v1_rt::take_owned_counted(".to_string(), ), acc_ident.clone(), ), - " = Rc::try_unwrap(".to_string(), + ", \"".to_string(), ), - acc_ident.clone(), + site, ), - ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), + "\"); ".to_string(), ), body_str, ), @@ -15107,7 +15205,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15148,33 +15246,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15191,7 +15289,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if (arg_value(init_arg.clone()).inferred.clone() != None) { + if ((*arg_value(init_arg.clone()).inferred).clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15202,7 +15300,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15212,7 +15310,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) .first() .cloned() @@ -15224,7 +15322,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15238,7 +15336,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15256,6 +15354,8 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15271,7 +15371,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15289,6 +15389,8 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15306,7 +15408,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15364,7 +15466,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15376,7 +15478,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15402,7 +15504,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15451,7 +15553,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }; @@ -15523,7 +15625,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15535,7 +15637,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { "_".to_string() @@ -15610,7 +15712,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15675,7 +15777,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15773,7 +15875,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15897,7 +15999,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -15954,7 +16056,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15972,7 +16074,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16045,7 +16147,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16249,7 +16351,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16378,13 +16480,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -16950,7 +17052,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17020,11 +17122,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17056,7 +17158,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17198,7 +17300,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17297,6 +17399,7 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), + arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17395,7 +17498,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17475,11 +17578,11 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name(scope.type_env.clone(), struct_name) { + match lookup_type_by_name((*scope.type_env).clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17506,8 +17609,10 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); + let receiver_type_name = authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + receiver_type, + ); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17524,7 +17629,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, } @@ -17571,7 +17676,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17599,7 +17704,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - (binding.resolved.clone().return_cardinality.clone() + ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17642,7 +17747,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_base, ), f, @@ -17776,7 +17881,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17784,7 +17889,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17793,7 +17898,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18013,13 +18118,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18040,7 +18145,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18056,7 +18161,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18130,7 +18235,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18140,7 +18245,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18150,7 +18255,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ), @@ -18170,7 +18275,10 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18251,20 +18359,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = resolve_node( + let resolved_struct = (*resolve_node( resolved_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) - .resolved - .clone(); + .resolved) + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18521,7 +18629,10 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18588,7 +18699,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18676,7 +18787,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18807,7 +18918,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -18891,10 +19002,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19210,8 +19321,10 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + stmt.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19227,7 +19340,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19297,15 +19410,18 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = emit_typed_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19332,11 +19448,11 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19553,7 +19669,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19611,10 +19727,10 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19629,12 +19745,18 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), rt.clone(), ) } @@ -19671,7 +19793,10 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19775,14 +19900,17 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19797,7 +19925,10 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) == n.clone()) { __found = true; @@ -19867,9 +19998,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -19926,7 +20057,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - frame.expr.clone(), + (*frame.expr).clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20043,7 +20174,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20194,7 +20325,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -21603,7 +21734,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match state.node.clone() { + let next_node = match (*state.node).clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21639,7 +21770,7 @@ pub fn advance_wire_path_projection( }) } } else { - match state.node.clone() { + match (*state.node).clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -22874,7 +23005,8 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) + && ((*annotation.type_annotation).clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -22906,12 +23038,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -22920,7 +23052,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -22929,11 +23061,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -22964,7 +23096,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ); @@ -22975,16 +23107,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23088,10 +23220,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23100,19 +23232,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23120,14 +23252,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23159,7 +23291,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23175,7 +23307,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23191,7 +23323,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23200,7 +23332,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -23208,7 +23340,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23228,13 +23360,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23251,14 +23383,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23281,8 +23413,7 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -23346,14 +23477,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -23774,7 +23905,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match data_item.body.clone() { + Some(data_item) => match (*data_item.body).clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23847,7 +23978,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if (item.body.clone() == None) { + if ((*item.body).clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -23881,7 +24012,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), ) { __result.push(item); } @@ -23894,12 +24025,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), registry.clone(), tm.items.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -23972,7 +24103,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )), None => "".to_string(), }; @@ -24009,8 +24140,10 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 0525069bf0f..988059445b2 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -14606,6 +14606,8 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 8dc46a13d29..b19d756df6d 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,6 +83,8 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, + pub move_sites_index: Rc>>>, + pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -104,6 +106,8 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 25d635b19b1..12c6fb18bc5 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,28 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - make_map_type( + (*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty - .clone() + .ty) + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)) - .ty - .clone() + (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() } pub fn list_of_element(element: Rc) -> Rc { - make_container_type("List".to_string(), element).ty.clone() + (*make_container_type("List".to_string(), element).ty).clone() } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element) - .ty - .clone() + (*make_container_type("Witness".to_string(), element).ty).clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -127,12 +123,12 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = make_container_type( + let set_ty = (*make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty - .clone(); + .ty) + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); @@ -173,6 +169,11 @@ pub fn builtin_function_registry() -> Rc>> { "reverse".to_string(), list_of_type_variable("collection_element".to_string()), ); + let m = v1_rt::rc_map_insert( + m.clone(), + "get".to_string(), + with_optional_cardinality(type_variable_node("collection_element".to_string())), + ); let m = v1_rt::rc_map_insert( m.clone(), "list_push".to_string(), @@ -249,41 +250,6 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_loc".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_test_fns".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_names".to_string(), - list_of_type_variable("test_migration_debt_module_name_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_known_covered_module_is_not_debt".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_holds".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_uncovered_deletes".to_string(), - list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), - ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 160e9fc850f..f4200b72527 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,14 +690,39 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn build_movable_set(proof: Rc) -> Rc> { +pub fn whole_value_borrow_count(usage: Rc) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for c in usage.consumers.clone().iter().cloned() { + if match c.kind.clone() { + EdgeKind::Read => true, + EdgeKind::Threaded => true, + _ => false, + } { + __result.push(c); + } + } + __result + }) + .len() as i64) +} + +pub fn build_movable_set( + proof: Rc, + param_names: Rc>, +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) + if ((match (*make_decision(usage.clone())).clone() { + OwnershipDecision::SoleOwner { .. } => true, + _ => false, + } && (whole_value_borrow_count(usage.clone()) == 0)) + && (is_owned_local(usage.binding_kind.clone()) + || v1_rt::set_contains(¶m_names, usage.name.clone()))) { __result.push(usage); } @@ -1138,13 +1163,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { + let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { + let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1233,6 +1258,337 @@ pub fn analyze_ownership( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiveState { + pub name: String, + pub whole: bool, + pub any_field: bool, + pub fields: Rc>, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct MoveLicenseAccum { + pub live: Rc>>, + pub licensed: Rc>, +} + +pub fn move_site_key(name: String, span_start: i64) -> String { + v1_rt::concat( + v1_rt::concat(name, "@".to_string()), + (span_start).to_string(), + ) +} + +pub fn empty_live_state(name: String) -> Rc { + Rc::new(LiveState { + name: name, + whole: false, + any_field: false, + fields: v1_rt::rc_empty_set::(), + }) +} + +pub fn live_state_of(acc: Rc, name: String) -> Rc { + match v1_rt::map_get(&acc.live.clone(), name.clone()) { + Some(st) => st.clone(), + None => empty_live_state(name.clone()), + } +} + +pub fn record_whole_use_site( + acc: Rc, + name: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !st.any_field.clone()); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: true, + any_field: st.any_field.clone(), + fields: st.fields.clone(), + }), + ), + licensed: licensed, + }) + } +} + +pub fn record_field_use_site( + acc: Rc, + name: String, + field: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !v1_rt::set_contains(&st.fields.clone(), field.clone())); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: st.whole.clone(), + any_field: true, + fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), + }), + ), + licensed: licensed, + }) + } +} + +pub fn merge_live_states(a: Rc, b: Rc) -> Rc { + Rc::new(LiveState { + name: a.name.clone(), + whole: (a.whole.clone() || b.whole.clone()), + any_field: (a.any_field.clone() || b.any_field.clone()), + fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), + }) +} + +pub fn merge_branch_licenses(branches: Rc>>) -> Rc { + branches.iter().cloned().fold( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + |acc: Rc, br: Rc| { + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + { + let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) + .iter() + .cloned() + .fold( + acc.live, + |lm: Rc>>, k: String| { + let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { + Some(s) => s.clone(), + None => empty_live_state(k.clone()), + }; + match v1_rt::map_get(&lm, k.clone()) { + Some(a_st) => v1_rt::rc_map_insert( + lm.clone(), + k.clone(), + merge_live_states(a_st.clone(), b_st.clone()), + ), + None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), + } + }, + ); + let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) + .iter() + .cloned() + .fold(acc.licensed, |l: Rc>, k: String| { + v1_rt::rc_map_insert(l, k.clone(), true) + }); + Rc::new(MoveLicenseAccum { + live: live_merged.clone(), + licensed: lic_merged.clone(), + }) + } + }, + ) +} + +pub fn license_walk( + acc: Rc, + texpr: Rc, + in_capture: bool, + si: Rc>>, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + match (*texpr.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_whole_use_site( + acc.clone(), + expr_var_name_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + ExprData::ExprLiteral { value: _, .. } => acc.clone(), + ExprData::ExprFieldAccess { .. } => { + let base_node = field_access_base(texpr.clone()); + match (*base_node.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_field_use_site( + acc.clone(), + expr_var_name_at(base_node.clone(), si.clone()), + field_access_field_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + _ => license_walk( + acc.clone(), + base_node.clone(), + in_capture.clone(), + si.clone(), + ), + } + } + ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }), + ExprData::ExprMethodCall { .. } => { + let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }); + license_walk( + args_acc, + method_receiver(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprIf => { + let t_acc = license_walk( + acc.clone(), + if_then_branch(texpr.clone()), + in_capture.clone(), + si.clone(), + ); + let e_acc = match if_else_branch(texpr.clone()) { + Some(eb) => { + license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) + } + None => acc.clone(), + }; + let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); + license_walk( + merged, + if_condition(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprMatch => { + let branch_accs = Rc::new({ + let mut __result = Vec::new(); + for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { + __result.push(license_walk( + acc.clone(), + arm_body(arm_node.clone()), + in_capture.clone(), + si.clone(), + )); + } + __result + }); + let merged = merge_branch_licenses(branch_accs); + license_walk( + merged, + match_scrutinee(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprLet => { + let body_acc = match let_body(texpr.clone()) { + Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), + None => acc.clone(), + }; + license_walk( + body_acc, + let_value(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprLambda => { + license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) + } + ExprData::ExprForEach => { + let body_acc = + license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); + license_walk( + body_acc, + foreach_collection(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, field: Rc| { + license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) + }), + _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + } + }) +} + +pub fn build_move_site_licenses( + body: Rc, + si: Rc>>, +) -> Rc> { + { + let walked = license_walk( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + body, + false, + si, + ); + walked.licensed.clone() + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index f073e49662d..5e92b0e22a9 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -54,7 +54,7 @@ pub fn rt_unicode_ops() -> String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/tests/src/pipeline.rs b/src/v1/tests/src/pipeline.rs index ea9101a8cd8..5067be6a571 100644 --- a/src/v1/tests/src/pipeline.rs +++ b/src/v1/tests/src/pipeline.rs @@ -11580,7 +11580,15 @@ fn count_ownership_violations( let try_unwrap_fallbacks = count_pattern(&emitted, "unwrap_or_else(|rc| (*rc).clone())"); for proof in result.ownership.iter() { - let movable = build_movable_set(proof.clone()); + // Mirror build_ownership_results: params are the bindings seeded without a + // binding_kind by analyze_ownership. + let param_names: std::collections::BTreeSet = proof + .bindings + .values() + .filter(|u| u.binding_kind.is_none()) + .map(|u| u.name.clone()) + .collect(); + let movable = build_movable_set(proof.clone(), std::rc::Rc::new(param_names)); for name in movable.iter() { let clone_pattern = format!("{}.clone()", name); let clones_in_emitted = count_pattern(&emitted, &clone_pattern); From c8e721c2933904971c7c8217a08fb8d9781c035d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 02:51:49 +0000 Subject: [PATCH 08/27] Drop gen-1 splice probe from the branch: seed back to committed baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The probe regen (gen-1: old seed binary over the new corpus) proved (a) the get registry fix greens regen — promoted to standalone PR #6255 — and (b) the ownership proof-side emitted code compiles clean, but the regenerated emit-side seed cannot build until the pre-existing old-emitter debt lands (#6243 deref-boxing restoration: 119 mechanical sites in emit_rust.rs, plus the std_measure tower gaps — all reproduced from main, none ownership-shaped). Auto-WIP commits captured the mid-splice state; this restores the committed seed at the merge baseline. All .dag work stays; clean regen + full rustc verdict re-runs after #6255 and #6243 merge. Co-Authored-By: Claude Fable 5 --- src/v1/04_method.dag | 1 - src/v1/stage0/src/v1_compiler_emit_rust.rs | 797 ++++++++---------- src/v1/stage0/src/v1_compiler_infer.rs | 2 - .../stage0/src/v1_compiler_infer_emit_info.rs | 4 - src/v1/stage0/src/v1_compiler_infer_method.rs | 62 +- src/v1/stage0/src/v1_compiler_ownership.rs | 364 +------- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/tests/src/pipeline.rs | 10 +- 8 files changed, 386 insertions(+), 856 deletions(-) diff --git a/src/v1/04_method.dag b/src/v1/04_method.dag index cb5cd096453..fd2345a797e 100644 --- a/src/v1/04_method.dag +++ b/src/v1/04_method.dag @@ -88,7 +88,6 @@ fn builtin_function_registry() -> Map { let m = map_insert(m, "map_keys", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "map_values", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "reverse", list_of_type_variable(id: "collection_element")) - let m = map_insert(m, "get", with_optional_cardinality(n: type_variable_node(id: "collection_element"))) let m = map_insert(m, "list_push", list_of_type_variable(id: "collection_element")) let m = map_insert(m, "hash_combine", hash_type) let m = map_insert(m, "atom_identity_hash", hash_type) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index edaf8bd9ff0..b45fa7ffa52 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, - build_read_only_params, collect_callable_refs, move_site_key, + analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, + collect_callable_refs, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,6 +1401,11 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { + if let Some(host) = + rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) + { + return host; + } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2100,7 +2105,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match (*wire_item.body).clone() { + match wire_item.body.clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2146,7 +2151,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match (*wc.body).clone() { + match wc.body.clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2293,7 +2298,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2311,7 +2316,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2370,7 +2375,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match (*item.type_annotation).clone() { + match item.type_annotation.clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2423,7 +2428,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2448,7 +2453,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -2603,8 +2608,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2620,10 +2625,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - item.clone(), - ); + let item_name = + authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2659,8 +2662,8 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.type_env.clone().source_indices.clone(), + typed_module.module.clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2679,21 +2682,21 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), item.clone(), ), item.clone(), ) }, ); - module_imports((*typed_module.module).clone()) + module_imports(typed_module.module.clone()) .iter() .cloned() .fold( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2701,7 +2704,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), ) .iter() .cloned() @@ -3248,14 +3251,12 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, - pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, - pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3266,7 +3267,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), - move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3371,7 +3367,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: ownership.move_sites_index.clone(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3448,8 +3437,8 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3457,7 +3446,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3493,16 +3482,16 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )) { __result.push(p); @@ -3528,10 +3517,8 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3682,8 +3669,6 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: base_info.move_sites_index.clone(), - move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3712,12 +3697,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ); let exported = get_exported_names( - (*tm.module).clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.module.clone(), + tm.type_env.clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3742,17 +3727,17 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ @@ -3761,7 +3746,7 @@ pub fn emit_module_full( __result.extend( (*import_specific_names_at( imp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) .iter() .cloned(), @@ -3778,11 +3763,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __result.push(item); @@ -3793,7 +3778,7 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); @@ -3804,7 +3789,7 @@ pub fn emit_module_full( local_type_names, export_sets.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3813,14 +3798,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3881,7 +3866,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3896,7 +3881,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ), "::*;".to_string(), )); @@ -3917,18 +3902,18 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); + let this_module_name = authored_name(scope.type_env.clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3937,7 +3922,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3945,7 +3930,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3968,10 +3953,8 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - i.clone(), - ) == "wire_contract".to_string())) + && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) + == "wire_contract".to_string())) { __result.push(i); } @@ -3985,7 +3968,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4003,26 +3986,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4140,8 +4123,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4153,8 +4136,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4213,7 +4196,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports((*tm.module).clone()), + Some(tm) => module_imports(tm.module.clone()), None => Rc::new(vec![]), } } @@ -4228,10 +4211,7 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at( - source_indices.clone(), - (*tm.module).clone(), - )); + __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); } __result }) @@ -4404,7 +4384,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4496,7 +4476,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4606,8 +4586,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in - module_imports((*tm.module).clone()).iter().cloned() + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4658,7 +4637,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()) + for imp in module_imports(tm.module.clone()) .iter() .cloned() { @@ -4926,7 +4905,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5183,7 +5162,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5219,7 +5198,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5679,7 +5658,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5708,7 +5687,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5847,7 +5826,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - (*scope.type_env).clone(), + scope.type_env.clone(), name.clone(), ) { true @@ -5912,8 +5891,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -7229,7 +7208,7 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), authored_name(env.clone(), item.clone()), @@ -7501,11 +7480,11 @@ pub fn emit_typed_item( }; let item_is_tco = is_tco_eligible( authored_name(env.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco.clone() { + let fn_read_only = if item_is_tco { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7516,17 +7495,6 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco.clone() { - v1_rt::rc_empty_map::() - } else { - match v1_rt::map_get( - &emit_info.move_sites_index.clone(), - qualified_name.clone(), - ) { - Some(m) => m.clone(), - None => v1_rt::rc_empty_map::(), - } - }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7539,8 +7507,6 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), @@ -7561,7 +7527,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7572,7 +7538,7 @@ pub fn emit_typed_item( item_text.clone(), item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7584,8 +7550,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text.clone(), - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7627,15 +7593,6 @@ pub fn emit_typed_item( } } -pub fn needs_box_wrapping_shared_dominates() -> String { - thread_local! { - static CACHED: String = { - "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7643,31 +7600,34 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { + // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box + // — shared_types dominates the recursive check. Replaced by regen's + // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } else { - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } else { - if ((n.children.clone().len() as i64) == 0) { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } + } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; + } + if ((n.children.clone().len() as i64) == 0) { + { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } - } else { - break false; - } + break v1_rt::set_contains(&recursive_types, name.clone()); + } + } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; } + } else { + break false; } } } @@ -9601,7 +9561,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9682,7 +9642,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9691,7 +9651,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9709,7 +9669,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9939,19 +9899,19 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -10021,7 +9981,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12119,7 +12079,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { + let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -12262,28 +12222,10 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } -pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { - if (use_span.clone() == 0) { - false - } else { - match v1_rt::map_get( - &emit_info.move_sites.clone(), - move_site_key(name.clone(), use_span.clone()), - ) { - Some(v) => { - (v.clone() - && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) - } - None => false, - } - } -} - pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, - use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12296,9 +12238,7 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = - (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) - || move_licensed_at_site(emit_info.clone(), name.clone(), use_span)); + let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12407,7 +12347,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12508,18 +12448,18 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); match find_child_named( base_struct, field, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12529,23 +12469,18 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - { - let faithful_nat_field = ((emit_info.corpus_repr.clone() - == RustCorpusRepr::FaithfulFreeMonoid) - && ((field_ty_name.clone() == "Nat".to_string()) - || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); - ((faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - (*scope.type_env).clone().source_indices.clone(), - )) - || is_recursive_type_by_name( - (*scope.type_env).clone(), - field_ty_name.clone(), - )) - } + let faithful_nat_field = + matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) + && (field_ty_name.clone() == "Nat".to_string() + || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); + faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) } } None => false, @@ -12613,7 +12548,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12676,7 +12611,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -13050,7 +12985,6 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), - expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13073,7 +13007,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13082,11 +13016,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13131,10 +13065,7 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_call_expr( f, expr.children.clone(), @@ -13168,10 +13099,8 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = expr_method_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let m = + expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_method_call( expr.clone(), r, @@ -13246,10 +13175,8 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13285,14 +13212,14 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13452,7 +13379,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13471,10 +13398,8 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = foreach_variable_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let v = + foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13582,7 +13507,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13601,7 +13526,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, |expr| { @@ -13834,11 +13759,9 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); - match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { + let ty_name = + resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); + match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13847,7 +13770,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name((*scope.type_env).clone(), child.clone()); + authored_name(scope.type_env.clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13856,7 +13779,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13965,7 +13888,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13990,7 +13913,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14123,7 +14046,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14138,7 +14061,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14267,7 +14190,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14414,7 +14337,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14482,10 +14405,8 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at( - a.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) + { Some(n) => n.clone(), None => "".to_string(), }, @@ -14503,7 +14424,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __found = true; @@ -14529,7 +14450,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14554,7 +14475,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14672,7 +14593,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14729,11 +14650,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14794,7 +14715,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14987,7 +14908,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15005,7 +14926,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -15049,7 +14970,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15096,7 +15017,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15118,19 +15039,6 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); - let site = v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - lambda_expr.span.clone().file.clone(), - ":".to_string(), - ), - (lambda_expr.span.clone().start.clone()).to_string(), - ), - ":".to_string(), - ), - acc_name.clone(), - ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15138,22 +15046,16 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), - ), - acc_ident.clone(), - ), - " = v1_rt::take_owned_counted(".to_string(), + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), ), acc_ident.clone(), ), - ", \"".to_string(), + " = Rc::try_unwrap(".to_string(), ), - site, + acc_ident.clone(), ), - "\"); ".to_string(), + ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), ), body_str, ), @@ -15205,7 +15107,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15246,33 +15148,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15289,7 +15191,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if ((*arg_value(init_arg.clone()).inferred).clone() != None) { + if (arg_value(init_arg.clone()).inferred.clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15300,7 +15202,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15310,7 +15212,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) .first() .cloned() @@ -15322,7 +15224,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15336,7 +15238,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15354,8 +15256,6 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15371,7 +15271,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15389,8 +15289,6 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15408,7 +15306,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15466,7 +15364,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15478,7 +15376,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15504,7 +15402,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15553,7 +15451,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }; @@ -15625,7 +15523,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15637,7 +15535,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { "_".to_string() @@ -15712,7 +15610,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15777,7 +15675,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15875,7 +15773,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15999,7 +15897,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -16056,7 +15954,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -16074,7 +15972,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16147,7 +16045,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16351,7 +16249,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16480,13 +16378,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -17052,7 +16950,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17122,11 +17020,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17158,7 +17056,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17300,7 +17198,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17399,7 +17297,6 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), - arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17498,7 +17395,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17578,11 +17475,11 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name((*scope.type_env).clone(), struct_name) { + match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17609,10 +17506,8 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - receiver_type, - ); + let receiver_type_name = + authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17629,7 +17524,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, } @@ -17676,7 +17571,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17704,7 +17599,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - ((*binding.resolved).clone().return_cardinality.clone() + (binding.resolved.clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17747,7 +17642,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_base, ), f, @@ -17881,7 +17776,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17889,7 +17784,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17898,7 +17793,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18118,13 +18013,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18145,7 +18040,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18161,7 +18056,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18235,7 +18130,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18245,7 +18140,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18255,7 +18150,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ), @@ -18275,10 +18170,7 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18359,20 +18251,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = (*resolve_node( + let resolved_struct = resolve_node( resolved_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) - .resolved) - .clone(); + .resolved + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18629,10 +18521,7 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18699,7 +18588,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18787,7 +18676,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18918,7 +18807,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -19002,10 +18891,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19321,10 +19210,8 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19340,7 +19227,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19410,18 +19297,15 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.expr.clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = emit_typed_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19448,11 +19332,11 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19669,7 +19553,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19727,10 +19611,10 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19745,18 +19629,12 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), rt.clone(), ) } @@ -19793,10 +19671,7 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19900,17 +19775,14 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.expr.clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19925,10 +19797,7 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19998,9 +19867,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -20057,7 +19926,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - (*frame.expr).clone(), + frame.expr.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20174,7 +20043,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20325,7 +20194,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -21734,7 +21603,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match (*state.node).clone() { + let next_node = match state.node.clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21770,7 +21639,7 @@ pub fn advance_wire_path_projection( }) } } else { - match (*state.node).clone() { + match state.node.clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -23005,8 +22874,7 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) - && ((*annotation.type_annotation).clone() != None)) + ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -23038,12 +22906,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -23052,7 +22920,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -23061,11 +22929,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -23096,7 +22964,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ); @@ -23107,16 +22975,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23220,10 +23088,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23232,19 +23100,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23252,14 +23120,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23291,7 +23159,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23307,7 +23175,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23323,7 +23191,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23332,7 +23200,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -23340,7 +23208,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23360,13 +23228,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23383,14 +23251,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23413,7 +23281,8 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -23477,14 +23346,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -23905,7 +23774,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match (*data_item.body).clone() { + Some(data_item) => match data_item.body.clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23978,7 +23847,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if ((*item.body).clone() == None) { + if (item.body.clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -24012,7 +23881,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ) { __result.push(item); } @@ -24025,12 +23894,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ), registry.clone(), tm.items.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -24103,7 +23972,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )), None => "".to_string(), }; @@ -24140,10 +24009,8 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 988059445b2..0525069bf0f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -14606,8 +14606,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b19d756df6d..8dc46a13d29 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,8 +83,6 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, - pub move_sites_index: Rc>>>, - pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -106,8 +104,6 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 12c6fb18bc5..25d635b19b1 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,24 +44,28 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - (*make_map_type( + make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty) - .clone() + .ty + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() + make_container_type("List".to_string(), type_variable_node(id)) + .ty + .clone() } pub fn list_of_element(element: Rc) -> Rc { - (*make_container_type("List".to_string(), element).ty).clone() + make_container_type("List".to_string(), element).ty.clone() } pub fn witness_of_element(element: Rc) -> Rc { - (*make_container_type("Witness".to_string(), element).ty).clone() + make_container_type("Witness".to_string(), element) + .ty + .clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -123,12 +127,12 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = (*make_container_type( + let set_ty = make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty) - .clone(); + .ty + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); @@ -169,11 +173,6 @@ pub fn builtin_function_registry() -> Rc>> { "reverse".to_string(), list_of_type_variable("collection_element".to_string()), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "get".to_string(), - with_optional_cardinality(type_variable_node("collection_element".to_string())), - ); let m = v1_rt::rc_map_insert( m.clone(), "list_push".to_string(), @@ -250,6 +249,41 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_loc".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_test_fns".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_names".to_string(), + list_of_type_variable("test_migration_debt_module_name_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_known_covered_module_is_not_debt".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_holds".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_uncovered_deletes".to_string(), + list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), + ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index f4200b72527..160e9fc850f 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,39 +690,14 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn whole_value_borrow_count(usage: Rc) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for c in usage.consumers.clone().iter().cloned() { - if match c.kind.clone() { - EdgeKind::Read => true, - EdgeKind::Threaded => true, - _ => false, - } { - __result.push(c); - } - } - __result - }) - .len() as i64) -} - -pub fn build_movable_set( - proof: Rc, - param_names: Rc>, -) -> Rc> { +pub fn build_movable_set(proof: Rc) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((match (*make_decision(usage.clone())).clone() { - OwnershipDecision::SoleOwner { .. } => true, - _ => false, - } && (whole_value_borrow_count(usage.clone()) == 0)) - && (is_owned_local(usage.binding_kind.clone()) - || v1_rt::set_contains(¶m_names, usage.name.clone()))) + if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) { __result.push(usage); } @@ -1163,13 +1138,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1258,337 +1233,6 @@ pub fn analyze_ownership( } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct LiveState { - pub name: String, - pub whole: bool, - pub any_field: bool, - pub fields: Rc>, -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct MoveLicenseAccum { - pub live: Rc>>, - pub licensed: Rc>, -} - -pub fn move_site_key(name: String, span_start: i64) -> String { - v1_rt::concat( - v1_rt::concat(name, "@".to_string()), - (span_start).to_string(), - ) -} - -pub fn empty_live_state(name: String) -> Rc { - Rc::new(LiveState { - name: name, - whole: false, - any_field: false, - fields: v1_rt::rc_empty_set::(), - }) -} - -pub fn live_state_of(acc: Rc, name: String) -> Rc { - match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st.clone(), - None => empty_live_state(name.clone()), - } -} - -pub fn record_whole_use_site( - acc: Rc, - name: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !st.any_field.clone()); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: true, - any_field: st.any_field.clone(), - fields: st.fields.clone(), - }), - ), - licensed: licensed, - }) - } -} - -pub fn record_field_use_site( - acc: Rc, - name: String, - field: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !v1_rt::set_contains(&st.fields.clone(), field.clone())); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: st.whole.clone(), - any_field: true, - fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), - }), - ), - licensed: licensed, - }) - } -} - -pub fn merge_live_states(a: Rc, b: Rc) -> Rc { - Rc::new(LiveState { - name: a.name.clone(), - whole: (a.whole.clone() || b.whole.clone()), - any_field: (a.any_field.clone() || b.any_field.clone()), - fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), - }) -} - -pub fn merge_branch_licenses(branches: Rc>>) -> Rc { - branches.iter().cloned().fold( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - |acc: Rc, br: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); - { - let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) - .iter() - .cloned() - .fold( - acc.live, - |lm: Rc>>, k: String| { - let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { - Some(s) => s.clone(), - None => empty_live_state(k.clone()), - }; - match v1_rt::map_get(&lm, k.clone()) { - Some(a_st) => v1_rt::rc_map_insert( - lm.clone(), - k.clone(), - merge_live_states(a_st.clone(), b_st.clone()), - ), - None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), - } - }, - ); - let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) - .iter() - .cloned() - .fold(acc.licensed, |l: Rc>, k: String| { - v1_rt::rc_map_insert(l, k.clone(), true) - }); - Rc::new(MoveLicenseAccum { - live: live_merged.clone(), - licensed: lic_merged.clone(), - }) - } - }, - ) -} - -pub fn license_walk( - acc: Rc, - texpr: Rc, - in_capture: bool, - si: Rc>>, -) -> Rc { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*texpr.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_whole_use_site( - acc.clone(), - expr_var_name_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - ExprData::ExprLiteral { value: _, .. } => acc.clone(), - ExprData::ExprFieldAccess { .. } => { - let base_node = field_access_base(texpr.clone()); - match (*base_node.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_field_use_site( - acc.clone(), - expr_var_name_at(base_node.clone(), si.clone()), - field_access_field_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - _ => license_walk( - acc.clone(), - base_node.clone(), - in_capture.clone(), - si.clone(), - ), - } - } - ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }), - ExprData::ExprMethodCall { .. } => { - let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }); - license_walk( - args_acc, - method_receiver(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprIf => { - let t_acc = license_walk( - acc.clone(), - if_then_branch(texpr.clone()), - in_capture.clone(), - si.clone(), - ); - let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => { - license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) - } - None => acc.clone(), - }; - let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); - license_walk( - merged, - if_condition(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprMatch => { - let branch_accs = Rc::new({ - let mut __result = Vec::new(); - for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { - __result.push(license_walk( - acc.clone(), - arm_body(arm_node.clone()), - in_capture.clone(), - si.clone(), - )); - } - __result - }); - let merged = merge_branch_licenses(branch_accs); - license_walk( - merged, - match_scrutinee(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprLet => { - let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), - None => acc.clone(), - }; - license_walk( - body_acc, - let_value(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprLambda => { - license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) - } - ExprData::ExprForEach => { - let body_acc = - license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); - license_walk( - body_acc, - foreach_collection(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, field: Rc| { - license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) - }), - _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - } - }) -} - -pub fn build_move_site_licenses( - body: Rc, - si: Rc>>, -) -> Rc> { - { - let walked = license_walk( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - body, - false, - si, - ); - walked.licensed.clone() - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 5e92b0e22a9..f073e49662d 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -54,7 +54,7 @@ pub fn rt_unicode_ops() -> String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/tests/src/pipeline.rs b/src/v1/tests/src/pipeline.rs index 5067be6a571..ea9101a8cd8 100644 --- a/src/v1/tests/src/pipeline.rs +++ b/src/v1/tests/src/pipeline.rs @@ -11580,15 +11580,7 @@ fn count_ownership_violations( let try_unwrap_fallbacks = count_pattern(&emitted, "unwrap_or_else(|rc| (*rc).clone())"); for proof in result.ownership.iter() { - // Mirror build_ownership_results: params are the bindings seeded without a - // binding_kind by analyze_ownership. - let param_names: std::collections::BTreeSet = proof - .bindings - .values() - .filter(|u| u.binding_kind.is_none()) - .map(|u| u.name.clone()) - .collect(); - let movable = build_movable_set(proof.clone(), std::rc::Rc::new(param_names)); + let movable = build_movable_set(proof.clone()); for name in movable.iter() { let clone_pattern = format!("{}.clone()", name); let clones_in_emitted = count_pattern(&emitted, &clone_pattern); From d5413839a05e97e3a99dabfc95a1140825c20ecf Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 03:22:27 +0000 Subject: [PATCH 09/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/dag_collect.dag | 3 - src/v1/dag_collect_support.dag | 3 - src/v1/stage0/src/bin/regen_stage0.rs | 2 - src/v1/stage0/src/v1_compiler_compile.rs | 41 +- src/v1/stage0/src/v1_compiler_complexity.rs | 307 +- src/v1/stage0/src/v1_compiler_emit.rs | 145 +- .../src/v1_compiler_emit_core_support.rs | 41 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 36 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 40 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 797 ++-- src/v1/stage0/src/v1_compiler_infer.rs | 4224 +++++++++-------- src/v1/stage0/src/v1_compiler_infer_access.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 9 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 19 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 248 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 51 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 68 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 57 +- .../stage0/src/v1_compiler_infer_patterns.rs | 246 +- .../stage0/src/v1_compiler_infer_resolve.rs | 710 +-- .../stage0/src/v1_compiler_infer_service.rs | 8 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 19 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 160 +- src/v1/stage0/src/v1_compiler_normalize.rs | 15 +- src/v1/stage0/src/v1_compiler_ownership.rs | 364 +- src/v1/stage0/src/v1_compiler_parse.rs | 414 +- src/v1/stage0/src/v1_compiler_resolve.rs | 2 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 40 - 29 files changed, 4440 insertions(+), 3635 deletions(-) diff --git a/src/v1/dag_collect.dag b/src/v1/dag_collect.dag index a03495ec298..a910f018b07 100644 --- a/src/v1/dag_collect.dag +++ b/src/v1/dag_collect.dag @@ -122,7 +122,6 @@ fn dag_collect_insert_slots(node: Node, slots: Map, coll Present { value: _ } => slots Absent => { let fp = if anchor.span.start == 0 && anchor.span.end == 0 { - // Synthetic keys embed the fingerprint; Absent branch must not re-hash. substring(s: key, start: 6, end: string_length(s: key)) } else { dag_node_fingerprint(node: anchor) @@ -144,8 +143,6 @@ fn dag_collect_from_module(module: TypedModule, slots: Map DagCollectAcc { let _memo_reset = dag_collect_fp_memo_reset() - // Dissolve-on: drop collision_errors threading once synthetic-key construction proof - // is a typed wall (key embeds fp ⇒ key-equal ⇒ fp-equal); kept for emit_dag gate shape. let collision_errors = [] let slots = typed.modules |> fold(init: empty_map(), f: (s, m) => dag_collect_from_module(module: m, slots: s, collision_errors: collision_errors)) diff --git a/src/v1/dag_collect_support.dag b/src/v1/dag_collect_support.dag index a590dabca84..b24a83d9fd9 100644 --- a/src/v1/dag_collect_support.dag +++ b/src/v1/dag_collect_support.dag @@ -118,9 +118,6 @@ fn dag_node_surface_fingerprint(node: Node) -> String { dag_node_surface_fingerprint_rec(node: node) } -// Dissolve-on: ground on std.content_hash + node-keyed memo table once v2 adoption -// clears for this stage. Realization threads a per-collect memo reset at -// collect_dag_nodes entry; Rust seed uses Rc::as_ptr until then. fn dag_collect_fp_memo_reset() -> Bool { true } diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 7ede06053a0..60ab5a5e5c8 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -73,8 +73,6 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "v1_compiler_compile.rs", "v1_compiler_compiler_tests_rust.rs", "v1_compiler_complexity.rs", - "v1_compiler_dag_collect.rs", - "v1_compiler_dag_collect_support.rs", "v1_compiler_effect_derivation.rs", "v1_compiler_emit.rs", "v1_compiler_emit_core_support.rs", diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 1c1e8ecd469..28965259701 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -135,7 +135,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> if { let mut __found = false; for item in m.items.clone().iter().cloned() { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { __found = true; break; } @@ -156,7 +156,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> for item in Rc::new({ let mut __result = Vec::new(); for item in m.items.clone().iter().cloned() { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { __result.push(item); } } @@ -167,10 +167,10 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - m.type_env.clone().source_indices.clone(), + (*m.type_env).clone().source_indices.clone(), item.clone(), ), - body: item.body.clone().clone().unwrap(), + body: (*item.body).clone().clone().unwrap(), params: item.params.clone(), span: item.span.clone(), is_tail_recursive: (item.is_self_recursive.clone() @@ -200,7 +200,7 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc) -> Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) }, ) } @@ -1807,7 +1810,7 @@ pub fn serialize_param( pub fn is_import_statement_node(n: Rc) -> bool { (import_is_all(n.clone()) - || (((((n.children.clone().len() as i64) > 0) && (n.body.clone() == None)) + || (((((n.children.clone().len() as i64) > 0) && ((*n.body).clone() == None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && ((n.params.clone().len() as i64) == 0))) } @@ -1877,7 +1880,7 @@ pub fn serialize_node_record( Connective::Disj => json_quote(connective_name(Connective::Disj)), Connective::NoConnective => "null".to_string(), Connective::Arrow => json_quote(connective_name(Connective::Arrow)), -}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref(node.inferred.clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref(node.body.clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref(node.transport.clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref(node.type_annotation.clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) +}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref((*node.inferred).clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref((*node.body).clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref((*node.transport).clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref((*node.type_annotation).clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) } pub fn serialize_typed_module( @@ -1891,7 +1894,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref(module.module.clone(), key_to_id.clone()), + serialize_node_ref((*module.module).clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2273,7 +2276,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let mut __result = Vec::new(); for p in parse_results.clone().iter().cloned() { __result.extend( - (*match p.module.clone() { + (*match (*p.module).clone() { Some(m) => Rc::new(vec![m.clone()]), None => Rc::new(vec![]), }) @@ -2428,7 +2431,7 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - m.module.clone(), + (*m.module).clone(), )); } __result diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 368276eb3bc..182e9e48cc2 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -1372,7 +1372,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1393,7 +1393,7 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), empty_parser_progress_env(), proven.clone(), @@ -1671,7 +1671,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -2207,7 +2207,11 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), + recursive_measure_param_names( + (*entry.body).clone(), + entry.params.clone(), + si.clone(), + ), ), None => acc.clone(), }, @@ -5753,7 +5757,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), local_func_set.clone(), si.clone(), )) @@ -6474,7 +6478,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - entry.body.clone(), + (*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6482,7 +6486,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - entry.body.clone(), + (*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6575,8 +6579,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6650,15 +6654,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6732,8 +6736,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6781,7 +6785,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6836,7 +6840,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6875,7 +6879,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - entry.body.clone(), + (*entry.body).clone(), name.clone(), si.clone(), ); @@ -7212,12 +7216,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7546,7 +7550,7 @@ pub fn resolve_callback_cost( fn_ref.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7555,7 +7559,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7566,7 +7570,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7579,7 +7583,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -7612,7 +7616,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - body_result.summary.clone().work.clone(), + (*body_result.summary.clone().work).clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7631,12 +7635,12 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: body_result.table.clone(), + table: (*body_result.table).clone(), }) } CostShape::ShapeSortBody => { @@ -7646,7 +7650,7 @@ pub fn cost_of_method_by_shape( la.clone(), func_index, scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7658,14 +7662,14 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { base: 2, argument: size.clone(), }); - let per_comparison = key_result.summary.clone().work.clone(); + let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, @@ -7680,12 +7684,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: key_result.table.clone(), + table: (*key_result.table).clone(), }) } CostShape::ShapeLinearScan => { @@ -7708,28 +7712,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -8553,7 +8557,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - lr.table.clone(), + (*lr.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8561,23 +8565,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - lr.summary.clone().work.clone(), + (*lr.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().work.clone(), + (*rr.summary.clone().work).clone(), ), ), span: cost_seq( - lr.summary.clone().span.clone(), + (*lr.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().span.clone(), + (*rr.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: rr.table.clone(), + table: (*rr.table).clone(), }) } ExprData::ExprCall { .. } => { @@ -8610,14 +8614,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: callee_result.table.clone(), + table: (*callee_result.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8625,34 +8629,34 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - args_result.summary.clone().work.clone(), - callee_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), + (*callee_result.summary.clone().work).clone(), ), span: cost_seq( - args_result.summary.clone().span.clone(), - callee_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), + (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } ExprData::ExprMethodCall { @@ -8699,17 +8703,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), })), } } @@ -8727,14 +8731,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8742,40 +8746,40 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), ), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } } @@ -8801,7 +8805,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: s_r.table.clone(), + table: (*s_r.table).clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8810,7 +8814,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - acc.result.clone().table.clone(), + (*(*acc.result).clone().table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8819,21 +8823,21 @@ pub fn cost_of_expr( result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*(*acc.result).clone().summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*(*acc.result).clone().summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: ar.table.clone(), + table: (*ar.table).clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![ar.summary.clone().work.clone()]), + Rc::new(vec![(*ar.summary.clone().work).clone()]), ), }) }, @@ -8841,23 +8845,29 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - s_r.summary.clone().work.clone(), + (*s_r.summary.clone().work).clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - s_r.summary.clone().span.clone(), - Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), + (*s_r.summary.clone().span).clone(), + Rc::new(vec![ + (*(*arms_accum.result).clone().summary.clone().span).clone() + ]), ), - output_size: arms_accum - .result + output_size: (*arms_accum.result) .clone() .summary .clone() .output_size .clone(), - certainty: arms_accum.result.clone().summary.clone().certainty.clone(), + certainty: (*arms_accum.result) + .clone() + .summary + .clone() + .certainty + .clone(), }), - table: arms_accum.result.clone().table.clone(), + table: (*(*arms_accum.result).clone().table).clone(), }) } ExprData::ExprIf => { @@ -8876,7 +8886,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8887,14 +8897,14 @@ pub fn cost_of_expr( eb.clone(), func_index.clone(), scc_index.clone(), - t_r.table.clone(), + (*t_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: er.table.clone(), + table: (*er.table).clone(), }) } None => Rc::new(SummaryResult { @@ -8904,29 +8914,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: t_r.table.clone(), + table: (*t_r.table).clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - c_r.summary.clone().work.clone(), + (*c_r.summary.clone().work).clone(), Rc::new(vec![ - t_r.summary.clone().work.clone(), - e_result.summary.clone().work.clone(), + (*t_r.summary.clone().work).clone(), + (*e_result.summary.clone().work).clone(), ]), ), span: cost_conditional( - c_r.summary.clone().span.clone(), + (*c_r.summary.clone().span).clone(), Rc::new(vec![ - t_r.summary.clone().span.clone(), - e_result.summary.clone().span.clone(), + (*t_r.summary.clone().span).clone(), + (*e_result.summary.clone().span).clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: e_result.table.clone(), + table: (*e_result.table).clone(), }) } ExprData::ExprLet => { @@ -8946,7 +8956,7 @@ pub fn cost_of_expr( b.clone(), func_index.clone(), scc_index.clone(), - v_r.table.clone(), + (*v_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8954,17 +8964,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - v_r.summary.clone().work.clone(), - b_r.summary.clone().work.clone(), + (*v_r.summary.clone().work).clone(), + (*b_r.summary.clone().work).clone(), ), span: cost_seq( - v_r.summary.clone().span.clone(), - b_r.summary.clone().span.clone(), + (*v_r.summary.clone().span).clone(), + (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: b_r.table.clone(), + table: (*b_r.table).clone(), }) } None => v_r.clone(), @@ -8985,7 +8995,7 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8993,17 +9003,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - sr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*sr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - sr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: sr.table.clone(), + table: (*sr.table).clone(), }) }, ), @@ -9023,22 +9033,23 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = + cost_loop(binder, size.clone(), (*bd_r.summary.clone().work).clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*c_r.summary.clone().span).clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: bd_r.table.clone(), + table: (*bd_r.table).clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9056,7 +9067,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9064,17 +9075,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9093,7 +9104,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9101,17 +9112,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9169,7 +9180,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - entry.body.clone(), + (*entry.body).clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9188,12 +9199,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), scc_members.clone(), ), span: bounded_scc_cost( t.clone(), - result.summary.clone().span.clone(), + (*result.summary.clone().span).clone(), scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9203,12 +9214,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), func_name.clone(), ), span: bounded_recursive_cost( t.clone(), - result.summary.clone().span.clone(), + (*result.summary.clone().span).clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9219,13 +9230,16 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost(bounded.work.clone()), - span: simplify_cost(bounded.span.clone()), + work: simplify_cost((*bounded.work).clone()), + span: simplify_cost((*bounded.span).clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = - cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); + let final_table = cache_summary( + (*result.table).clone(), + func_name.clone(), + simplified.clone(), + ); Rc::new(SummaryResult { summary: simplified.clone(), table: final_table, @@ -9591,7 +9605,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9620,7 +9634,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - entry.body.clone(), + (*entry.body).clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9720,12 +9734,13 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) + if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) + > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9798,12 +9813,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity(sr.summary.clone().work.clone()); + let class_str = classify_complexity((*sr.summary.clone().work).clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9811,12 +9826,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { + let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason(sr.summary.clone().work.clone()), + reason: extract_unknown_reason((*sr.summary.clone().work).clone()), span: entry.span.clone(), })]), ) @@ -9845,7 +9860,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - sr.table.clone(), + (*sr.table).clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index e7c5382b4eb..f8d7b8d487a 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -594,13 +594,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: typed_module.type_env.clone(), - func_env: typed_module.func_env.clone(), + type_env: (*typed_module.type_env).clone(), + func_env: (*typed_module.func_env).clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -620,7 +620,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc, name: String, ) -> Option> { - lookup_func_sig(scope.func_env.clone(), name) + lookup_func_sig((*scope.func_env).clone(), name) } pub fn typed_named_arg_matches( @@ -672,7 +672,10 @@ pub fn order_typed_call_args( let has_unnamed = { let mut __found = false; for arg in args.clone().iter().cloned() { - if (arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()) == None) + if (arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) == None) { __found = true; break; @@ -691,7 +694,7 @@ pub fn order_typed_call_args( |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -707,7 +710,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), true, ) @@ -721,7 +724,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -739,7 +742,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -1246,7 +1249,7 @@ pub fn named_type_vars_in_inferred(inferred: Option>) -> Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_vars = named_type_vars_in_inferred(n.inferred.clone()); + let self_vars = named_type_vars_in_inferred((*n.inferred).clone()); let child_vars = Rc::new({ let mut __result = Vec::new(); for ch in n.children.clone().iter().cloned() { @@ -1323,13 +1326,13 @@ pub fn render_node_type( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); - let n_is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let n_is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; @@ -1337,7 +1340,7 @@ pub fn render_node_type( && ((n.children.clone().len() as i64) == 0)) { { - let is_named_type_var = match n.inferred.clone().as_deref().cloned() { + let is_named_type_var = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) } @@ -1376,7 +1379,7 @@ pub fn render_node_type( __result }); let param_str = param_strs.clone().join(&repr.param_separator.clone()); - let ret_str = match n.inferred.clone().as_deref().cloned() { + let ret_str = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_node_type( rt.clone(), target.clone(), @@ -1460,7 +1463,7 @@ pub fn render_node_type( } if is_conj { { - if (n.type_annotation.clone() != None) { + if ((*n.type_annotation).clone() != None) { { let refined_str = match n.children.clone().first().cloned() { Some(base) => render_node_type( @@ -1481,7 +1484,7 @@ pub fn render_node_type( { let first_child = match n.children.clone().first().cloned() { Some(c) => { - if (c.inferred.clone() != None) { + if ((*c.inferred).clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1501,7 +1504,7 @@ pub fn render_node_type( }; let second_child = match n.children.clone().get(1 as usize).cloned() { Some(c) => { - if (c.inferred.clone() != None) { + if ((*c.inferred).clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1810,15 +1813,15 @@ pub fn has_service_items(typed: Rc) -> bool { } pub fn service_fallback_transport(item: Rc) -> Rc { - if (item.transport.clone() == None) { + if ((*item.transport).clone() == None) { local_transport_node(item.span.clone()) } else { - item.transport.clone().clone().unwrap() + (*item.transport).clone().clone().unwrap() } } pub fn effective_operation_transport(op_node: Rc, fallback: Rc) -> Rc { - match op_node.transport.clone() { + match (*op_node.transport).clone() { Some(op_transport) => op_transport.clone(), None => fallback, } @@ -1834,9 +1837,9 @@ pub fn service_has_rest( let from_ops = { let mut __found = false; for op in op_children.iter().cloned() { - if if (op.transport.clone() != None) { + if if ((*op.transport).clone() != None) { is_rest_transport( - op.transport.clone().clone().unwrap(), + (*op.transport).clone().clone().unwrap(), source_indices.clone(), ) } else { @@ -1858,8 +1861,8 @@ pub fn service_has_shell(fallback_transport: Rc, op_children: Rc) -> String + Clone, ) -> String { loop { - let si = frame.scope.clone().type_env.clone().source_indices.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + let si = (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(); + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { + if (expr_call_func_at((*frame.expr).clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: frame.expr.clone().children.clone(), + args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2555,7 +2561,7 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value(frame.expr.clone()); + let inner = return_value((*frame.expr).clone()); { let __tco_0 = Rc::new(TcoFrame { expr: inner, @@ -2621,7 +2627,11 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); + let val_str = recurse_expr( + (*frame.expr).clone(), + frame.scope.clone(), + frame.depth.clone(), + ); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2635,15 +2645,18 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = recurse_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2670,11 +2683,11 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2795,14 +2808,17 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( @@ -2832,9 +2848,9 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { @@ -2936,7 +2952,10 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - input.scope.clone().type_env.clone().source_indices.clone(), + (*input.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) }, |frame| { @@ -3111,7 +3130,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3211,10 +3230,10 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), @@ -3442,7 +3461,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -4099,7 +4118,7 @@ pub fn emit_typed_cast_shared( { let expr_str = recurse(expr.clone()); let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); - let src_ty = match expr.inferred.clone().as_deref().cloned() { + let src_ty = match (*expr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { emit_node_type(n.clone(), target.clone(), source_indices.clone()) } @@ -5245,7 +5264,7 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = scope.type_env.clone().source_indices.clone(); + let source_indices = (*scope.type_env).clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -5733,7 +5752,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5753,7 +5772,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = scope.type_env.clone().source_indices.clone(); + let fa_si = (*scope.type_env).clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index e384a9d4951..d61dd191831 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -585,7 +585,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_type_def_item(item: Rc) -> bool { - ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) + ((item.connective.clone() != Connective::NoConnective) && ((*item.transport).clone() == None)) } pub fn is_bare_leaf_item(item: Rc) -> bool { - (((((item.connective.clone() == Connective::NoConnective) && (item.body.clone() == None)) + (((((item.connective.clone() == Connective::NoConnective) && ((*item.body).clone() == None)) && ((item.params.clone().len() as i64) == 0)) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) } @@ -683,26 +686,26 @@ pub fn is_type_decl_item( ) -> bool { ((is_bare_leaf_item(item.clone()) && !is_type_alias_return_node(resolved_type(item.clone()), source_indices)) - || (((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + || (((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0))) } pub fn is_function_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() == None)) + (((*item.body).clone() != None) && ((*item.type_annotation).clone() == None)) } pub fn is_data_def_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() != None)) + (((*item.body).clone() != None) && ((*item.type_annotation).clone() != None)) } pub fn is_service_def_item(item: Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_resource_def_item(item: Rc) -> bool { - (((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) - || ((((item.transport.clone() == None) && ((item.children.clone().len() as i64) == 0)) + ((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) + || (((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) > 0)) - && (item.body.clone() == None))) + && ((*item.body).clone() == None))) } diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 80ca723d392..177e2376db6 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -129,16 +129,16 @@ pub fn emit_go(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -462,9 +462,9 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = typed_module.type_env.clone().source_indices.clone(); + let si = (*typed_module.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( @@ -695,7 +695,7 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_go_type_def_from_connective(item.clone(), env.clone()) @@ -717,7 +717,7 @@ pub fn emit_go_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -726,7 +726,7 @@ pub fn emit_go_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -735,8 +735,8 @@ pub fn emit_go_typed_item( if is_data_def_item(item.clone()) { emit_go_data_def( item_text, - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), 0, @@ -1141,7 +1141,7 @@ pub fn emit_go_fn_def( scope: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1255,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1388,7 +1388,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1800,7 +1800,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index ddb3cc3f4a9..1f2d2d804a1 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,16 +117,16 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -187,8 +187,8 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -364,9 +364,9 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); @@ -582,7 +582,7 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_py_type_def_from_connective(item.clone(), env.clone()) @@ -607,7 +607,7 @@ pub fn emit_py_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -616,7 +616,7 @@ pub fn emit_py_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -625,8 +625,8 @@ pub fn emit_py_typed_item( if is_data_def_item(item.clone()) { emit_py_data_def( item_text, - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b45fa7ffa52..edaf8bd9ff0 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, - collect_callable_refs, + analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, + build_read_only_params, collect_callable_refs, move_site_key, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,11 +1401,6 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { - if let Some(host) = - rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) - { - return host; - } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2105,7 +2100,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match wire_item.body.clone() { + match (*wire_item.body).clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2151,7 +2146,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match wc.body.clone() { + match (*wc.body).clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2298,7 +2293,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2316,7 +2311,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2375,7 +2370,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match item.type_annotation.clone() { + match (*item.type_annotation).clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2428,7 +2423,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2453,7 +2448,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -2608,8 +2603,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2625,8 +2620,10 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = - authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at( + (*tm.type_env).clone().source_indices.clone(), + item.clone(), + ); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2662,8 +2659,8 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2682,21 +2679,21 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), item.clone(), ), item.clone(), ) }, ); - module_imports(typed_module.module.clone()) + module_imports((*typed_module.module).clone()) .iter() .cloned() .fold( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2704,7 +2701,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), ) .iter() .cloned() @@ -3251,12 +3248,14 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, + pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, + pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3267,7 +3266,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), + move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3367,7 +3371,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: ownership.move_sites_index.clone(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3437,8 +3448,8 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3446,7 +3457,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3482,16 +3493,16 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -3517,8 +3528,10 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3669,6 +3682,8 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: base_info.move_sites_index.clone(), + move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3697,12 +3712,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); let exported = get_exported_names( - tm.module.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.module).clone(), + (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3727,17 +3742,17 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ @@ -3746,7 +3761,7 @@ pub fn emit_module_full( __result.extend( (*import_specific_names_at( imp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) .iter() .cloned(), @@ -3763,11 +3778,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __result.push(item); @@ -3778,7 +3793,7 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); @@ -3789,7 +3804,7 @@ pub fn emit_module_full( local_type_names, export_sets.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3798,14 +3813,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3866,7 +3881,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3881,7 +3896,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ), "::*;".to_string(), )); @@ -3902,18 +3917,18 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name(scope.type_env.clone(), m.clone()); + let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3922,7 +3937,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3930,7 +3945,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3953,8 +3968,10 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) - == "wire_contract".to_string())) + && (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + i.clone(), + ) == "wire_contract".to_string())) { __result.push(i); } @@ -3968,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3986,26 +4003,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) + let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4123,8 +4140,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4136,8 +4153,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4196,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports(tm.module.clone()), + Some(tm) => module_imports((*tm.module).clone()), None => Rc::new(vec![]), } } @@ -4211,7 +4228,10 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); + __result.push(authored_name_at( + source_indices.clone(), + (*tm.module).clone(), + )); } __result }) @@ -4384,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4476,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4586,7 +4606,8 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() + for imp in + module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4637,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) + for imp in module_imports((*tm.module).clone()) .iter() .cloned() { @@ -4905,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5162,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5198,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5658,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5687,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5826,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - scope.type_env.clone(), + (*scope.type_env).clone(), name.clone(), ) { true @@ -5891,8 +5912,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -7208,7 +7229,7 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), authored_name(env.clone(), item.clone()), @@ -7480,11 +7501,11 @@ pub fn emit_typed_item( }; let item_is_tco = is_tco_eligible( authored_name(env.clone(), item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco { + let fn_read_only = if item_is_tco.clone() { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7495,6 +7516,17 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; + let fn_move_sites = if item_is_tco.clone() { + v1_rt::rc_empty_map::() + } else { + match v1_rt::map_get( + &emit_info.move_sites_index.clone(), + qualified_name.clone(), + ) { + Some(m) => m.clone(), + None => v1_rt::rc_empty_map::(), + } + }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7507,6 +7539,8 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), @@ -7527,7 +7561,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7538,7 +7572,7 @@ pub fn emit_typed_item( item_text.clone(), item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7550,8 +7584,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text.clone(), - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7593,6 +7627,15 @@ pub fn emit_typed_item( } } +pub fn needs_box_wrapping_shared_dominates() -> String { + thread_local! { + static CACHED: String = { + "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7600,34 +7643,31 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { - // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box - // — shared_types dominates the recursive check. Replaced by regen's - // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } - if ((n.children.clone().len() as i64) == 0) { - { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } - } } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; } else { - break false; + if ((n.children.clone().len() as i64) == 0) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; + } else { + break v1_rt::set_contains(&recursive_types, name.clone()); + } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } + } } } } @@ -9561,7 +9601,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9642,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9651,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9669,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9899,19 +9939,19 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_func_inferred( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -9981,7 +10021,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12079,7 +12119,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { + let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -12222,10 +12262,28 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } +pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { + if (use_span.clone() == 0) { + false + } else { + match v1_rt::map_get( + &emit_info.move_sites.clone(), + move_site_key(name.clone(), use_span.clone()), + ) { + Some(v) => { + (v.clone() + && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + } + None => false, + } + } +} + pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, + use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12238,7 +12296,9 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); + let moves_by_value = + (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) + || move_licensed_at_site(emit_info.clone(), name.clone(), use_span)); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12347,7 +12407,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12448,18 +12508,18 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); match find_child_named( base_struct, field, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12469,18 +12529,23 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - let faithful_nat_field = - matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) - && (field_ty_name.clone() == "Nat".to_string() - || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); - faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) + { + let faithful_nat_field = ((emit_info.corpus_repr.clone() + == RustCorpusRepr::FaithfulFreeMonoid) + && ((field_ty_name.clone() == "Nat".to_string()) + || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); + ((faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + (*scope.type_env).clone().source_indices.clone(), + )) + || is_recursive_type_by_name( + (*scope.type_env).clone(), + field_ty_name.clone(), + )) + } } } None => false, @@ -12548,7 +12613,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12611,7 +12676,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -12985,6 +13050,7 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), + expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13007,7 +13073,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13016,11 +13082,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13065,7 +13131,10 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let f = expr_call_func_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_call_expr( f, expr.children.clone(), @@ -13099,8 +13168,10 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = - expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let m = expr_method_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_method_call( expr.clone(), r, @@ -13175,8 +13246,10 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13212,14 +13285,14 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13379,7 +13452,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13398,8 +13471,10 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = - foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let v = foreach_variable_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13507,7 +13582,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13526,7 +13601,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, |expr| { @@ -13759,9 +13834,11 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = - resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); - match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { + let ty_name = resolved_type_name( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); + match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13770,7 +13847,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name(scope.type_env.clone(), child.clone()); + authored_name((*scope.type_env).clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13779,7 +13856,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13888,7 +13965,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13913,7 +13990,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14046,7 +14123,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14061,7 +14138,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14190,7 +14267,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14337,7 +14414,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14405,8 +14482,10 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) - { + match arg_name_at( + a.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { Some(n) => n.clone(), None => "".to_string(), }, @@ -14424,7 +14503,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __found = true; @@ -14450,7 +14529,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14475,7 +14554,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14593,7 +14672,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14650,11 +14729,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14715,7 +14794,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14908,7 +14987,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14926,7 +15005,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -14970,7 +15049,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15017,7 +15096,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15039,6 +15118,19 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); + let site = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + lambda_expr.span.clone().file.clone(), + ":".to_string(), + ), + (lambda_expr.span.clone().start.clone()).to_string(), + ), + ":".to_string(), + ), + acc_name.clone(), + ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15046,16 +15138,22 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), + ), + acc_ident.clone(), + ), + " = v1_rt::take_owned_counted(".to_string(), ), acc_ident.clone(), ), - " = Rc::try_unwrap(".to_string(), + ", \"".to_string(), ), - acc_ident.clone(), + site, ), - ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), + "\"); ".to_string(), ), body_str, ), @@ -15107,7 +15205,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15148,33 +15246,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15191,7 +15289,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if (arg_value(init_arg.clone()).inferred.clone() != None) { + if ((*arg_value(init_arg.clone()).inferred).clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15202,7 +15300,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15212,7 +15310,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) .first() .cloned() @@ -15224,7 +15322,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15238,7 +15336,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15256,6 +15354,8 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15271,7 +15371,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15289,6 +15389,8 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15306,7 +15408,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15364,7 +15466,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15376,7 +15478,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15402,7 +15504,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15451,7 +15553,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }; @@ -15523,7 +15625,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15535,7 +15637,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { "_".to_string() @@ -15610,7 +15712,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15675,7 +15777,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15773,7 +15875,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15897,7 +15999,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -15954,7 +16056,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15972,7 +16074,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16045,7 +16147,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16249,7 +16351,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16378,13 +16480,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -16950,7 +17052,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17020,11 +17122,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17056,7 +17158,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17198,7 +17300,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17297,6 +17399,7 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), + arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17395,7 +17498,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17475,11 +17578,11 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name(scope.type_env.clone(), struct_name) { + match lookup_type_by_name((*scope.type_env).clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17506,8 +17609,10 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); + let receiver_type_name = authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + receiver_type, + ); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17524,7 +17629,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, } @@ -17571,7 +17676,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17599,7 +17704,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - (binding.resolved.clone().return_cardinality.clone() + ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17642,7 +17747,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_base, ), f, @@ -17776,7 +17881,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17784,7 +17889,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17793,7 +17898,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18013,13 +18118,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18040,7 +18145,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18056,7 +18161,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18130,7 +18235,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18140,7 +18245,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18150,7 +18255,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ), @@ -18170,7 +18275,10 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18251,20 +18359,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = resolve_node( + let resolved_struct = (*resolve_node( resolved_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) - .resolved - .clone(); + .resolved) + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18521,7 +18629,10 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18588,7 +18699,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18676,7 +18787,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18807,7 +18918,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -18891,10 +19002,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19210,8 +19321,10 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + stmt.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19227,7 +19340,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19297,15 +19410,18 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = emit_typed_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19332,11 +19448,11 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19553,7 +19669,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19611,10 +19727,10 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19629,12 +19745,18 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), rt.clone(), ) } @@ -19671,7 +19793,10 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19775,14 +19900,17 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19797,7 +19925,10 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) == n.clone()) { __found = true; @@ -19867,9 +19998,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -19926,7 +20057,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - frame.expr.clone(), + (*frame.expr).clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20043,7 +20174,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20194,7 +20325,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -21603,7 +21734,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match state.node.clone() { + let next_node = match (*state.node).clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21639,7 +21770,7 @@ pub fn advance_wire_path_projection( }) } } else { - match state.node.clone() { + match (*state.node).clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -22874,7 +23005,8 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) + && ((*annotation.type_annotation).clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -22906,12 +23038,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -22920,7 +23052,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -22929,11 +23061,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -22964,7 +23096,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ); @@ -22975,16 +23107,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23088,10 +23220,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23100,19 +23232,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23120,14 +23252,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23159,7 +23291,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23175,7 +23307,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23191,7 +23323,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23200,7 +23332,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -23208,7 +23340,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23228,13 +23360,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23251,14 +23383,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23281,8 +23413,7 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -23346,14 +23477,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -23774,7 +23905,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match data_item.body.clone() { + Some(data_item) => match (*data_item.body).clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23847,7 +23978,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if (item.body.clone() == None) { + if ((*item.body).clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -23881,7 +24012,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), ) { __result.push(item); } @@ -23894,12 +24025,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), registry.clone(), tm.items.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -23972,7 +24103,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )), None => "".to_string(), }; @@ -24009,8 +24140,10 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 0525069bf0f..19cc103d962 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,20 +45,18 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, - inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, - lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - put_inductive_field, put_inductive_field_cross, record_build_type_env_call, - record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, + build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, + is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, + lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, + rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{ - inferred_to_outputs, item_kind, variant_locals_from_items, -}; +pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -109,13 +107,11 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; -// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. -use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, + FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, + VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -146,18 +142,19 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, - index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, - is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, - is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, - let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, - make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, - make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, - make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, - method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, - node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, - resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, - string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, + is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, + is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, + lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, + make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, + make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, + make_param_node, make_span, make_text_part_node, make_transport_node, map_children, + match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, + param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, + return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, + with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -251,7 +248,7 @@ pub fn infer_block_stmts( let is_last = (remaining_count.clone() == 1); let stmt_expected = if is_last { expected.clone() } else { None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = stmt_result.typed.clone(); + let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = @@ -384,7 +381,7 @@ pub fn merge_scope_from_imports( svc_locals: svc_locals, }), |acc: Rc, titem: Rc| { - if ((titem.transport.clone() != None) + if (((*titem.transport).clone() != None) && ((titem.children.clone().len() as i64) > 0)) { { @@ -397,7 +394,7 @@ pub fn merge_scope_from_imports( c.clone(), ), outputs: inferred_to_outputs( - c.inferred.clone(), + (*c.inferred).clone(), c.span.clone(), env.source_indices.clone(), ), @@ -428,11 +425,11 @@ pub fn merge_scope_from_imports( }) } } else { - if (((((titem.body.clone() != None) + if ((((((*titem.body).clone() != None) && ((titem.params.clone().len() as i64) == 0)) - && (titem.transport.clone() == None)) + && ((*titem.transport).clone() == None)) && (titem.connective.clone() == Connective::NoConnective)) - && (titem.inferred.clone() != None)) + && ((*titem.inferred).clone() != None)) { Rc::new(InferScopeComponents { svc_registry: acc.svc_registry.clone(), @@ -517,7 +514,7 @@ pub fn classify_field_recursion( source_indices: Rc>>, ) -> Option> { { - let type_expr = match field_node.inferred.clone().as_deref().cloned() { + let type_expr = match (*field_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(field_node.clone()), }; @@ -773,53 +770,66 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) { - Some(authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), - )) + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent.clone(), + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), + )) + } else { + None + } } else { None } - } else { - None } + None => None, } - None => None, - }, + } None => None, } } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup -// via the binding edge — replaced by regen's true emission of variant_owner_node -// in the convergence commit. +pub fn variant_owner_node_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(owner) => { - if owner.connective.clone() == Connective::Disj - && has_child_named( - owner.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) - { - Some(owner) - } else { - None + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(owner) => { + let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); + if owner_is_coproduct { + if has_child_named( + owner.clone(), + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(owner.clone()) + } else { + None + } + } else { + None + } } + None => None, } - None => None, - }, + } None => None, } } @@ -842,45 +852,6 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, - name: String, - scope_enum: String, - expected: Option>, -) -> Option { - match expected { - Some(exp_node) => { - let exp_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), - exp_node.clone(), - ); - if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) - && (exp_name.clone() != name.clone())) - { - match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { - Some(exp_type) => { - if ((exp_type.connective.clone() == Connective::Disj) - && has_child_named( - exp_type.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - )) - { - Some(exp_name.clone()) - } else { - None - } - } - None => None, - } - } else { - None - } - } - None => None, - } -} - pub fn inference_error( message: String, span: Rc, @@ -911,7 +882,15 @@ pub fn type_mismatch_error( ) } -// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) +pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -919,32 +898,30 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { - if (expected.return_cardinality.clone() != Cardinality::CardOptional) { - return false; - } let expected_resolved = - match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { + match lookup_type_for(env, with_required_cardinality(expected.clone())) { Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = - (expected_resolved.connective.clone() == Connective::Disj); - let got_shape = node_type_shape(got.clone(), source_indices.clone()); - let got_is_string = (got_shape == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); + let expected_is_optional_coproduct = ((expected.return_cardinality.clone() + == Cardinality::CardOptional) + && (expected_resolved.connective.clone() == Connective::Disj)); + let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) + == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - if (ft.return_cardinality.clone() != Cardinality::CardOptional) { - return false; + { + let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { + Some(resolved) => resolved.clone(), + None => with_required_cardinality(ft.clone()), + }; + ((ft.return_cardinality.clone() == Cardinality::CardOptional) + && (inner.connective.clone() == Connective::Disj)) } - let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -952,17 +929,14 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { Some(direct) => direct.children.clone(), - // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), - // no name round-trip, no whole-env scan fallback. Regen replaces - // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -984,37 +958,6 @@ pub fn record_lit_expected_fields( } } -pub fn record_lit_variant_fields_from_visible_env( - env: Rc, - variant_name: String, - module_name: String, -) -> Rc>> { - let source_indices = env.source_indices.clone(); - let visible = flatten_visible_bindings(env.clone()); - for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { - let node = expand_type_for_field_access( - binding.resolved.clone(), - env.clone(), - module_name.clone(), - ); - if (node.connective.clone() == Connective::Disj) { - for arm in node.children.clone().iter().cloned() { - let arm_name = authored_name_at(source_indices.clone(), arm.clone()); - if (arm_name == variant_name.clone()) { - let expanded = - expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); - if (expanded.connective.clone() == Connective::Conj) { - return expanded.children.clone(); - } else { - return arm.children.clone(); - } - } - } - } - } - Rc::new(vec![]) -} - pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -1024,7 +967,7 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) @@ -1032,10 +975,10 @@ pub fn record_lit_expanded_from_expected( { Some(exp.clone()) } else { - match exp.inferred.clone().as_deref().cloned() { + match (*exp.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), expanded.clone(), ) == tn.clone()) { @@ -1047,7 +990,7 @@ pub fn record_lit_expanded_from_expected( _ => { let rt = resolved_type(exp.clone()); if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), rt.clone(), ) == tn.clone()) { @@ -1092,15 +1035,17 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - != tn.clone()) + if (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + exp.clone(), + ) != tn.clone()) { None } else { if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for(scope.type_env.clone(), exp.clone()) { + match lookup_type_for((*scope.type_env).clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1109,7 +1054,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1134,8 +1079,7 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -1146,15 +1090,15 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { .return_cardinality .clone(), uses: sf.uses.clone(), - body: sf.body.clone(), - transport: sf.transport.clone(), + body: (*sf.body).clone(), + transport: (*sf.transport).clone(), properties: sf.properties.clone(), - type_annotation: sf.type_annotation.clone(), + type_annotation: (*sf.type_annotation).clone(), is_self_recursive: sf.is_self_recursive.clone(), has_non_tail_self_call: sf .has_non_tail_self_call .clone(), - match_pattern: sf.match_pattern.clone(), + match_pattern: (*sf.match_pattern).clone(), expr_data: sf.expr_data.clone(), ident: None, })); @@ -1185,7 +1129,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1195,20 +1139,24 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { + match (*arg_value(receiver_arg).inferred) + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( receiver_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => false, } @@ -1218,12 +1166,12 @@ pub fn set_union_other_operand_is_resolved_non_set( other_arg: Rc, scope: Rc, ) -> bool { - match arg_value(other_arg).inferred.clone().as_deref().cloned() { + match (*arg_value(other_arg).inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. }) => !node_is_set_collection( other_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => false, } @@ -1233,14 +1181,14 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, scope.type_env.clone()) { + match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, } } pub fn set_element_type_is_concrete(elem: Rc) -> bool { - match elem.inferred.clone() { + match (*elem.inferred).clone() { Some(inf) => !is_type_variable(inf.clone()), None => true, } @@ -1435,8 +1383,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1444,18 +1391,19 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => { - match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) - } + }) => match map_value_type_in_env( + receiver_type.clone(), + (*scope.type_env).clone(), + ) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type.clone()) + } else { + with_optional_cardinality(value_type.clone()) } - None => resolve_builtin_call_type(func_name.clone()), } - } + None => resolve_builtin_call_type(func_name.clone()), + }, _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1465,8 +1413,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1475,11 +1422,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { + match map_key_type_in_env(receiver_type.clone(), (*scope.type_env).clone()) + { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { - bt: lk.ty.clone(), + bt: (*lk.ty).clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1502,8 +1450,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1513,12 +1460,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( .. }) => match map_value_type_in_env( receiver_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(Tier2bBt { - bt: lv.ty.clone(), + bt: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1547,8 +1494,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()) - .inferred + Some(insert_arg) => match (*arg_value(insert_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1562,8 +1508,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()) - .inferred + Some(other_arg) => match (*arg_value(other_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1572,7 +1517,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: other_type, .. }) => match set_element_type_in_env( other_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, @@ -1600,8 +1545,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1622,7 +1566,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(oe) => set_element_types_mismatch( re.clone(), oe.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }, @@ -1673,8 +1617,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()) - .inferred + match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1685,11 +1628,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => match recv_elem.clone() { Some(_) => receiver_type.clone(), None => match operand_elem.clone() { - Some(element) => { - set_kernel_ty_from_element(element.clone()) - .ty - .clone() - } + Some(element) => (*set_kernel_ty_from_element( + element.clone(), + ) + .ty) + .clone(), None => { resolve_builtin_call_type(func_name.clone()) } @@ -1757,11 +1700,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(MethodPipeFallback { - result_ty: lk.ty.clone(), + result_ty: (*lk.ty).clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1772,11 +1715,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(MethodPipeFallback { - result_ty: lv.ty.clone(), + result_ty: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1910,7 +1853,7 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - scope.type_env.clone(), + (*scope.type_env).clone(), scrutinee_type.clone(), )), PatternSubject::PatternDynamic { @@ -1941,7 +1884,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1985,7 +1928,7 @@ pub fn annotate_pattern_parent_enums( resolved_scrut.clone(), variant_name.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); @@ -1997,16 +1940,16 @@ pub fn annotate_pattern_parent_enums( variant_subject.clone(), field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -2045,11 +1988,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), + param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2058,8 +2001,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2077,8 +2020,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2103,8 +2046,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2143,8 +2086,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2172,7 +2115,7 @@ pub fn scope_after_stmt_node( scope.clone(), let_binding_name_at( stmt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2198,7 +2141,7 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(n.clone()), ), _ => "".to_string(), @@ -2208,7 +2151,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); + inductive_fields_for((*scope.type_env).clone(), scrut_type_name.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2268,7 +2211,7 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); @@ -2281,13 +2224,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2377,7 +2320,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(a); } @@ -2398,9 +2341,9 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - init_result.typed.clone(), + (*init_result.typed).clone(), ia.span.clone(), ia.span.clone(), ), @@ -2427,7 +2370,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2435,9 +2378,9 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2498,10 +2441,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2564,8 +2507,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2582,9 +2525,9 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -2606,8 +2549,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2673,8 +2616,11 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), - ar.typed.clone(), + arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + (*ar.typed).clone(), arg.span.clone(), arg.span.clone(), ), @@ -2711,16 +2657,15 @@ pub fn infer_expr( ExprData::ExprVar { binding_kind: _, .. } => { - let name = - expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let name = expr_var_name_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { - // HAND-PATCH (§1c): the expected-type-as-owner-picker - // is deleted; the binding edge alone names the owner. - // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( name.clone(), Rc::new(ExprData::ExprVar { @@ -2732,7 +2677,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), span.clone(), @@ -2747,7 +2692,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), span.clone(), @@ -2755,7 +2700,7 @@ pub fn infer_expr( } } } - None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { + None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( @@ -2766,7 +2711,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: fsig.inferred.clone(), + node: (*fsig.inferred).clone(), })), span.clone(), span.clone(), @@ -2783,7 +2728,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - fsig.inferred.clone(), + (*fsig.inferred).clone(), ), })), span.clone(), @@ -2821,44 +2766,34 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let base_rt = resolved_type(base_typed.clone()); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { + if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) }; - let resolved_base_is_error = if resolved_base.inferred.clone() != None { - is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) + let resolved_base_is_error = if ((*resolved_base.inferred).clone() != None) { + is_compiler_error((*resolved_base.inferred).clone().clone().unwrap()) } else { false }; if resolved_base_is_error { - // HAND-PATCH (debug instrumentation, removed with regen): - // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - format!( - "error type cascade (field '{}' on error-typed base '{}' in {})", - field_name, - authored_name_at( - scope.type_env.clone().source_indices.clone(), - base_typed.clone() - ), - scope.module_name - ), + "error type cascade".to_string(), span.clone(), ), diagnostics: base_diags, @@ -2868,19 +2803,19 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { let field_summary = match field_summary_for_type( base_rt.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), field_name.clone(), ) { Some(s) => Some(s.clone()), None => field_summary_for_type( resolved_base.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), field_name.clone(), ), }; @@ -2904,7 +2839,7 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); if base_is_type_var { { @@ -2933,7 +2868,7 @@ pub fn infer_expr( base_rt.clone(), field_name.clone(), scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( @@ -2967,8 +2902,7 @@ pub fn infer_expr( "' on type '".to_string(), ), authored_name_at( - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3002,11 +2936,13 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = - expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let func_name = expr_call_func_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); + let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -3038,7 +2974,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -3050,13 +2986,13 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type(first_result.typed.clone()); + let first_type = resolved_type((*first_result.typed).clone()); let elem_type = for_each_element_type_node( first_type, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - first_result.typed.clone(), + (*first_result.typed).clone(), elem_type.clone(), scope.clone(), ); @@ -3074,9 +3010,9 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - first_result.typed.clone(), + (*first_result.typed).clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3095,7 +3031,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3109,7 +3045,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3121,7 +3057,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -3157,7 +3093,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3178,11 +3114,11 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), - ar.typed.clone(), + (*ar.typed).clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3190,9 +3126,9 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type(ar.typed.clone()), + resolved_type((*ar.typed).clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.subst.clone(), ) } @@ -3204,9 +3140,12 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -3225,7 +3164,7 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); @@ -3241,9 +3180,9 @@ pub fn infer_expr( { let resolved_type = match sig.clone() { Some(s) => substitute_generics( - s.inferred.clone(), + (*s.inferred).clone(), call_subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => error_type(), }; @@ -3252,7 +3191,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3267,7 +3206,7 @@ pub fn infer_expr( value_params_for_check, typed_args.clone(), call_subst.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) }; @@ -3303,7 +3242,7 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) @@ -3330,7 +3269,7 @@ pub fn infer_expr( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3339,9 +3278,9 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let is_known_method = (method_resolution.result_type.clone() != None); + let is_known_method = ((*method_resolution.result_type).clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { { let receiver = method_receiver.clone(); @@ -3353,17 +3292,19 @@ pub fn infer_expr( .skip(1 as usize) .collect::>(), ); - let base_result_type = match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) { + let base_result_type = + match (*method_resolution.result_type).clone() { + Some(mt) => mt.clone(), + None => error_type(), + }; + let method_tv = if ((*method_resolution.semantics).clone() == None) + { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { - match (*method_resolution.semantics.clone().clone().unwrap()) + match (*(*method_resolution.semantics).clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3374,8 +3315,7 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3408,8 +3348,7 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3433,14 +3372,15 @@ pub fn infer_expr( }), } }; - let bridge_result_type = method_tv.ty.clone(); + let bridge_result_type = (*method_tv.ty).clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics.clone() + let returns_receiver_self = if ((*method_resolution.semantics) + .clone() == None) { false } else { - match (*method_resolution.semantics.clone().clone().unwrap()) + match (*(*method_resolution.semantics).clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3456,11 +3396,11 @@ pub fn infer_expr( let final_receiver = if ((returns_receiver_self && is_fully_resolved( bridge_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( first_arg_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3474,15 +3414,15 @@ pub fn infer_expr( })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), - body: receiver.body.clone(), - transport: receiver.transport.clone(), + body: (*receiver.body).clone(), + transport: (*receiver.transport).clone(), properties: receiver.properties.clone(), - type_annotation: receiver.type_annotation.clone(), + type_annotation: (*receiver.type_annotation).clone(), is_self_recursive: receiver.is_self_recursive.clone(), has_non_tail_self_call: receiver .has_non_tail_self_call .clone(), - match_pattern: receiver.match_pattern.clone(), + match_pattern: (*receiver.match_pattern).clone(), expr_data: receiver.expr_data.clone(), ident: None, }) @@ -3495,7 +3435,7 @@ pub fn infer_expr( __result.push(make_arg_node( arg_name_at( ta.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), arg_value(ta.clone()), span.clone(), @@ -3508,7 +3448,8 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics.clone(), + method_semantics: (*method_resolution.semantics) + .clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), @@ -3534,7 +3475,7 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3598,7 +3539,7 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3666,7 +3607,7 @@ match bare_s { scope.clone(), span.clone(), ); - let bt = tier2b.bt.clone(); + let bt = (*tier2b.bt).clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3700,8 +3641,7 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if ((binding - .resolved + if (((*binding.resolved) .clone() .params .clone() @@ -3709,7 +3649,7 @@ match bare_s { as i64) > 0) { - Some(binding.resolved.clone()) + Some((*binding.resolved).clone()) } else { None } @@ -3746,7 +3686,7 @@ match bare_s { Some(ctor_result) => ctor_result.clone(), None => { let type_match = lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), func_name.clone(), ); let resolved_type = match type_match.clone() @@ -3795,21 +3735,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = recv_result.typed.clone(); + let recv_typed = (*recv_result.typed).clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( resolved_type(recv_typed.clone()), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3820,7 +3760,7 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( @@ -3840,7 +3780,7 @@ match bare_s { let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); @@ -3853,7 +3793,7 @@ match bare_s { }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { @@ -3885,9 +3825,9 @@ match bare_s { None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let pipe_fb = match method_resolution.result_type.clone() { + let pipe_fb = match (*method_resolution.result_type).clone() { Some(rt) => Rc::new(MethodPipeFallback { result_ty: rt.clone(), kernel_diags: Rc::new(vec![]), @@ -3899,14 +3839,14 @@ match bare_s { span.clone(), ), }; - let base_result_type = pipe_fb.result_ty.clone(); - let method_tv_mc = if (method_resolution.semantics.clone() == None) { + let base_result_type = (*pipe_fb.result_ty).clone(); + let method_tv_mc = if ((*method_resolution.semantics).clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { - match (*method_resolution.semantics.clone().clone().unwrap()).clone() { + match (*(*method_resolution.semantics).clone().clone().unwrap()).clone() { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. @@ -3915,7 +3855,7 @@ match bare_s { if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { { @@ -3939,7 +3879,7 @@ match bare_s { mc_arg_types, recv_rt.clone(), mc_fold_overrides, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } } else { @@ -3960,10 +3900,10 @@ match bare_s { }), } }; - let result_type = method_tv_mc.ty.clone(); + let result_type = (*method_tv_mc.ty).clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); - let method_semantics = if (method_resolution.semantics.clone() != None) { - method_resolution.semantics.clone() + let method_semantics = if ((*method_resolution.semantics).clone() != None) { + (*method_resolution.semantics).clone() } else { Some(Rc::new(MethodSemantics::PlainMethodSemantics)) }; @@ -3994,10 +3934,10 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = scrut_result.typed.clone(); + let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(scrut_typed.clone()); - let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); + let scrut_subject = pattern_subject_from_inferred((*scrut_typed.inferred).clone()); let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ let mut __result = Vec::new(); @@ -4026,7 +3966,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4044,7 +3984,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4064,7 +4004,7 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.body_type.clone()); + __result.push((*ar.body_type).clone()); } __result }); @@ -4083,14 +4023,14 @@ match bare_s { prefer_specific_type( acc, t.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); @@ -4147,8 +4087,8 @@ match bare_s { }), }; if !is_fully_resolved( - original.body_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*original.body_type).clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4181,7 +4121,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4199,7 +4139,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4229,7 +4169,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.typed_arm.clone()); + __result.push((*ar.typed_arm).clone()); } __result }); @@ -4262,7 +4202,7 @@ match bare_s { } => check_match_exhaustiveness( resolved_scrutinee.clone(), typed_arms.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), span.clone(), scope.module_name.clone(), ), @@ -4289,23 +4229,23 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = cond_result.typed.clone(); + let cond_typed = (*cond_result.typed).clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type(then_result.typed.clone()); - let else_rt = resolved_type(else_result.typed.clone()); + let then_rt = resolved_type((*then_result.typed).clone()); + let else_rt = resolved_type((*else_result.typed).clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { @@ -4313,30 +4253,30 @@ match bare_s { }; let else_result = if (!is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = else_result.typed.clone(); + let else_typed = (*else_result.typed).clone(); let else_diags = else_result.diagnostics.clone(); let then_rt = resolved_type(then_typed.clone()); let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4348,14 +4288,14 @@ match bare_s { .to_string(), node_type_shape( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ), span.clone(), @@ -4393,7 +4333,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4404,7 +4344,7 @@ match bare_s { binding_kind: _, .. } => { (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), bd.clone(), ) == let_name.clone()) } @@ -4418,7 +4358,7 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { @@ -4446,13 +4386,13 @@ match bare_s { ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), Rc::new(vec![val_typed.clone(), body_typed.clone()]), - body_typed.inferred.clone(), + (*body_typed.inferred).clone(), span.clone(), node_name_span(texpr.clone()), ); @@ -4469,7 +4409,7 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), field_inits, span.clone(), @@ -4485,7 +4425,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4507,7 +4447,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push(r.typed.clone()); + __result.push((*r.typed).clone()); } __result }); @@ -4520,7 +4460,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type(r.typed.clone()), + Some(r) => resolved_type((*r.typed).clone()), None => unit_type(), } } else { @@ -4528,7 +4468,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => child_type_node(elem.clone()), @@ -4546,7 +4486,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4576,7 +4516,7 @@ match bare_s { Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: list_k.ty.clone(), + node: (*list_k.ty).clone(), })), span.clone(), ); @@ -4593,15 +4533,15 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = left_result.typed.clone(); + let left_typed = (*left_result.typed).clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = right_result.typed.clone(); + let right_typed = (*right_result.typed).clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), resolved_type(left_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -4610,7 +4550,7 @@ match bare_s { }), Rc::new(vec![left_typed.clone(), right_typed]), Some(Rc::new(InferredNode::Resolved { - node: binop_info.result_type.clone(), + node: (*binop_info.result_type).clone(), })), span.clone(), ); @@ -4623,7 +4563,7 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = operand_result.typed.clone(); + let operand_typed = (*operand_result.typed).clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), @@ -4645,7 +4585,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4775,8 +4715,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: lam_scope.type_env.clone(), - func_env: lam_scope.func_env.clone(), + type_env: (*lam_scope.type_env).clone(), + func_env: (*lam_scope.func_env).clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4785,7 +4725,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4811,7 +4751,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), None => None, }; @@ -4826,13 +4766,13 @@ match bare_s { inferred: param_type.clone(), return_cardinality: pn.return_cardinality.clone(), uses: pn.uses.clone(), - body: pn.body.clone(), - transport: pn.transport.clone(), + body: (*pn.body).clone(), + transport: (*pn.transport).clone(), properties: pn.properties.clone(), - type_annotation: pn.type_annotation.clone(), + type_annotation: (*pn.type_annotation).clone(), is_self_recursive: pn.is_self_recursive.clone(), has_non_tail_self_call: pn.has_non_tail_self_call.clone(), - match_pattern: pn.match_pattern.clone(), + match_pattern: (*pn.match_pattern).clone(), expr_data: pn.expr_data.clone(), }) }); @@ -4842,7 +4782,7 @@ match bare_s { let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), - body_typed.inferred.clone(), + (*body_typed.inferred).clone(), span.clone(), ); Rc::new(InferResult { @@ -4860,7 +4800,10 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node(r.typed.clone(), part_node.span.clone()) + make_interp_part_node( + (*r.typed).clone(), + part_node.span.clone(), + ) } None => part_node.clone(), }, @@ -4919,7 +4862,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: state.last_type.clone(), + node: (*state.last_type).clone(), })), span.clone(), ); @@ -4948,12 +4891,12 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = inner_result.typed.clone(); + let inner_typed = (*inner_result.typed).clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( - inner_typed.inferred.clone(), + (*inner_typed.inferred).clone(), target_name, span.clone(), si.clone(), @@ -4979,17 +4922,17 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = coll_result.typed.clone(); + let coll_typed = (*coll_result.typed).clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( resolved_type(coll_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( coll_typed.clone(), @@ -5003,13 +4946,13 @@ match bare_s { elem_provenance, ); let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( variable.clone(), Rc::new(ExprData::ExprForEach), Rc::new(vec![coll_typed.clone(), body_typed.clone()]), - body_typed.inferred.clone(), + (*body_typed.inferred).clone(), span.clone(), node_name_span(texpr.clone()), ); @@ -5023,15 +4966,15 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = index_result.typed.clone(); + let index_typed = (*index_result.typed).clone(); let index_diags = index_result.diagnostics.clone(); - let index_check = match base_typed.inferred.clone().as_deref().cloned() { + let index_check = match (*base_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match index_typed.inferred.clone().as_deref().cloned() { + }) => match (*index_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: index_type, .. }) => Some(check_index_access_node( @@ -5039,19 +4982,21 @@ match bare_s { index_type.clone(), span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = + match (*base_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + (*index_typed.inferred).clone() + } + _ => (*base_typed.inferred).clone(), + }; let idx_inferred = match index_check.clone() { - Some(checked) => checked.inferred.clone(), + Some(checked) => (*checked.inferred).clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid index access".to_string(), @@ -5082,21 +5027,21 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = start_result.typed.clone(); + let start_typed = (*start_result.typed).clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = end_result.typed.clone(); + let end_typed = (*end_result.typed).clone(); let end_diags = end_result.diagnostics.clone(); - let slice_check = match base_typed.inferred.clone().as_deref().cloned() { + let slice_check = match (*base_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match start_typed.inferred.clone().as_deref().cloned() { + }) => match (*start_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: start_type, .. - }) => match end_typed.inferred.clone().as_deref().cloned() { + }) => match (*end_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: end_type, .. }) => { Some(check_slice_access_node( base_type.clone(), @@ -5104,7 +5049,7 @@ match bare_s { end_type.clone(), span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) } _ => None, @@ -5113,20 +5058,20 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() + let access_failure_inferred = + match (*base_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + match (*start_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + (*end_typed.inferred).clone() + } + _ => (*start_typed.inferred).clone(), } - _ => start_typed.inferred.clone(), } - } - _ => base_typed.inferred.clone(), - }; + _ => (*base_typed.inferred).clone(), + }; let slc_inferred = match slice_check.clone() { - Some(checked) => checked.inferred.clone(), + Some(checked) => (*checked.inferred).clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid slice access".to_string(), @@ -5161,8 +5106,8 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![inner_result.typed.clone()]), - inner_result.typed.clone().inferred.clone(), + Rc::new(vec![(*inner_result.typed).clone()]), + (*(*inner_result.typed).clone().inferred).clone(), span.clone(), ); Rc::new(InferResult { @@ -5199,8 +5144,8 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { Some(variant_node) => { @@ -5281,12 +5226,13 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { + if (((*n.inferred).clone() != None) && is_type_variable((*n.inferred).clone().clone().unwrap())) + { true } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (n.inferred.clone() == None)) + && ((*n.inferred).clone() == None)) { { let name = authored_name_at(env.source_indices.clone(), n.clone()); @@ -5312,7 +5258,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() == None)) + && ((*n.inferred).clone() == None)) { is_user_generic_use_site(n.clone(), env.clone()) } else { @@ -5326,7 +5272,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((binding.connective.clone() == Connective::NoConnective) && ((binding.children.clone().len() as i64) == 0)) - && (binding.inferred.clone() != None)) + && ((*binding.inferred).clone() != None)) { true } else { @@ -5334,7 +5280,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { && ((binding.children.clone().len() as i64) > 0)) { (is_user_generic_use_site(binding.clone(), env.clone()) - || (binding.inferred.clone() != None)) + || ((*binding.inferred).clone() != None)) } else { false } @@ -5354,9 +5300,7 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = resolve_node(n, env.clone(), module_name.clone()) - .resolved - .clone(); + let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { @@ -5364,7 +5308,7 @@ pub fn peel_alias_once_for_field_access( } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) - && (once.inferred.clone() == None)) + && ((*once.inferred).clone() == None)) { { let __tco_0 = once.clone(); @@ -5382,7 +5326,7 @@ pub fn structural_from_expanded_type(normed: Rc) -> Rc { match normed.connective.clone() { Connective::Conj => normed.clone(), Connective::Disj => normed.clone(), - _ => match normed.inferred.clone().as_deref().cloned() { + _ => match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => match target.connective.clone() { Connective::Conj => target.clone(), Connective::Disj => target.clone(), @@ -5403,7 +5347,7 @@ pub fn record_field_type_is_unresolved_param( if ((ft.connective.clone() == Connective::NoConnective) && ((ft.children.clone().len() as i64) == 0)) { - match ft.inferred.clone() { + match (*ft.inferred).clone() { Some(inf) => is_type_variable(inf.clone()), None => { let fname = authored_name_at(env.source_indices.clone(), ft.clone()); @@ -5517,11 +5461,11 @@ pub fn alias_chain_target_after_args( target.clone(), type_args.clone(), ); - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = ((((*decl.inferred).clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { - match decl.inferred.clone().as_deref().cloned() { + match (*decl.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: alias_body, .. }) => substitute_generics( @@ -5645,17 +5589,13 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) +pub fn expand_type_for_field_access_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn expand_type_for_field_access_with_seen( @@ -5667,29 +5607,44 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) + { + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) + } } } +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) +} + pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) - && (decl.inferred.clone() != None)) + && ((*decl.inferred).clone() != None)) { - match decl.inferred.clone().as_deref().cloned() { + match (*decl.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), _ => decl.clone(), } @@ -5698,7 +5653,7 @@ pub fn record_lit_alias_struct_fields( }; let expanded = expand_type_for_field_access( to_expand, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5718,8 +5673,8 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), type_name) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5743,73 +5698,50 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); - { - let mut __found = false; - for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( - scope.type_env.clone(), - ))) - .iter() - .cloned() - { - if { - let node = binding.resolved.clone(); - if (node.connective.clone() == Connective::Disj) { + let si = (*scope.type_env).clone().source_indices.clone(); + match variant_owner_node(scope.clone(), type_name.clone()) { + Some(owner) => { + let mut __found = false; + for arm in owner.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { { - let mut __found = false; - for arm in node.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) - == type_name.clone()) - { - { - let ea = expand_type_for_field_access( - arm.clone(), - scope.type_env.clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) - { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) - == field.clone()) - { - __found = true; - break; - } - } - __found - } + let ea = expand_type_for_field_access( + arm.clone(), + (*scope.type_env).clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) == field.clone()) { + __found = true; + break; } - } else { - false - } { - __found = true; - break; } + __found } - __found } } else { false + } { + __found = true; + break; } - } { - __found = true; - break; } + __found } - __found + None => false, } } } pub fn type_has_sole_constructor(type_name: String, scope: Rc) -> bool { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5833,38 +5765,28 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { - // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is - // deleted; the ladder is instantiate -> expected -> declaration/ - // binding-edge only. Regen replaces this with the dag source's true - // emission. let struct_fields = match type_name.clone() { - Some(tn) => { - match record_lit_instantiated_fields( + Some(tn) => match record_lit_instantiated_fields( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields.clone(), + None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => { - match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => { - record_lit_expected_fields(type_name.clone(), scope.clone()) - } - } - } + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields.clone(), + None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, - } - } + }, + }, None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), @@ -5895,7 +5817,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5931,7 +5853,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5944,15 +5866,15 @@ pub fn infer_record_lit( .cloned() { Some(sf) => { - let ft = match sf.inferred.clone().as_deref().cloned() { + let ft = match (*sf.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if ((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone()) + if (((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone())) || field_type_is_optional_coproduct( ft.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), )) { Some(ft.clone()) @@ -5967,7 +5889,7 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = ar.typed.clone(); + let ar_typed = (*ar.typed).clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { @@ -5975,28 +5897,30 @@ pub fn infer_record_lit( if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - scope.type_env.clone().source_indices.clone(), - scope.type_env.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*scope.type_env).clone(), ) { - let expected_for_shape = match lookup_type_for( - scope.type_env.clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape, - scope.type_env.clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - scope.type_env.clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) + { + let expected_for_shape = match lookup_type_for( + (*scope.type_env).clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) + } } else { Rc::new(vec![]) } @@ -6023,7 +5947,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push(fir.typed_field.clone()); + __result.push((*fir.typed_field).clone()); } __result }); @@ -6041,15 +5965,15 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ), - span: fir.typed_field.clone().span.clone(), - ident_span: fir.typed_field.clone().ident_span.clone(), + span: (*fir.typed_field).clone().span.clone(), + ident_span: (*fir.typed_field).clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: fir.infer_result.clone().typed.clone().inferred.clone(), + inferred: (*(*fir.infer_result.clone().typed).clone().inferred).clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6100,7 +6024,7 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); + lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { @@ -6110,7 +6034,7 @@ pub fn infer_record_lit( lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for(scope.type_env.clone(), local_node.clone()) + lookup_type_for((*scope.type_env).clone(), local_node.clone()) } None => None, } @@ -6130,8 +6054,8 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6143,7 +6067,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - val_fir.infer_result.clone().typed.clone(), + (*val_fir.infer_result.clone().typed).clone(), )), None => raw_resolved, } @@ -6151,9 +6075,6 @@ pub fn infer_record_lit( } else { raw_resolved }; - // HAND-PATCH (§1c): unbound constructor literal is the typed - // UnresolvedType diagnostic, not a generic InternalError message. - // Regen replaces this with the dag source's true emission. let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( @@ -6167,7 +6088,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6252,7 +6173,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6262,7 +6183,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { Some(_) => Some(Rc::new(SizeExpr::ParamSize { @@ -6290,7 +6211,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() @@ -6339,7 +6260,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6404,7 +6325,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6415,7 +6336,7 @@ pub fn classify_collection_shrink( } => { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (rname == param_name.clone()) { { @@ -6460,7 +6381,10 @@ Rc::new(SubValueRelation::StrictSubValue { } => { let aname = expr_var_name_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env) + .clone() + .source_indices + .clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6668,12 +6592,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6693,7 +6617,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6728,12 +6652,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6753,7 +6677,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6797,7 +6721,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6805,7 +6729,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6832,7 +6756,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ) .iter() @@ -6871,7 +6795,7 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); + expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { @@ -6907,8 +6831,10 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = - expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_mname = expr_method_name_at( + expr.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) @@ -6937,8 +6863,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = - expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let vname = expr_var_name_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6946,23 +6874,25 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = - field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let field = field_access_field_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -6998,7 +6928,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + let vname = + expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -7010,13 +6941,15 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), @@ -7028,8 +6961,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), None => match v1_rt::map_get( &ctx.param_names.clone(), @@ -7042,7 +6975,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) @@ -7104,7 +7037,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let iname = expr_var_name_at( inner.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -7132,7 +7065,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - let type_based = match val.inferred.clone().as_deref().cloned() { + let type_based = match (*val.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if is_container_type(authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), c.clone(), ), None => "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) + && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) { { let fields = - inductive_fields_for(ctx.type_env.clone(), elem.clone()); + inductive_fields_for((*ctx.type_env).clone(), elem.clone()); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7244,7 +7177,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7291,7 +7224,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7315,7 +7248,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7376,7 +7309,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7434,7 +7367,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env + (*ctx.type_env) .clone() .source_indices .clone(), @@ -7504,7 +7437,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7551,7 +7484,7 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) @@ -7594,7 +7527,7 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) @@ -7609,7 +7542,7 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7617,7 +7550,7 @@ pub fn classify_argument( } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -7638,7 +7571,7 @@ pub fn classify_argument( } } }; - let fields = inductive_fields_for(ctx.type_env.clone(), type_name); + let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7676,22 +7609,24 @@ pub fn classify_argument( SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - let from_provenance = - match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, - } + let from_provenance = match lookup_func_sig( + (*ctx.func_env).clone(), + callee.clone(), + ) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map.clone(), + ctx.clone(), + ), + None => None, } - None => None, - }; + } + None => None, + }; match from_provenance { Some(prov_rel) => prov_rel.clone(), None => { @@ -7707,7 +7642,7 @@ pub fn classify_argument( None => "".to_string(), }; let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), type_name, ); let cf = Rc::new({ @@ -7785,13 +7720,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7829,13 +7764,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7847,13 +7782,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7950,7 +7885,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7966,14 +7901,16 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7981,10 +7918,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -8055,7 +7992,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8074,7 +8011,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8143,7 +8080,7 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { Some(t) => t.clone(), @@ -8181,7 +8118,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8216,11 +8153,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8268,13 +8205,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8288,7 +8225,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8299,7 +8236,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8317,16 +8254,16 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: Rc::new(ExprData::ExprCall { call_semantics: cs.clone(), descent_evidence: Some(evidence), @@ -8342,7 +8279,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), @@ -8369,7 +8306,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8377,7 +8314,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -8387,7 +8324,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ); Rc::new({ @@ -8415,7 +8352,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((mname.clone() == "first".to_string()) || (mname.clone() == "last".to_string())) @@ -8431,7 +8368,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() + && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8439,9 +8376,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - match lookup_func_sig(ctx.func_env.clone(), callee) { + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8477,20 +8414,20 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8502,14 +8439,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: ic.type_env.clone(), + type_env: (*ic.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: ic.func_env.clone(), + func_env: (*ic.func_env).clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8525,9 +8462,9 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8539,14 +8476,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8562,11 +8499,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8575,14 +8512,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8607,24 +8544,26 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: v1_rt::concat(Rc::new(vec![annotated_scrut]), annotated_arms), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = - let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let binding_name = let_binding_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { @@ -8660,7 +8599,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8676,7 +8615,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }) } @@ -8684,7 +8623,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( @@ -8696,7 +8635,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }), }; @@ -8715,16 +8654,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8742,7 +8681,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8777,7 +8716,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8793,7 +8732,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8801,7 +8740,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8815,7 +8754,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8838,16 +8777,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: threaded.children.clone(), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8856,8 +8795,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = - expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let mname = expr_method_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { @@ -8869,7 +8810,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) @@ -8884,7 +8825,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let base = field_access_base(receiver.clone()); let fname = field_access_field_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8892,7 +8833,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -8921,7 +8862,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ) .iter() @@ -8947,7 +8888,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { @@ -8990,7 +8931,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); lparams .clone() @@ -9010,7 +8951,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), @@ -9030,14 +8971,14 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -9045,7 +8986,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -9066,7 +9007,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9079,7 +9020,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9103,16 +9044,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9126,8 +9067,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = - foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let fe_var = foreach_variable_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9138,7 +9081,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), fe_var.clone(), @@ -9148,18 +9091,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; @@ -9172,16 +9115,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: Rc::new(vec![annotated_coll, annotated_body.clone()]), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9197,7 +9140,7 @@ pub fn resolved_type_name( n: Rc, source_indices: Rc>>, ) -> String { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, rt.clone()) } @@ -9816,7 +9759,7 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = unwrapped.expr.clone(); + let terminal = (*unwrapped.expr).clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( terminal, @@ -9862,11 +9805,15 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { + match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in - arm_unwrapped.expr.clone().children.clone().iter().cloned() + for fi in (*arm_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9893,10 +9840,16 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { + let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { + for fi in (*then_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9914,24 +9867,30 @@ pub fn classify_terminal_per_field( Some(else_expr) => { let else_unwrapped = unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() - { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + let else_result = + match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in (*else_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -10099,13 +10058,13 @@ pub fn arm_ctx_from_variant_provenance( } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); + call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10123,8 +10082,8 @@ pub fn arm_ctx_from_variant_provenance( call_args.clone(), c.param_order.clone(), c.param_names.clone(), - c.type_env.clone(), - c.func_env.clone(), + (*c.type_env).clone(), + (*c.func_env).clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10152,7 +10111,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10160,7 +10119,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10382,7 +10341,7 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - sig.inferred.clone(), + (*sig.inferred).clone(), ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -10715,7 +10674,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10737,7 +10696,7 @@ pub fn populate_output_provenance( None => acc.clone(), } } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { if !expr_has_self_call( body.clone(), @@ -10756,34 +10715,36 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = - match item.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: rt, - .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, - >, + let variant_prov = match (*item.inferred) + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { + node: rt, .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, >, >, >, - >( - ), - }; + >, + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10798,7 +10759,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10912,19 +10873,19 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: p.inferred.clone(), + inferred: (*p.inferred).clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: p.body.clone(), - transport: p.transport.clone(), + body: (*p.body).clone(), + transport: (*p.transport).clone(), properties: p.properties.clone(), - type_annotation: p.type_annotation.clone(), + type_annotation: (*p.type_annotation).clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: p.match_pattern.clone(), + match_pattern: (*p.match_pattern).clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -10964,7 +10925,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -10975,19 +10936,19 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: p.inferred.clone(), + inferred: (*p.inferred).clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: p.body.clone(), - transport: p.transport.clone(), + body: (*p.body).clone(), + transport: (*p.transport).clone(), properties: p.properties.clone(), - type_annotation: p.type_annotation.clone(), + type_annotation: (*p.type_annotation).clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: p.match_pattern.clone(), + match_pattern: (*p.match_pattern).clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -11039,16 +11000,16 @@ pub fn infer_transport_node( children: t.children.clone(), connective: t.connective.clone(), params: t.params.clone(), - inferred: t.inferred.clone(), + inferred: (*t.inferred).clone(), return_cardinality: t.return_cardinality.clone(), uses: t.uses.clone(), - body: t.body.clone(), - transport: t.transport.clone(), + body: (*t.body).clone(), + transport: (*t.transport).clone(), properties: prop_result.props.clone(), - type_annotation: t.type_annotation.clone(), + type_annotation: (*t.type_annotation).clone(), is_self_recursive: t.is_self_recursive.clone(), has_non_tail_self_call: t.has_non_tail_self_call.clone(), - match_pattern: t.match_pattern.clone(), + match_pattern: (*t.match_pattern).clone(), expr_data: t.expr_data.clone(), ident: None, })), @@ -11060,20 +11021,20 @@ pub fn infer_transport_node( pub fn infer_item(item: Rc, scope: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let typed_anno = item.type_annotation.clone(); + let typed_anno = (*item.type_annotation).clone(); let transport_scope = if ((item.params.clone().len() as i64) > 0) { build_params_scope(scope.clone(), item.params.clone()) } else { scope.clone() }; - let transport_result = infer_transport_node(item.transport.clone(), transport_scope); - let typed_transport = transport_result.transport.clone(); + let transport_result = infer_transport_node((*item.transport).clone(), transport_scope); + let typed_transport = (*transport_result.transport).clone(); let transport_diags = transport_result.diagnostics.clone(); let props_result = infer_auth_source_properties(item.properties.clone(), scope.clone()); let typed_properties = props_result.props.clone(); let props_diags = props_result.diagnostics.clone(); if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11083,7 +11044,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push(infer_item(c.clone(), scope.clone()).item.clone()); + __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11105,7 +11066,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc diagnostics: v1_rt::concat(transport_diags, props_diags), }) } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) { { let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( @@ -11115,49 +11076,49 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), ) }, ); - let fn_return_expected = if (item.inferred.clone() != None) { + let fn_return_expected = if ((*item.inferred).clone() != None) { Some(resolved_type(item.clone())) } else { None }; let body_result = infer_expr( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), fn_scope.clone(), fn_return_expected, ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); - let inferred_ret = if (item.inferred.clone() != None) { - item.inferred.clone() + let inferred_ret = if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { - body_typed.inferred.clone() + (*body_typed.inferred).clone() }; let is_recursive = expr_has_self_call( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { annotate_descent_evidence( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), item.params.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), fn_scope.locals.clone(), - scope.func_env.clone(), + (*scope.func_env).clone(), ) } else { body_typed.clone() @@ -11171,7 +11132,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push(infer_item(c.clone(), scope.clone()).item.clone()); + .push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11188,11 +11149,11 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc has_non_tail_self_call: expr_has_non_tail_self_call( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), true, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11205,17 +11166,17 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() != None)) + if ((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + && ((*item.inferred).clone() != None)) { { let fn_scope = scope.clone(); let body_result = infer_expr( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), fn_scope.clone(), Some(resolved_type(item.clone())), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11224,7 +11185,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ident_span: item.ident_span.clone(), children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: Some(body_typed.clone()), @@ -11245,26 +11206,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + { { - let data_expected = if (item.type_annotation.clone() != None) { - Some(item.type_annotation.clone().clone().unwrap()) + let data_expected = if ((*item.type_annotation).clone() != None) { + Some((*item.type_annotation).clone().clone().unwrap()) } else { None }; let val_result = infer_expr( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), scope.clone(), data_expected, ); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let inferred_ret = if (item.type_annotation.clone() != None) { + let inferred_ret = if ((*item.type_annotation).clone() != None) { Some(Rc::new(InferredNode::Resolved { - node: item.type_annotation.clone().clone().unwrap(), + node: (*item.type_annotation).clone().clone().unwrap(), })) } else { - val_typed.inferred.clone() + (*val_typed.inferred).clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11294,7 +11256,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) + && ((*item.body).clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11305,14 +11268,15 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { - item.inferred.clone() + inferred: if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11341,14 +11305,15 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { - item.inferred.clone() + inferred: if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11410,7 +11375,7 @@ pub fn type_node_label( if (authored.clone() != "".to_string()) { authored.clone() } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id.clone(), _ => n.name.clone(), } @@ -11426,7 +11391,7 @@ pub fn param_is_generic_decl( let pt = param_node_type_expr(p.clone()); let pname = param_node_name_at(p.clone(), source_indices.clone()); let tname = type_node_label(pt.clone(), source_indices.clone()); - let type_expr_is_var = match pt.inferred.clone() { + let type_expr_is_var = match (*pt.inferred).clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -11450,7 +11415,7 @@ pub fn unify_generics( let f_bare = (((formal.children.clone().len() as i64) == 0) && (formal.connective.clone() == Connective::NoConnective)); if ((f_bare - || match formal.inferred.clone().as_deref().cloned() { + || match (*formal.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: _, .. }) => true, _ => false, }) @@ -11536,13 +11501,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); + authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11555,7 +11520,7 @@ pub fn unify_record_lit_field_walk( { Some(fi) => { let actual_value = field_init_node_value(fi.clone()); - let field_formal = match sf.inferred.clone().as_deref().cloned() { + let field_formal = match (*sf.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -11572,7 +11537,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.clone(), ) } @@ -11593,7 +11558,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11610,7 +11575,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } else { @@ -11618,7 +11583,7 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) && (formal_name.clone() == record_type_name.clone())) @@ -11638,7 +11603,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11648,7 +11613,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11658,7 +11623,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11689,7 +11654,7 @@ pub fn substitute_generics_apply( source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => { match v1_rt::map_get(&subst, tv_id.clone()) { Some(c) => c.clone(), @@ -11730,7 +11695,7 @@ pub fn substitute_generics_apply( } __result }); - let new_inferred = match n.inferred.clone().as_deref().cloned() { + let new_inferred = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let new_rt = substitute_generics_apply( rt.clone(), @@ -11738,18 +11703,18 @@ pub fn substitute_generics_apply( source_indices.clone(), ); if v1_rt::rc_ptr_eq(new_rt.clone(), rt.clone()) { - n.inferred.clone() + (*n.inferred).clone() } else { Some(Rc::new(InferredNode::Resolved { node: new_rt.clone(), })) } } - _ => n.inferred.clone(), + _ => (*n.inferred).clone(), }; if ((v1_rt::rc_vec_ptr_eq(new_children.clone(), n.children.clone()) && v1_rt::rc_vec_ptr_eq(new_params.clone(), n.params.clone())) - && (new_inferred.clone() == n.inferred.clone())) + && (new_inferred.clone() == (*n.inferred).clone())) { n.clone() } else { @@ -11763,13 +11728,13 @@ pub fn substitute_generics_apply( inferred: new_inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -11797,10 +11762,10 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps(b.resolved.clone(), source_indices); - let is_bare_self = ((((b.resolved.clone().connective.clone() + let deps0 = node_type_deps((*b.resolved).clone(), source_indices); + let is_bare_self = (((((*b.resolved).clone().connective.clone() == Connective::NoConnective) - && ((b.resolved.clone().children.clone().len() as i64) == 0)) + && (((*b.resolved).clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11867,14 +11832,6 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { - if resolved_imports.len() == 1 { - if let Some(imp) = resolved_imports.first().cloned() { - if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - return parent.type_env_cache.clone(); - } - } - return empty_type_env_cache(); - } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11887,58 +11844,29 @@ pub fn union_parent_type_env_caches( ) } -pub fn union_parent_variant_locals( - resolved_imports: Rc>>, - parent_index: Rc>>, -) -> Rc>> { - resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, imp: Rc| match v1_rt::map_get( - &parent_index, - imp.module_path.clone(), - ) { - Some(parent) => v1_rt::rc_map_merge( - acc.clone(), - parent.type_env_cache.clone().variant_locals.clone(), - ), - None => acc.clone(), - }, - ) -} - -pub fn fold_local_coproduct_variant_locals( - bindings: Rc>>, - imported_variants: Rc>, - source_indices: Rc>>, - init_locals: Rc>>, -) -> Rc { - Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - Rc::new(VariantFoldState { - locals: init_locals, - collision_errors: Rc::new(vec![]), - }), - |acc: Rc, binding: Rc| { - let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - { - let binding_enum_name = - authored_name_at(source_indices.clone(), binding.resolved.clone()); - binding - .resolved +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, binding: Rc| { + let is_coproduct = + ((*binding.resolved).clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + (*binding.resolved) .clone() .children .clone() @@ -11946,70 +11874,28 @@ pub fn fold_local_coproduct_variant_locals( .cloned() .fold( acc.clone(), - |vacc: Rc, child: Rc| { + |vacc: Rc>>, child: Rc| { let child_name = - authored_name_at(source_indices.clone(), child.clone()); - let curr_child_is_imported = is_imported_variant_owned_by( - imported_variants.clone(), - child_name.clone(), - binding_enum_name.clone(), - ); - match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { - Some(_prev) => { - if curr_child_is_imported.clone() { - Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }) - } else { - vacc.clone() - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }), + authored_name_at(env.source_indices.clone(), child.clone()); + match v1_rt::map_get(&vacc, child_name.clone()) { + Some(_prev) => vacc.clone(), + None => v1_rt::rc_map_insert( + vacc.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: (*binding.resolved).clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), } }, ) + } else { + acc.clone() } - } else { - acc.clone() - } - }, - ) -} - -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => fold_local_coproduct_variant_locals( - kernel.bindings.clone(), - v1_rt::rc_empty_map::(), - env.source_indices.clone(), - v1_rt::rc_empty_map::>(), - ) - .locals - .clone(), + }, + ), None => v1_rt::rc_empty_map::>(), } } @@ -12066,9 +11952,26 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ); + let filtered_ancestry = + Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) .iter() .cloned() .fold( @@ -12077,8 +11980,10 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -12088,30 +11993,11 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get( - &parent_env.ancestry_str_bindings.clone(), - name.clone(), - ) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ), + ); + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: filtered_str, + ancestry_str_bindings: filtered_ancestry, parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12125,271 +12011,258 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, + parent_index: Rc>>, source_indices: Rc>>, intern_table: Rc, -) -> Rc { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> Rc { + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let intern_table = seed_kernel_intern_table(intern_table.clone()); + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }) -} - -pub fn build_type_env( - module: Rc, - parent_index: Rc>>, - source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - record_build_type_env_call(); - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() .cloned() .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert( acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), + intern(intern_table.clone(), name.clone()).id.clone(), + true, ) }, ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); - let kernel_cache = type_env_cache_from_bindings( - kernel.bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), - ); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let kernel = Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12397,7 +12270,7 @@ pub fn build_type_env( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12407,7 +12280,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12430,7 +12303,7 @@ pub fn build_type_env( ), "'".to_string(), ), - span: imp.target_module.clone().clone().unwrap().span.clone(), + span: (*imp.target_module).clone().clone().unwrap().span.clone(), }), module_name_str.clone(), )]), @@ -12441,7 +12314,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12484,9 +12357,9 @@ pub fn build_type_env( ) } } else { - if (((item.inferred.clone() != None) + if ((((*item.inferred).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && ((*item.body).clone() == None)) { { let alias_node = Rc::new(Node { @@ -12496,7 +12369,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12520,7 +12393,7 @@ pub fn build_type_env( ) } } else { - if ((item.transport.clone() == None) + if (((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12545,8 +12418,8 @@ pub fn build_type_env( } else { if (((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) + && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) { { let bare_node = Rc::new(Node { @@ -12556,7 +12429,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: item.params.clone(), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12585,8 +12458,8 @@ pub fn build_type_env( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -12606,7 +12479,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items(module.module.clone()).iter().cloned().fold( + let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12658,10 +12531,15 @@ pub fn build_type_env( }, ); let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); + let kernel_cache = type_env_cache_from_bindings( + kernel_bindings.clone(), + source_indices.clone(), + compiler_recursive_name_set(), + ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12702,52 +12580,53 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -12771,7 +12650,7 @@ pub fn build_type_env( local_name_set, all_deps_map.clone(), ); - let resolved_env_out = resolved.env.clone(); + let resolved_env_out = (*resolved.env).clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), @@ -12804,7 +12683,6 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { - record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12959,7 +12837,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12967,7 +12845,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12978,7 +12856,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -13021,9 +12899,9 @@ pub fn build_type_env_unresolved( ) } } else { - if (((item.inferred.clone() != None) + if ((((*item.inferred).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && ((*item.body).clone() == None)) { { let alias_node = Rc::new(Node { @@ -13033,7 +12911,7 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -13057,7 +12935,7 @@ pub fn build_type_env_unresolved( ) } } else { - if ((item.transport.clone() == None) + if (((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -13082,8 +12960,8 @@ pub fn build_type_env_unresolved( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -13109,8 +12987,8 @@ pub fn build_type_env_unresolved( ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13151,52 +13029,53 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -13248,11 +13127,11 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name, kind: kind.clone(), - service_names: if (item.body.clone() == None) { + service_names: if ((*item.body).clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), source_indices.clone(), ) }, @@ -13265,30 +13144,30 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name, kind: kind.clone(), - service_names: if (item.body.clone() == None) { + service_names: if ((*item.body).clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), source_indices.clone(), ) }, resource_names: res_names, params: item.params.clone(), - is_self_recursive: if (item.body.clone() == None) { + is_self_recursive: if ((*item.body).clone() == None) { false } else { expr_has_self_call( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), item_name_str.clone(), source_indices.clone(), ) }, - has_non_tail_self_call: if (item.body.clone() == None) { + has_non_tail_self_call: if ((*item.body).clone() == None) { false } else { expr_has_non_tail_self_call( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), item_name_str.clone(), true, source_indices.clone(), @@ -13312,14 +13191,14 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = resolved.item.clone(); + let ritem = (*resolved.item).clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) - && (ritem.inferred.clone() != None)) - && (ritem.body.clone() != None)); + && ((*ritem.inferred).clone() != None)) + && ((*ritem.body).clone() != None)); let func_sig = if (is_func || is_zero_arg_func) { { - let declared_rt = if (ritem.inferred.clone() != None) { + let declared_rt = if ((*ritem.inferred).clone() != None) { Some(resolved_type(ritem.clone())) } else { None @@ -13339,31 +13218,33 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) + let svc_entries = if (((*ritem.transport).clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } - } else { - None - }; + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = if (((*ritem.transport).clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) + } + } else { + None + }; Rc::new(ItemContribution { resolved_item: ritem.clone(), resolve_diagnostics: resolved.diagnostics.clone(), @@ -13402,7 +13283,7 @@ pub fn fold_module_contributions( }); } Some(contribution) => { - let next_func_sigs = match contribution.func_sig.clone() { + let next_func_sigs = match (*contribution.func_sig).clone() { Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), None => func_sigs, }; @@ -13411,7 +13292,7 @@ pub fn fold_module_contributions( svc_registry, authored_name_at( source_indices.clone(), - contribution.resolved_item.clone(), + (*contribution.resolved_item).clone(), ), contribution.svc_entries.clone(), ) @@ -13433,7 +13314,7 @@ pub fn fold_module_contributions( .collect::>(), ); let __tco_1 = - v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); + v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); let __tco_2 = next_func_sigs; let __tco_3 = next_svc_registry; let __tco_4 = next_svc_locals; @@ -13458,76 +13339,315 @@ pub fn fold_module_contributions( } } -pub fn enum_parents_for_variant_in_items( - variant_name: String, - items: Rc>>, +pub fn constructor_binding_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn insert_variant_owner_checked( + state: Rc, + arm_name: String, + owner: Rc, source_indices: Rc>>, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()) - == variant_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } + module_name: String, +) -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); + let owner_name = authored_name_at(source_indices.clone(), owner.clone()); + let same_owner = (((prev_name.clone() == owner_name.clone()) + && ((*prev.resolved).clone().span.clone().file.clone() + == owner.span.clone().file.clone())) + && ((*prev.resolved).clone().span.clone().start.clone() + == owner.span.clone().start.clone())); + if same_owner { + state.clone() + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name.clone(), + enum1: prev_name.clone(), + enum2: owner_name.clone(), + span: owner.span.clone(), + }), + module_name, + )]), + ), + }) } - __result - }) - .iter() - .cloned() - { - __result.push(authored_name_at(source_indices.clone(), item.clone())); } - __result - }) + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name.clone(), + resolved: owner.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } } -pub fn unique_imported_variant_owner( - variant_name: String, +pub fn bind_coproduct_item_arms( + state: Rc, + item: Rc, + source_indices: Rc>>, + module_name: String, +) -> Rc { + item.children.clone().iter().cloned().fold( + state, + |vacc: Rc, child: Rc| { + insert_variant_owner_checked( + vacc, + authored_name_at(source_indices.clone(), child.clone()), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + }, + ) +} + +pub fn build_local_variants( items: Rc>>, source_indices: Rc>>, -) -> Option { - { - let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); - if ((parents.clone().len() as i64) == 1) { - parents.clone().first().cloned() - } else { - None + module_name: String, + init: Rc, +) -> Rc { + items + .iter() + .cloned() + .fold(init, |acc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + acc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + acc.clone() + } + }) +} + +pub fn reexport_chain_authority() -> String { + thread_local! { + static CACHED: String = { + "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn owner_of_exported_arm( + mut module_path: String, + mut arm_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for c in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), c.clone()) + == arm_name.clone()) + { + __found = true; + break; + } + } + __found + } { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == arm_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } } } } -pub fn is_imported_variant_owned_by( - imported_variants: Rc>, - variant_name: String, - enum_name: String, -) -> bool { - match v1_rt::map_get(&imported_variants, variant_name) { - Some(unique_parent) => (unique_parent.clone() == enum_name), - None => false, +pub fn exported_coproduct_item( + mut module_path: String, + mut enum_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if (authored_name_at(source_indices.clone(), item.clone()) + == enum_name.clone()) + { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == enum_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } + } } } @@ -13535,35 +13655,70 @@ pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, -) -> Rc> { + module_name: String, + init: Rc, +) -> Rc { resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, imp: Rc| { - imp.specific_names.clone().iter().cloned().fold( - acc, - |inner: Rc>, variant_name: String| { - if v1_rt::map_contains_key(&inner, variant_name.clone()) { - inner.clone() - } else { - { - let source_items = - match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - match unique_imported_variant_owner( - variant_name.clone(), - source_items.clone(), - source_indices.clone(), - ) { - Some(parent) => v1_rt::rc_map_insert( - inner.clone(), - variant_name.clone(), - parent.clone(), - ), - None => inner.clone(), + init, + |acc: Rc, imp: Rc| { + let with_glob = if imp.is_all.clone() { + { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.clone().iter().cloned().fold( + acc.clone(), + |iacc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + iacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + iacc.clone() } - } + }, + ) + } + } else { + acc.clone() + }; + imp.specific_names.clone().iter().cloned().fold( + with_glob.clone(), + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms( + nacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => nacc.clone(), + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked( + after_enum.clone(), + name.clone(), + owner.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => after_enum.clone(), } }, ) @@ -13571,94 +13726,6 @@ pub fn build_imported_variants( ) } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain -// followers — a module re-exports its specific-name imports, so the binder -// walks the acyclic import chain to the defining module's coproduct. Replaced -// by regen's true emission in the convergence commit. -pub fn owner_of_exported_arm( - module_path: String, - arm_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && item - .children - .iter() - .cloned() - .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == arm_name) - }); - match reexport { - Some(imp) => owner_of_exported_arm( - authored_name_at(source_indices.clone(), imp), - arm_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - -pub fn exported_coproduct_item( - module_path: String, - enum_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && authored_name_at(source_indices.clone(), item.clone()) == enum_name - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == enum_name) - }); - match reexport { - Some(imp) => exported_coproduct_item( - authored_name_at(source_indices.clone(), imp), - enum_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - pub fn build_module_context( contributions: Rc>>, parent_index: Rc>>, @@ -13677,134 +13744,21 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional - // realization of the new v1.compiler.infer dag source — replaced - // wholesale by regen output in the convergence commit. Constructor - // namespace is FLAT: local coproduct arms + direct imports' - // contributions; the binding carries the owner NODE; one arm name - // bound to two different owners = VariantCollision (per-file wall). - let insert_variant_owner_checked = |state: Rc, - arm_name: String, - owner: Rc| - -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = - authored_name_at(env.source_indices.clone(), prev.resolved.clone()); - let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); - let same_owner = prev_name == owner_name - && prev.resolved.span.file == owner.span.file - && prev.resolved.span.start == owner.span.start; - if same_owner { - state - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name, - enum1: prev_name, - enum2: owner_name, - span: owner.span.clone(), - }), - module_name.clone(), - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name, - resolved: owner, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } - }; - let bind_coproduct_item_arms = - |state: Rc, item: Rc| -> Rc { - item.children - .clone() - .iter() - .cloned() - .fold(state, |vacc, child| { - insert_variant_owner_checked( - vacc, - authored_name_at(env.source_indices.clone(), child.clone()), - item.clone(), - ) - }) - }; - let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( + let local_variant_fold = build_local_variants( + local.resolved_items.clone(), + env.source_indices.clone(), + module_name.clone(), Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), - |acc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(acc, item) - } else { - acc - } - }, ); - let variant_fold = resolved_imports.clone().iter().cloned().fold( + let variant_fold = build_imported_variants( + resolved_imports.clone(), + parent_index.clone(), + env.source_indices.clone(), + module_name.clone(), local_variant_fold, - |acc: Rc, imp: Rc| { - // Glob (is_all) imports bind the target's OWN coproduct arms only. - let with_glob = if imp.is_all { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.iter().cloned().fold( - acc, - |iacc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(iacc, item) - } else { - iacc - } - }, - ) - } else { - acc - }; - // Specific names resolve through the re-export chain to the - // defining module (owner_of_exported_arm / exported_coproduct_item). - imp.specific_names.iter().cloned().fold( - with_glob, - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms(nacc, item), - None => nacc, - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked(after_enum, name, owner), - None => after_enum, - } - }, - ) - }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13821,7 +13775,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), + Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), None => Rc::new(vec![]), }) .iter() @@ -13834,7 +13788,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name, + module_name.clone(), env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13848,7 +13802,7 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: resolve_result.func_env.clone(), + func_env: (*resolve_result.func_env).clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, variant_locals: env_variant_locals.clone(), @@ -13889,7 +13843,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = env_result.env.clone(); + let env = (*env_result.env).clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13905,7 +13859,7 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: resolved.module.clone(), + module: (*resolved.module).clone(), items: Rc::new(vec![]), type_env: env.clone(), type_env_cache: env_cache.clone(), @@ -13919,10 +13873,10 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), resolved.module.clone()); + authored_name_at(source_indices.clone(), (*resolved.module).clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items(resolved.module.clone()).iter().cloned() { + for item in module_items((*resolved.module).clone()).iter().cloned() { __result.push(analyze_item( item.clone(), env.clone(), @@ -13941,16 +13895,16 @@ pub fn typecheck_module( let data_locals = ctx.resolved_items.clone().iter().cloned().fold( ctx.locals.clone(), |acc: Rc>>, item: Rc| { - if ((((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() == None)) - && (item.type_annotation.clone() != None)) + if (((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + && ((*item.inferred).clone() == None)) + && ((*item.type_annotation).clone() != None)) { v1_rt::rc_map_insert( acc.clone(), authored_name_at(source_indices.clone(), item.clone()), Rc::new(TypeBinding { name: authored_name_at(source_indices.clone(), item.clone()), - resolved: item.type_annotation.clone().clone().unwrap(), + resolved: (*item.type_annotation).clone().clone().unwrap(), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ) @@ -13961,7 +13915,7 @@ pub fn typecheck_module( ); let infer_scope = Rc::new(InferScope { type_env: env.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13973,7 +13927,7 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push(tir.item.clone()); + __result.push((*tir.item).clone()); } __result }); @@ -13986,7 +13940,7 @@ pub fn typecheck_module( }); let updated_func_env = populate_output_provenance( typed_items.clone(), - ctx.func_env.clone(), + (*ctx.func_env).clone(), env.clone(), data_locals.clone(), ); @@ -13994,18 +13948,18 @@ pub fn typecheck_module( let mut __result = Vec::new(); for item in typed_items.clone().iter().cloned() { __result.push( - if (item.is_self_recursive.clone() && (item.body.clone() != None)) { + if (item.is_self_recursive.clone() && ((*item.body).clone() != None)) { Rc::new(Node { name: item.name.clone(), span: item.span.clone(), ident_span: item.ident_span.clone(), children: item.children.clone(), params: item.params.clone(), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), body: Some(annotate_descent_evidence( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), authored_name_at(source_indices.clone(), item.clone()), item.params.clone(), env.clone(), @@ -14013,12 +13967,12 @@ pub fn typecheck_module( updated_func_env.clone(), )), connective: item.connective.clone(), - transport: item.transport.clone(), + transport: (*item.transport).clone(), properties: item.properties.clone(), - type_annotation: item.type_annotation.clone(), + type_annotation: (*item.type_annotation).clone(), is_self_recursive: item.is_self_recursive.clone(), has_non_tail_self_call: item.has_non_tail_self_call.clone(), - match_pattern: item.match_pattern.clone(), + match_pattern: (*item.match_pattern).clone(), expr_data: item.expr_data.clone(), ident: None, }) @@ -14031,12 +13985,12 @@ pub fn typecheck_module( }); let typed_base = module_node( resolved_module_name.clone(), - module_imports(resolved.module.clone()), + module_imports((*resolved.module).clone()), ctx.resolved_items.clone(), - resolved.module.clone().span.clone(), + (*resolved.module).clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: resolved.module.clone().ident_span.clone(), + ident_span: (*resolved.module).clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { @@ -14187,12 +14141,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14210,7 +14164,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14251,11 +14205,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14273,7 +14227,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14344,7 +14298,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); + let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14367,7 +14321,7 @@ pub fn collect_parent_envs( ), "'".to_string(), ), - span: imp.target_module.clone().clone().unwrap().span.clone(), + span: (*imp.target_module).clone().clone().unwrap().span.clone(), }), resolved_mod_name.clone(), )]), @@ -14405,7 +14359,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items .clone() .iter() @@ -14470,7 +14424,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14525,9 +14479,11 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().source_indices.clone(), + )) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14566,7 +14522,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &m.type_env.clone().recursive_type_set.clone(), + &(*m.type_env).clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), + intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14606,6 +14562,8 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, @@ -14715,7 +14673,7 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), typed.module.clone()), + authored_name_at(source_indices.clone(), (*typed.module).clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); @@ -14731,201 +14689,518 @@ pub fn typecheck_modules( continue; } } - } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct StrBindingsRewireAccum { + pub str_bindings: Rc>>, + pub ancestry_str_bindings: Rc>>, +} + +pub fn import_module_path_at( + imp: Rc, + source_indices: Rc>>, +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn local_authority_binding(owner: Rc, name: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values( + &(*owner.type_env).clone().bindings.clone(), + )) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .first() + .cloned() + { + Some(binding) => Some(binding.clone()), + None => None, + } +} + +pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if module_exports_type_name(m.clone(), name.clone()) { + __result.push(m); + } + } + __result + }) + .len() as i64) +} + +pub fn local_authority_for_name_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn local_authority_for_name( + modules: Rc>>, + name: String, +) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) + { + __result.push(m); + } + } + __result + }) + .last() + .cloned() + { + Some(owner) => Some(owner.clone()), + None => None, + } +} + +pub fn module_exports_type_name(m: Rc, name: String) -> bool { + ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) +} + +pub fn direct_import_exporter_count( + m: Rc, + name: String, + index: Rc>>, + source_indices: Rc>>, +) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*m.module).clone()).iter().cloned() { + if { + let path = import_module_path_at(imp.clone(), source_indices.clone()); + match v1_rt::map_get(&index, path.clone()) { + Some(parent) => module_exports_type_name(parent.clone(), name.clone()), + None => false, + } + } { + __result.push(imp); + } + } + __result + }) + .len() as i64) +} + +pub fn rewire_inherited_str_binding( + modules: Rc>>, + module_index: Rc>>, + consumer: Rc, + source_indices: Rc>>, + local_names: Rc>, + str_bindings: Rc>>, + ancestry_str_bindings: Rc>>, + name: String, +) -> Rc { + if ((v1_rt::set_contains(&local_names, name.clone()) + || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) + > 1)) + || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) + { + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } else { + match local_authority_for_name(modules.clone(), name.clone()) { + Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { + Some(canonical) => { + let ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings.clone(), + name.clone(), + canonical.clone(), + ); + let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { + Some(_) => v1_rt::rc_map_insert( + str_bindings.clone(), + name.clone(), + canonical.clone(), + ), + None => str_bindings.clone(), + }; + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + }, + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + } + } +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + { + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), (*m.module).clone()), + m.clone(), + ) + }, + ); + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + __result.push({ + let local_names = + Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { + v1_rt::rc_set_insert(acc, b.name.clone()) + }); + let ancestry_keys = Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().ancestry_str_bindings.clone(), + )); + let str_keys = + Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); + let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); + let rewired = inherited_keys.clone().iter().cloned().fold( + Rc::new(StrBindingsRewireAccum { + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + }), + |acc: Rc, name: String| { + rewire_inherited_str_binding( + modules.clone(), + index.clone(), + m.clone(), + source_indices.clone(), + local_names.clone(), + acc.str_bindings.clone(), + acc.ancestry_str_bindings.clone(), + name.clone(), + ) + }, + ); + Rc::new(TypedModule { + module: (*m.module).clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: rewired.str_bindings.clone(), + ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), + parents: (*m.type_env).clone().parents.clone(), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: (*m.func_env).clone(), + item_registry: m.item_registry.clone(), + }) + }); + } + __result + }) } } -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, -) -> Rc>> { - record_rewire_type_env_import_str_binding_call(); - fn local_authority_binding(owner: Rc, name: String) -> Option> { - owner - .type_env - .bindings - .values() - .find(|b| b.name.clone() == name) - .cloned() - } - - fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { - modules - .iter() - .filter(|m| module_exports_type_name((**m).clone(), name)) - .count() - } - - fn local_authority_for_name( - modules: Rc>>, - name: String, - ) -> Option> { - // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) - modules + intern_table: Rc, +) -> Rc { + { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() - .rev() - .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - } - - fn module_exports_type_name(m: Rc, name: &str) -> bool { - m.type_env - .bindings - .values() - .any(|b| b.name.as_str() == name) - } - - fn direct_import_exporter_count( - m: Rc, - name: &str, - index: &HashMap>, - source_indices: Rc>>, - ) -> usize { - module_imports(m.module.clone()) - .iter() - .filter(|imp| { - let path = import_module_path_at((*imp).clone(), source_indices.clone()); - index.get(&path).map_or(false, |parent| { - module_exports_type_name(parent.clone(), name) - }) - }) - .count() - } - - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), m.module.clone()), - m.clone(), - ) - }, - ); - - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - let local_names: std::collections::HashSet = m - .type_env - .bindings - .values() - .map(|b| b.name.clone()) - .collect(); - let mut str_bindings = m.type_env.str_bindings.clone(); - let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); - let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() - .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - .filter(|name| !local_names.contains(name)) - .collect(); - inherited_names.sort(); - for name in inherited_names { - if direct_import_exporter_count( - m.clone(), - name.as_str(), - &index, - source_indices.clone(), - ) > 1 - || global_type_exporter_count(modules.clone(), name.as_str()) > 1 - { - continue; - } - if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { - if let Some(canonical) = local_authority_binding(owner, name.clone()) { - if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { - Some(existing) => { - Rc::ptr_eq(&existing.resolved, &canonical.resolved) - && existing.name == canonical.name - } - None => false, - } { - continue; - } - ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings, - name.clone(), - canonical.clone(), - ); - if v1_rt::map_contains_key(&str_bindings, name.clone()) { - str_bindings = - v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); - } - } - } + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } - __result.push(Rc::new(TypedModule { - module: m.module.clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: m.type_env.bindings.clone(), - str_bindings, - ancestry_str_bindings, - parents: m.type_env.parents.clone(), - recursive_types: m.type_env.recursive_types.clone(), - recursive_type_set: m.type_env.recursive_type_set.clone(), - inductive_fields: m.type_env.inductive_fields.clone(), - source_indices: m.type_env.source_indices.clone(), - intern_table: m.type_env.intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), - item_registry: m.item_registry.clone(), - })); - } - __result - }) + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices, + intern_table: intern_table.clone(), + }) + } } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { - record_rewire_type_env_parent_links_call(); { - let intern_table = modules - .first() - .map(|m| m.type_env.intern_table.clone()) - .unwrap_or_else(empty_intern_table); - let shared_kernel = modules - .iter() - .find_map(|m| { - m.type_env.parents.last().and_then(|kernel| { - if kernel.bindings.is_empty() { - None - } else { - Some(kernel.clone()) - } - }) - }) - .unwrap_or_else(|| { - compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) - }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, ); + let shared_kernel = match modules.clone().iter().cloned().fold( + None, + |acc, m: Rc| match acc.clone() { + Some(_) => acc.clone(), + None => match (*m.type_env).clone().parents.clone().last().cloned() { + Some(kernel) => Some(kernel.clone()), + None => None, + }, + }, + ) { + Some(kernel) => kernel.clone(), + None => match modules.clone().first().cloned() { + Some(m) => compiler_kernel_type_env( + source_indices.clone(), + (*m.type_env).clone().intern_table.clone(), + ), + None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), + }, + }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = @@ -14933,7 +15208,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - parent.type_env.clone(), + (*parent.type_env).clone(), )]), None => Rc::new(vec![]), } @@ -14944,23 +15219,28 @@ pub fn rewire_type_env_parent_links( } __result }); - let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: m.type_env.clone().bindings.clone(), - str_bindings: m.type_env.clone().str_bindings.clone(), - ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), - parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), - recursive_types: m.type_env.clone().recursive_types.clone(), - recursive_type_set: m.type_env.clone().recursive_type_set.clone(), - inductive_fields: m.type_env.clone().inductive_fields.clone(), - source_indices: m.type_env.clone().source_indices.clone(), - intern_table: m.type_env.clone().intern_table.clone(), + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + parents: v1_rt::concat( + import_parents.clone(), + Rc::new(vec![shared_kernel.clone()]), + ), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), + func_env: (*m.func_env).clone(), item_registry: m.item_registry.clone(), }) }); @@ -14980,7 +15260,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, @@ -14991,13 +15271,13 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![parent.func_env.clone()]), + Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), None => Rc::new(vec![]), } }) @@ -15008,12 +15288,12 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), - type_env: m.type_env.clone(), + type_env: (*m.type_env).clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: m.func_env.clone().local.clone(), + local: (*m.func_env).clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index c3d02096a6e..0ca86943c45 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -131,7 +131,7 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - parts.key_type.clone(), + (*parts.key_type).clone(), normed_index.clone(), source_indices.clone(), ) { @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality(parts.value_type.clone()), + with_optional_cardinality((*parts.value_type).clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 0dc55228a93..80801b55852 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -229,11 +229,10 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .map(|b| b.name.clone()) - .collect(); - __result.sort(); + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { + __result.push(b.name.clone()); + } __result }); let name_set = all_names diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 8dc46a13d29..e1056496101 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,6 +83,8 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, + pub move_sites_index: Rc>>>, + pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -104,6 +106,8 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), @@ -280,7 +284,7 @@ pub fn build_struct_field_summaries( |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); - if (child.inferred.clone() == None) { + if ((*child.inferred).clone() == None) { acc.clone() } else { { @@ -448,8 +452,7 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child - .inferred + |acc: Rc>, child: Rc| match (*child.inferred) .clone() .as_deref() .cloned() @@ -459,8 +462,8 @@ pub fn build_field_type_map( source_indices.clone(), normalize_access_type_node(ft.clone()), ); - let ft_is_type_var = if (ft.inferred.clone() != None) { - is_type_variable(ft.inferred.clone().clone().unwrap()) + let ft_is_type_var = if ((*ft.inferred).clone() != None) { + is_type_variable((*ft.inferred).clone().clone().unwrap()) } else { false }; @@ -485,7 +488,7 @@ pub fn build_type_summary( { if (((item.connective.clone() == Connective::NoConnective) || (item.connective.clone() == Connective::Arrow)) - || (item.transport.clone() != None)) + || ((*item.transport).clone() != None)) { return None; } @@ -500,7 +503,7 @@ pub fn build_type_summary( let has_fn = { let mut __found = false; for child in item.children.clone().iter().cloned() { - if match child.inferred.clone().as_deref().cloned() { + if match (*child.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.connective.clone() == Connective::Arrow) } @@ -660,7 +663,7 @@ pub fn add_emit_item_summary( let v_has_fn = { let mut __found = false; for vc in variant.children.clone().iter().cloned() { - if match vc.inferred.clone().as_deref().cloned() { + if match (*vc.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => (rt.connective.clone() == Connective::Arrow), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index dc7b6acbab3..daa958bdc8e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,82 +17,12 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -use std::sync::atomic::{AtomicU64, Ordering}; - -// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). -static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); -static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); -static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); - -pub fn flatten_visible_parent_recurses() -> u64 { - FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) -} - -pub fn build_type_env_calls() -> u64 { - BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) -} - -pub fn merge_type_env_cache_calls() -> u64 { - MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_parent_links_calls() -> u64 { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_import_str_binding_calls() -> u64 { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) -} - -pub fn reset_flatten_visible_profile() { - FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); -} - -pub fn reset_type_env_lookup_profile() { - reset_flatten_visible_profile(); - BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); - MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); -} - -pub fn maybe_print_type_env_lookup_profile() { - if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { - eprintln!( - "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", - flatten_visible_parent_recurses(), - build_type_env_calls(), - merge_type_env_cache_calls(), - rewire_type_env_parent_links_calls(), - rewire_type_env_import_str_binding_calls(), - ); - } -} - -pub fn record_flatten_visible_parent_recurse() { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_build_type_env_call() { - BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_parent_links_call() { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_import_str_binding_call() { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); -} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, - #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -101,10 +31,6 @@ pub struct TypeEnv { pub intern_table: Rc, } -fn empty_type_env_parents() -> Rc>> { - Rc::new(vec![]) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -120,6 +46,60 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } +pub fn type_env_compositional_authority_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_work_count_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_key_determinism_authority() -> String { + thread_local! { + static CACHED: String = { + "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn flatten_visible_bindings_invariant() -> String { + thread_local! { + static CACHED: String = { + "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -129,16 +109,34 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn record_merge_type_env_cache_call() { - MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); +pub fn build_type_env_calls() -> i64 { + 0 +} + +pub fn merge_type_env_cache_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_parent_links_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_import_str_binding_calls() -> i64 { + 0 +} + +pub fn type_env_counter_dissolution() -> String { + thread_local! { + static CACHED: String = { + "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { - record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), - // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at - // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -164,42 +162,21 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - let mut pairs: Vec<(String, Rc)> = bindings - .values() - .map(|binding| (binding.name.clone(), binding.clone())) - .collect(); - pairs.sort_by(|a, b| a.0.cmp(&b.0)); - pairs.into_iter().fold( + Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, (name, binding)| { - v1_rt::rc_map_insert(acc, name, binding) - }, - ) -} - -// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value -// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). -#[allow(dead_code)] -pub fn deterministic_str_binding_map( - m: Rc>>, -) -> Rc>> { - let mut keys: Vec = m.keys().cloned().collect(); - keys.sort(); - keys.iter().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, key: &String| { - v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) + |acc: Rc>>, binding: Rc| { + v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings, name.clone()) { + match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { + None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name) { - Some(id) => v1_rt::map_get(&env.bindings, id), + None => match intern_find(env.intern_table.clone(), name.clone()) { + Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), None => None, }, }, @@ -211,7 +188,7 @@ pub fn lookup_binding(env: Rc, ident: i64) -> Option> { Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env, name) + lookup_binding_by_name(env.clone(), name) } } } @@ -224,7 +201,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name.clone()) { + match intern_find(env.intern_table.clone(), name) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } @@ -232,14 +209,14 @@ pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -263,18 +240,26 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) if !fields.is_empty() => fields.clone(), - _ => { - for parent in env.parents.iter() { - let fields = inductive_fields_for(parent.clone(), type_name.clone()); - if !fields.is_empty() { - return fields; - } - } - Rc::new(vec![]) + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) => fields.clone(), + None => Rc::new(vec![]), + }; + if ((local.clone().len() as i64) > 0) { + local.clone() + } else { + env.parents.clone().iter().cloned().fold( + Rc::new(vec![]), + |acc: Rc>>, parent: Rc| { + if ((acc.clone().len() as i64) > 0) { + acc.clone() + } else { + inductive_fields_for(parent.clone(), type_name.clone()) + } + }, + ) } - } + }) } pub fn is_inductive_field( @@ -400,12 +385,27 @@ pub fn inductive_fields_list_to_map( ) } +pub fn flatten_visible_parent_recurses() -> i64 { + 0 +} + +pub fn reset_flatten_visible_profile() -> () { + {} +} + +pub fn reset_type_env_lookup_profile() -> () { + reset_flatten_visible_profile() +} + +pub fn maybe_print_type_env_lookup_profile() -> () { + {} +} + pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -469,7 +469,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings, + str_bindings: merged_bindings.clone(), ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 02b08953fa8..90356140623 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,12 +2,10 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; -pub use crate::std_induction::SubValueRelation; -use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -166,23 +164,26 @@ pub fn inferred_to_outputs( pub fn item_kind(item: Rc) -> ItemKind { { let kind = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { ItemKind::TypeItem } else { - if (item.transport.clone() != None) { + if ((*item.transport).clone() != None) { ItemKind::ServiceItem } else { - if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) + { ItemKind::FnItem } else { - if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { + if (((*item.body).clone() != None) + && ((*item.type_annotation).clone() != None)) + { ItemKind::DataItem } else { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { ItemKind::FnItem } else { ItemKind::OtherItem @@ -196,38 +197,6 @@ pub fn item_kind(item: Rc) -> ItemKind { } } -pub fn variant_locals_from_items( - items: Rc>>, - init: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - items.iter().cloned().fold( - init, - |acc: Rc>>, item: Rc| { - let is_coproduct = (item.connective.clone() == Connective::Disj); - if is_coproduct.clone() { - item.children.clone().iter().cloned().fold( - acc.clone(), - |vacc: Rc>>, child: Rc| { - let child_name = authored_name_at(source_indices.clone(), child.clone()); - v1_rt::rc_map_insert( - vacc, - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: item.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ) - } else { - acc.clone() - } - }, - ) -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index ac704dae929..71b8b8be903 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -126,12 +126,12 @@ pub fn lookup_field_type_node( None => nominal_type_ref("V".to_string()), }; Some( - make_container_type( + (*make_container_type( "Witness".to_string(), value_child, ) - .ty - .clone(), + .ty) + .clone(), ) } } else { @@ -149,7 +149,7 @@ pub fn lookup_field_type_node( } } } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { lookup_field_type_node( target.clone(), @@ -217,18 +217,14 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - if (resolved.connective.clone() == Connective::Conj) { + let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved.connective.clone() == Connective::Conj) + || ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone()))) + { resolved.clone() } else { - let resolved_name = - authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone())) - { - resolved.clone() - } else { - receiver_type.clone() - } + receiver_type.clone() } } } @@ -241,8 +237,8 @@ pub fn resolve_scrutinee_type_node_seen( seen: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; @@ -252,9 +248,9 @@ pub fn resolve_scrutinee_type_node_seen( let normed = normalize_access_type_node(n.clone()); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) - && (normed.inferred.clone() != None)) + && ((*normed.inferred).clone() != None)) { - match normed.inferred.clone().as_deref().cloned() { + match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { resolve_scrutinee_type_node_seen(env.clone(), target.clone(), seen.clone()) } @@ -266,18 +262,18 @@ pub fn resolve_scrutinee_type_node_seen( { { let canonical = authored_name(env.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if ((*normed.inferred).clone() != None) { { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; - match normed.inferred.clone().as_deref().cloned() { + match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { if ((((authored_name(env.clone(), target.clone()) == canonical.clone()) - && (target.inferred.clone() == None)) + && ((*target.inferred).clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { @@ -309,7 +305,7 @@ pub fn resolve_scrutinee_type_node_seen( Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) == canonical.clone()) - && (resolved.inferred.clone() == None)) + && ((*resolved.inferred).clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) @@ -475,10 +471,10 @@ pub struct StructuralMethodLookup { } pub fn product_field_result_type(field: Rc) -> Option> { - match field.inferred.clone().as_deref().cloned() { + match (*field.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match rt.inferred.clone().as_deref().cloned() { + match (*rt.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Some(return_type.clone()), @@ -503,11 +499,7 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some( - make_container_type("Witness".to_string(), raw.clone()) - .ty - .clone(), - ) + Some((*make_container_type("Witness".to_string(), raw.clone()).ty).clone()) } } None => None, @@ -587,12 +579,12 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if ((enriched.ty.clone().connective.clone() == Connective::Conj) - && ((enriched.ty.clone().children.clone().len() as i64) > 0)) + if (((*enriched.ty).clone().connective.clone() == Connective::Conj) + && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( - enriched.ty.clone(), + (*enriched.ty).clone(), method_name.clone(), source_indices.clone(), ); @@ -621,8 +613,8 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: mfr.field_node.clone(), - result_type: mfr.result_type.clone(), + field_node: (*mfr.field_node).clone(), + result_type: (*mfr.result_type).clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), algebra_template: Some(t.clone()), @@ -668,7 +660,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: mfr.field_node.clone(), + method_def: (*mfr.field_node).clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -676,7 +668,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some(mfr.result_type.clone()), + result_type: Some((*mfr.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -694,7 +686,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some(svc_result.result_type.clone()), + result_type: Some((*svc_result.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 96d9884ceb1..12c6fb18bc5 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,28 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - make_map_type( + (*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty - .clone() + .ty) + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)) - .ty - .clone() + (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() } pub fn list_of_element(element: Rc) -> Rc { - make_container_type("List".to_string(), element).ty.clone() + (*make_container_type("List".to_string(), element).ty).clone() } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element) - .ty - .clone() + (*make_container_type("Witness".to_string(), element).ty).clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -127,12 +123,12 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = make_container_type( + let set_ty = (*make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty - .clone(); + .ty) + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); @@ -254,41 +250,6 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_loc".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_test_fns".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_names".to_string(), - list_of_type_variable("test_migration_debt_module_name_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_known_covered_module_is_not_debt".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_holds".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_uncovered_deletes".to_string(), - list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), - ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 1dd9fc95134..c4ead0b440c 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,6 +37,148 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), + None => acc.clone(), + } + }, + ) + } +} + +pub fn expand_scrut_from_decl( + decl: Rc, + scrut_node: Rc, + name: String, + env: Rc, +) -> Rc { + { + let decl_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_alias = ((((*decl.inferred).clone() != None) + && (decl.connective.clone() == Connective::NoConnective)) + && ((decl.children.clone().len() as i64) == 0)); + if decl_is_disj { + decl.clone() + } else { + if has_inferred_alias { + match (*decl.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node, env.clone()); + substitute_type_slots( + target.clone(), + subst, + name, + env.source_indices.clone(), + ) + } + _ => scrut_node, + } + } else { + scrut_node + } + } + } +} + +pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { + { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())); + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if is_generic_use { + expand_scrut_from_decl( + decl.clone(), + scrut_node.clone(), + name.clone(), + env.clone(), + ) + } else { + { + let def_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_body = (((*decl.inferred).clone() != None) + && (decl.connective.clone() == Connective::NoConnective)); + if def_is_disj { + decl.clone() + } else { + if has_inferred_body { + match (*decl.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let target_is_disj = + (target.connective.clone() == Connective::Disj); + if target_is_disj { + target.clone() + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + } + } + } + None => scrut_node.clone(), + } + } +} + +pub fn expand_scrut_type_for_variant_lookup( + mut scrut_node: Rc, + mut env: Rc, +) -> Rc { + loop { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_disj = (scrut_node.connective.clone() == Connective::Disj); + let is_witness = is_witness_type_name(name); + if (is_disj || is_witness) { + break scrut_node.clone(); + } else { + match (*scrut_node.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let __tco_0 = target.clone(); + scrut_node = __tco_0; + continue; + } + _ => { + break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); + } + } + } + } +} + pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -242,8 +384,8 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { pub fn pattern_subject_from_node(mut n: Rc) -> Rc { loop { - let is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; @@ -252,9 +394,9 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() != None)) + && ((*n.inferred).clone() != None)) { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); n = __tco_0; @@ -327,102 +469,6 @@ pub fn variant_not_found_result( )])) } -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), - None => acc, - } - }, - ) -} - -pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { - return scrut_node.clone(); - } - if (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())) - { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if (((decl.inferred.clone() != None) - && ((decl.children.clone().len() as i64) == 0)) - && (decl.connective.clone() == Connective::NoConnective)) - { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); - let expanded = substitute_type_slots( - target, - subst, - name.clone(), - env.source_indices.clone(), - ); - return expanded; - } - _ => scrut_node.clone(), - } - } else if (decl.connective.clone() == Connective::Disj) { - decl.clone() - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } else { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(def) => { - if (def.connective.clone() == Connective::Disj) { - def.clone() - } else if ((def.inferred.clone() != None) - && (def.connective.clone() == Connective::NoConnective)) - { - match def.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - if (target.connective.clone() == Connective::Disj) { - target - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } -} - pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 84f1b36551f..d3e82622f71 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, - is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, + lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -90,8 +90,8 @@ pub fn unit_variant_in_coproduct( } pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc { - if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { - match ty.inferred.clone().as_deref().cloned() { + if ((ty.connective.clone() == Connective::NoConnective) && ((*ty.inferred).clone() != None)) { + match (*ty.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), _ => ty.clone(), } @@ -117,24 +117,41 @@ pub fn lookup_unit_variant_phantom_type( } } +pub fn phantom_match_flat_scope() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), + { + let direct_bindings = env.parents.clone().iter().cloned().fold( + env.str_bindings.clone(), + |acc: Rc>>, parent: Rc| { + v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) }, - ) + ); + Rc::new(v1_rt::map_values(&direct_bindings)) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), + }, + ) + } } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -165,27 +182,36 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { + thread_local! { + static CACHED: String = { + "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) + && is_kernel_type(authored_name_at(source_indices, structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -194,9 +220,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone() != "".to_string()) + if ((((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone()) + && !is_declared_container_alias_spelling(brand_name.clone())) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -213,35 +239,37 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S Some(resolved) => { let structural = if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved - .clone(), - _ => resolve_node_bounded( + match (*resolved.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + (*resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved) + .clone() + } + _ => (*resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved - .clone(), + .resolved) + .clone(), } } else { - resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved + (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved) .clone() }; - if (((brand.clone() != "".to_string()) + if ((((brand.clone() != "".to_string()) && (brand.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand.clone()) + && !is_declared_container_alias_spelling(brand.clone())) && !is_transparent_primitive_alias_rhs( structural.clone(), source_indices.clone(), @@ -251,18 +279,18 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved.inferred.clone().as_deref().cloned() { + match (*resolved.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = resolve_node_bounded( + let target_resolved = (*resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), 0, ) - .resolved - .clone(); + .resolved) + .clone(); with_authored_identity(n.clone(), target_resolved) } _ => resolved.clone(), @@ -347,6 +375,61 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { + thread_local! { + static CACHED: String = { + "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for parent in env.parents.clone().iter().cloned() { + if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), + None => false, + } { + __result.push(parent); + } + } + __result + }) + .first() + .cloned() + { + Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => Some((*b.resolved).clone()), + None => None, + }, + None => None, + } +} + +pub fn resolve_paramless_generic_use_decl( + env: Rc, + n: Rc, + decl: Rc, + brand: String, +) -> Rc { + match ((n.children.clone().len() as i64) > 0) { + true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { + Some(user_decl) => user_decl.clone(), + None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) + { + true => match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural.clone(), + None => decl, + }, + false => decl, + }, + }, + false => decl, + } +} + pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); @@ -354,45 +437,8 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { decl.clone() - } else if ((n.children.clone().len() as i64) > 0) { - // HAND-PATCH (parameterized use site prefers parameterized - // decl; replaced at regen): a use site WITH type args whose - // primary lookup lands paramless (kernel prelude shadowing - // an imported user generic, e.g. Optional) retries the - // ancestry binding for a parameterized decl. - let ancestry_generic = env.parents.iter().fold( - None, - |acc: Option>, parent: &Rc| { - if acc.is_some() { - return acc; - } - match v1_rt::map_get(&parent.str_bindings, brand.clone()) { - Some(b) => { - if ((b.resolved.params.clone().len() as i64) > 0) { - Some(b.resolved.clone()) - } else { - acc - } - } - None => acc, - } - }, - ); - match ancestry_generic { - Some(user_decl) => user_decl, - None => { - if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { - match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl.clone(), - } - } else { - decl.clone() - } - } - } } else { - decl.clone() + resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { @@ -415,7 +461,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { if is_container_type(n.name.clone()) { false } else { - if (decl.inferred.clone() != None) { + if ((*decl.inferred).clone() != None) { true } else { true @@ -438,8 +484,8 @@ pub fn substitute_type_slots( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_slot = (((((n.children.clone().len() as i64) == 0) && (n.connective.clone() == Connective::NoConnective)) - && (n.body.clone() == None)) - && (n.inferred.clone() == None)); + && ((*n.body).clone() == None)) + && ((*n.inferred).clone() == None)); if is_slot { match v1_rt::map_get( &slot_bindings, @@ -477,18 +523,18 @@ pub fn substitute_type_slots( children: substituted_args.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: child.inferred.clone(), + inferred: (*child.inferred).clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: child.properties.clone(), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation).clone(), is_self_recursive: child.is_self_recursive.clone(), has_non_tail_self_call: child .has_non_tail_self_call .clone(), - match_pattern: child.match_pattern.clone(), + match_pattern: (*child.match_pattern).clone(), expr_data: child.expr_data.clone(), ident: None, }) @@ -505,7 +551,7 @@ pub fn substitute_type_slots( } __result }); - let new_inferred = match n.inferred.clone().as_deref().cloned() { + let new_inferred = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Some(Rc::new(InferredNode::Resolved { node: substitute_type_slots( @@ -516,7 +562,7 @@ pub fn substitute_type_slots( ), })) } - _ => n.inferred.clone(), + _ => (*n.inferred).clone(), }; Rc::new(Node { name: n.name.clone(), @@ -528,13 +574,13 @@ pub fn substitute_type_slots( inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -578,8 +624,7 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) - .resolved + (*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) .clone() } AliasKind::AliasLeaf => match lookup_type_by_name( @@ -596,9 +641,9 @@ pub fn resolve_alias_target( pub fn is_parametric_type_alias_decl(item: Rc) -> bool { ((((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) - && (item.inferred.clone() != None)) + && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() != None)) } pub fn resolve_nominal_alias_rhs( @@ -625,7 +670,7 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); @@ -646,13 +691,13 @@ pub fn resolve_nominal_alias_rhs( children: resolved_args, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -697,7 +742,7 @@ pub fn resolve_node_bounded( { let is_product = (n.connective.clone() == Connective::Conj); if is_product { - if (n.type_annotation.clone() != None) { + if ((*n.type_annotation).clone() != None) { match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( @@ -706,7 +751,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let base_resolved = base_result.resolved.clone(); + let base_resolved = (*base_result.resolved).clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -716,13 +761,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![base_resolved]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -742,7 +787,7 @@ pub fn resolve_node_bounded( let child_results = Rc::new({ let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { - __result.push(if (child.inferred.clone() == None) { + __result.push(if ((*child.inferred).clone() == None) { Rc::new(NodeResolveResult { resolved: child.clone(), diagnostics: Rc::new(vec![]), @@ -756,7 +801,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = rt_result.resolved.clone(); + let rt_resolved = (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -775,13 +820,14 @@ pub fn resolve_node_bounded( .return_cardinality .clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: v1_rt::concat( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation) + .clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -798,7 +844,7 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.resolved.clone()); + __result.push((*cr.resolved).clone()); } __result }); @@ -817,13 +863,13 @@ pub fn resolve_node_bounded( children: resolved_children, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -847,7 +893,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = inner_result.resolved.clone(); + let inner_resolved = (*inner_result.resolved).clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: with_optional_cardinality(inner_resolved), @@ -866,7 +912,8 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) { + if ((*field_child.inferred).clone() == None) + { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -907,7 +954,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - rt_result.resolved.clone(); + (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -923,10 +970,10 @@ pub fn resolve_node_bounded( })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), - body: field_child.body.clone(), - transport: field_child.transport.clone(), + body: (*field_child.body).clone(), + transport: (*field_child.transport).clone(), properties: v1_rt::concat(field_child.properties.clone(), rt_resolved.properties.clone()), - type_annotation: field_child.type_annotation.clone(), + type_annotation: (*field_child.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -944,7 +991,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.resolved.clone()); + __result.push((*fr.resolved).clone()); } __result }); @@ -965,16 +1012,16 @@ pub fn resolve_node_bounded( children: resolved_fields.clone(), connective: variant_child.connective.clone(), params: variant_child.params.clone(), - inferred: variant_child.inferred.clone(), + inferred: (*variant_child.inferred).clone(), return_cardinality: variant_child .return_cardinality .clone(), uses: variant_child.uses.clone(), - body: variant_child.body.clone(), - transport: variant_child.transport.clone(), + body: (*variant_child.body).clone(), + transport: (*variant_child.transport).clone(), properties: variant_child.properties.clone(), - type_annotation: variant_child - .type_annotation + type_annotation: (*variant_child + .type_annotation) .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -991,7 +1038,7 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push(vr.resolved.clone()); + __result.push((*vr.resolved).clone()); } __result }); @@ -1010,13 +1057,13 @@ pub fn resolve_node_bounded( children: resolved_variants, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1067,7 +1114,7 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); @@ -1136,12 +1183,12 @@ pub fn resolve_node_bounded( } }, ); - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = ((((*decl.inferred).clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { { - let alias_target = match decl.inferred.clone().as_deref().cloned() { + let alias_target = match (*decl.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { substitute_type_slots( target.clone(), @@ -1164,19 +1211,19 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: target_result.resolved.clone().children.clone(), - connective: target_result.resolved.clone().connective.clone(), + children: (*target_result.resolved).clone().children.clone(), + connective: (*target_result.resolved).clone().connective.clone(), params: Rc::new(vec![]), - inferred: target_result.resolved.clone().inferred.clone(), + inferred: (*(*target_result.resolved).clone().inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), - type_annotation: n.type_annotation.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), + properties: (*target_result.resolved).clone().properties.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1192,13 +1239,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), - type_annotation: n.type_annotation.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), + properties: (*target_result.resolved).clone().properties.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1233,16 +1280,16 @@ pub fn resolve_node_bounded( children: substituted_children, connective: decl.connective.clone(), params: Rc::new(vec![]), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: decl.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1259,13 +1306,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: decl.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -1297,7 +1344,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = key_result.resolved.clone(); + let key_resolved = (*key_result.resolved).clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1305,9 +1352,9 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = val_result.resolved.clone(); + let val_resolved = (*val_result.resolved).clone(); let val_diags = val_result.diagnostics.clone(); - let key_param_name = if (key_child_node.inferred.clone() != None) { + let key_param_name = if ((*key_child_node.inferred).clone() != None) { authored_name(env.clone(), key_child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { @@ -1315,7 +1362,7 @@ pub fn resolve_node_bounded( None => authored_name(env.clone(), key_child_node.clone()), } }; - let val_param_name = if (val_child_node.inferred.clone() != None) { + let val_param_name = if ((*val_child_node.inferred).clone() != None) { authored_name(env.clone(), val_child_node.clone()) } else { match container_param_name(type_name.clone(), 1) { @@ -1375,13 +1422,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_key_child, resolved_val_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1404,9 +1451,10 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = el_result.resolved.clone(); + let el_resolved = (*el_result.resolved).clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() != None) + let el_param_name = if ((*child_node.inferred).clone() + != None) { authored_name(env.clone(), child_node.clone()) } else { @@ -1447,13 +1495,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1472,26 +1520,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: target, .. - }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) - > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = match (*n.inferred) + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { node: target, .. }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1508,10 +1556,9 @@ pub fn resolve_node_bounded( == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved - .inferred + match (*resolved.inferred) .clone() .as_deref() .cloned() @@ -1539,14 +1586,14 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - resolve_node_bounded( + (*resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved - .clone() + .resolved) + .clone() } else { target.clone() } @@ -1569,23 +1616,24 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) { + let n_is_error = if ((*n.inferred).clone() != None) + { is_compiler_error( - n.inferred.clone().clone().unwrap(), + (*n.inferred).clone().clone().unwrap(), ) } else { false }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = if (n.inferred.clone() != None) - { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = + if ((*n.inferred).clone() != None) { + is_type_variable( + (*n.inferred).clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1725,7 +1773,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), missing_generic_args_diagnostics( @@ -1752,7 +1800,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> type_resolved, field_node_cardinality(field.clone()), match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1768,7 +1816,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1782,13 +1830,13 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), - body: authored_type.body.clone(), - transport: authored_type.transport.clone(), + body: (*authored_type.body).clone(), + transport: (*authored_type.transport).clone(), properties: type_resolved.properties.clone(), - type_annotation: authored_type.type_annotation.clone(), + type_annotation: (*authored_type.type_annotation).clone(), is_self_recursive: authored_type.is_self_recursive.clone(), has_non_tail_self_call: authored_type.has_non_tail_self_call.clone(), - match_pattern: authored_type.match_pattern.clone(), + match_pattern: (*authored_type.match_pattern).clone(), expr_data: authored_type.expr_data.clone(), ident: None, }) @@ -1816,7 +1864,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> None => Rc::new(vec![]), }; let default_expr = match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }; Rc::new(ParamResult { @@ -1840,7 +1888,7 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( @@ -1861,7 +1909,7 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( @@ -1886,7 +1934,7 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( @@ -1921,13 +1969,13 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = body_result.expr.clone(); + let body_expr = (*body_result.expr).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( arm_pattern(arm.clone()), match guard_result.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }, body_expr, @@ -1952,7 +2000,7 @@ pub fn resolve_string_part( }), StringPart::Interpolation { expr: expr, .. } => { let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = expr_result.expr.clone(); + let resolved_expr = (*expr_result.expr).clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { @@ -1988,7 +2036,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - val_result.expr.clone(), + (*val_result.expr).clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2001,7 +2049,7 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); @@ -2026,7 +2074,7 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.expr.clone()); + __result.push((*cr.expr).clone()); } __result }); @@ -2054,7 +2102,7 @@ pub fn resolve_transport_binding( transport: make_transport_node( resolved_props, resolved_children, - transport.body.clone(), + (*transport.body).clone(), transport.span.clone(), ), diagnostics: v1_rt::concat(v1_rt::concat(prop_diags, child_diags), body_diags), @@ -2101,7 +2149,7 @@ pub fn resolve_expr_types( }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| r.expr.clone()), + expr: map_children(texpr.clone(), |child| (*r.expr).clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2127,7 +2175,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - vr.expr.clone(), + (*vr.expr).clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2140,7 +2188,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2159,7 +2207,7 @@ pub fn resolve_expr_types( descent_evidence: de.clone(), }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2196,7 +2244,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: rr.expr.clone(), + expr: (*rr.expr).clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2221,7 +2269,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - vr.expr.clone(), + (*vr.expr).clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2236,7 +2284,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2254,7 +2302,7 @@ pub fn resolve_expr_types( method_semantics: ms.clone(), }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2288,7 +2336,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: sr.expr.clone(), + expr: (*sr.expr).clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2323,12 +2371,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match child.match_pattern.clone() { + match (*child.match_pattern).clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some(guard_r.expr.clone()), - body_r.expr.clone(), + Some((*guard_r.expr).clone()), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2352,12 +2400,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match child.match_pattern.clone() { + match (*child.match_pattern).clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, None, - body_r.expr.clone(), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2373,7 +2421,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2388,7 +2436,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprMatch), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2419,14 +2467,18 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), + Some(r) => Rc::new(vec![ + (*cr.expr).clone(), + (*tr.expr).clone(), + (*r.expr).clone(), + ]), + None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2456,15 +2508,15 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![vr.expr.clone()]), + Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), + None => Rc::new(vec![(*vr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( let_binding_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprLet), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2493,7 +2545,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - vr.expr.clone(), + (*vr.expr).clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2506,7 +2558,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2524,7 +2576,7 @@ pub fn resolve_expr_types( parent_enum: pe.clone(), }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2546,7 +2598,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2561,7 +2613,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprListLit), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2593,8 +2645,8 @@ pub fn resolve_expr_types( op: op.clone(), algebra_field: af.clone(), }), - Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(lr.diagnostics.clone(), rr.diagnostics.clone()), @@ -2611,8 +2663,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![r.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*r.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2638,8 +2690,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), - texpr.inferred.clone(), + v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2663,7 +2715,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - r.expr.clone(), + (*r.expr).clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2681,7 +2733,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2696,7 +2748,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2717,7 +2769,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2732,7 +2784,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprBlock), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2759,8 +2811,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(r.diagnostics.clone(), tr.diagnostics.clone()), @@ -2786,8 +2838,8 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![cr.expr.clone(), br.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2817,8 +2869,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![br.expr.clone(), ir.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(br.diagnostics.clone(), ir.diagnostics.clone()), @@ -2856,8 +2908,12 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![ + (*br.expr).clone(), + (*sr.expr).clone(), + (*er.expr).clone(), + ]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2879,8 +2935,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![r.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*r.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2970,7 +3026,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3028,7 +3084,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding, + tp_binding.clone(), ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3050,7 +3106,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push(pr.param.clone()); + __result.push((*pr.param).clone()); } __result }); @@ -3062,7 +3118,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let ret_result = if is_parametric_type_alias_decl(item.clone()) { - match item.inferred.clone().as_deref().cloned() { + match (*item.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: authored_rhs, .. }) => resolve_nominal_alias_rhs( @@ -3070,14 +3126,18 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) env.clone(), module_name.clone(), ), - _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), + _ => resolve_optional_node( + (*item.inferred).clone(), + env.clone(), + module_name.clone(), + ), } } else { - resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) + resolve_optional_node((*item.inferred).clone(), env.clone(), module_name.clone()) }; - let ret_resolved = ret_result.resolved.clone(); + let ret_resolved = (*ret_result.resolved).clone(); let ret_diags = ret_result.diagnostics.clone(); - let resolved_ret = if (item.inferred.clone() == None) { + let resolved_ret = if ((*item.inferred).clone() == None) { None } else { Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) @@ -3096,7 +3156,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push(ur.resource_use.clone()); + __result.push((*ur.resource_use).clone()); } __result }); @@ -3107,62 +3167,62 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) } __result }); - let body_resolved = if (item.body.clone() == None) { + let body_resolved = if ((*item.body).clone() == None) { Rc::new(ExprResolveResult { expr: item.clone(), diagnostics: Rc::new(vec![]), }) } else { resolve_expr_types( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_body = if (item.body.clone() == None) { + let resolved_body = if ((*item.body).clone() == None) { None } else { - Some(body_resolved.expr.clone()) + Some((*body_resolved.expr).clone()) }; - let body_diags = if (item.body.clone() == None) { + let body_diags = if ((*item.body).clone() == None) { Rc::new(vec![]) } else { body_resolved.diagnostics.clone() }; - let anno_resolved = if (item.type_annotation.clone() == None) { + let anno_resolved = if ((*item.type_annotation).clone() == None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), }) } else { resolve_node( - item.type_annotation.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_anno = if (item.type_annotation.clone() == None) { + let resolved_anno = if ((*item.type_annotation).clone() == None) { None } else { - Some(anno_resolved.resolved.clone()) + Some((*anno_resolved.resolved).clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); - let transport_resolved = if (item.transport.clone() == None) { + let transport_resolved = if ((*item.transport).clone() == None) { Rc::new(TransportResolveResult { transport: local_transport_node(no_span()), diagnostics: Rc::new(vec![]), }) } else { resolve_transport_binding( - item.transport.clone().clone().unwrap(), + (*item.transport).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_transport = if (item.transport.clone() == None) { + let resolved_transport = if ((*item.transport).clone() == None) { None } else { - Some(transport_resolved.transport.clone()) + Some((*transport_resolved.transport).clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3179,7 +3239,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); @@ -3191,7 +3251,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let child_results = if ((item.connective.clone() == Connective::Conj) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3216,16 +3276,16 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: child.children.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: child.inferred.clone(), + inferred: (*child.inferred).clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: v1_rt::concat( child.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3239,7 +3299,9 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { + if ((item.connective.clone() == Connective::Disj) + && ((*item.transport).clone() == None)) + { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3270,18 +3332,18 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: field.children.clone(), connective: field.connective.clone(), params: field.params.clone(), - inferred: field.inferred.clone(), + inferred: (*field.inferred).clone(), return_cardinality: field .return_cardinality .clone(), uses: field.uses.clone(), - body: field.body.clone(), - transport: field.transport.clone(), + body: (*field.body).clone(), + transport: (*field.transport).clone(), properties: v1_rt::concat( field.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), - type_annotation: field.type_annotation.clone(), + type_annotation: (*field.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3297,7 +3359,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.item.clone()); + __result.push((*fr.item).clone()); } __result }); @@ -3316,13 +3378,13 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: resolved_fields.clone(), connective: variant.connective.clone(), params: variant.params.clone(), - inferred: variant.inferred.clone(), + inferred: (*variant.inferred).clone(), return_cardinality: variant.return_cardinality.clone(), uses: variant.uses.clone(), - body: variant.body.clone(), - transport: variant.transport.clone(), + body: (*variant.body).clone(), + transport: (*variant.transport).clone(), properties: variant.properties.clone(), - type_annotation: variant.type_annotation.clone(), + type_annotation: (*variant.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3352,7 +3414,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.item.clone()); + __result.push((*cr.item).clone()); } __result }); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 76923b77bc0..7e67bf3ddb2 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,15 +210,15 @@ pub fn expand_transitive_services_once( registry: Rc>>, ) -> Rc>> { modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { - let has_no_body = (item.body.clone() == None); + let has_no_body = ((*item.body).clone() == None); if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); + let called = collect_called_func_names((*item.body).clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), @@ -414,7 +414,7 @@ pub fn service_op_entry( Rc::new(OpEntry { name: authored_name_at(source_indices.clone(), child.clone()), outputs: inferred_to_outputs( - child.inferred.clone(), + (*child.inferred).clone(), child.span.clone(), source_indices.clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index ef23eba9abf..f42fbef7d98 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -99,10 +99,10 @@ pub fn collect_func_call_edges( let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( - (*if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + (*if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) { collect_calls_in_expr( authored_name_at(source_indices.clone(), item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), local_func_set.clone(), source_indices.clone(), ) @@ -226,7 +226,7 @@ pub fn declared_to_resolved(dsig: Rc) -> Rc { Rc::new(ResolvedFuncSig { name: dsig.name.clone(), params: dsig.params.clone(), - inferred: dsig.inferred.clone().clone().unwrap(), + inferred: (*dsig.inferred).clone().clone().unwrap(), is_async: dsig.is_async.clone(), output_provenance: dsig.output_provenance.clone(), variant_provenance: dsig.variant_provenance.clone(), @@ -243,7 +243,7 @@ pub fn merge_remaining_declared( .fold( resolved, |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -277,7 +277,7 @@ pub fn topo_resolve_loop( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -358,7 +358,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -394,7 +394,7 @@ pub fn topo_resolve_loop( cycle_accum.signatures.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -427,7 +427,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -498,7 +498,8 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) + { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 27e0642597b..35a27dd0431 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -83,14 +83,14 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn resolved_type(n: Rc) -> Rc { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } } pub fn child_type_node(ch: Rc) -> Rc { - if (ch.inferred.clone() != None) { + if ((*ch.inferred).clone() != None) { resolved_type(ch.clone()) } else { ch.clone() @@ -170,16 +170,16 @@ pub fn reground_alias_carrier_identity( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -201,16 +201,16 @@ pub fn structural_carrier_template_name( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -242,7 +242,7 @@ pub fn is_fully_resolved( source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_is_type_var = match n.inferred.clone() { + let self_is_type_var = match (*n.inferred).clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -752,16 +752,16 @@ pub fn enrich_base_with_fields( children: fields, connective: Connective::Conj, params: base.params.clone(), - inferred: base.inferred.clone(), + inferred: (*base.inferred).clone(), return_cardinality: base.return_cardinality.clone(), uses: base.uses.clone(), - body: base.body.clone(), - transport: base.transport.clone(), + body: (*base.body).clone(), + transport: (*base.transport).clone(), properties: base.properties.clone(), - type_annotation: base.type_annotation.clone(), + type_annotation: (*base.type_annotation).clone(), is_self_recursive: base.is_self_recursive.clone(), has_non_tail_self_call: base.has_non_tail_self_call.clone(), - match_pattern: base.match_pattern.clone(), + match_pattern: (*base.match_pattern).clone(), expr_data: base.expr_data.clone(), ident: None, }) @@ -866,9 +866,9 @@ pub fn instantiate_algebra_type( }; let inner_b = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, inner_b.ty.clone()); + let built = make_container_type(kind_name, (*inner_b.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -879,16 +879,16 @@ pub fn instantiate_algebra_type( let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -928,13 +928,13 @@ pub fn instantiate_algebra_type( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, rb.ty.clone()), + ty: make_callable_type(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,7 +962,7 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -974,7 +974,7 @@ pub fn instantiate_algebra_field( __result }); let return_b = instantiate_algebra_type( - template.return_type.clone(), + (*template.return_type).clone(), base.clone(), source_indices.clone(), ); @@ -982,10 +982,10 @@ pub fn instantiate_algebra_field( algebra_method_field( template.name.clone(), param_types.clone(), - return_b.ty.clone(), + (*return_b.ty).clone(), ) } else { - algebra_value_field(template.name.clone(), return_b.ty.clone()) + algebra_value_field(template.name.clone(), (*return_b.ty).clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1017,7 +1017,7 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -1312,8 +1312,8 @@ pub fn apply_type_substitution( for ch in receiver.children.clone().iter().cloned() { if !({ let inner = child_type_node(ch.clone()); - if (inner.inferred.clone() != None) { - is_type_variable(inner.inferred.clone().clone().unwrap()) + if ((*inner.inferred).clone() != None) { + is_type_variable((*inner.inferred).clone().clone().unwrap()) } else { ((inner.ident_span.clone() == None) || !is_kernel_type(authored_name_at( @@ -1475,9 +1475,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, inner_applied.ty.clone()); + let built = make_container_type(kind_name, (*inner_applied.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1492,7 +1492,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } @@ -1503,9 +1503,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1551,7 +1551,7 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -1583,7 +1583,7 @@ pub fn apply_type_substitution( } __result }), - rb.ty.clone(), + (*rb.ty).clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1592,11 +1592,11 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self(template.return_type.clone()) + is_receiver_self((*template.return_type).clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable(template.return_type.clone()) + has_type_variable((*template.return_type).clone()) } pub fn has_type_variable(t: Rc) -> bool { @@ -1631,7 +1631,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - template.return_type.clone(), + (*template.return_type).clone(), subst, receiver_type.clone(), source_indices.clone(), @@ -1643,7 +1643,7 @@ pub fn callable_inferred(n: Rc) -> Rc { { let is_callable = ((n.params.clone().len() as i64) > 0); if is_callable { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: ret, .. }) => ret.clone(), None => error_type(), _ => error_type(), @@ -1657,7 +1657,7 @@ pub fn callable_inferred(n: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if ((n.type_annotation.clone() != None) && has_structure) { + let unwrapped = if (((*n.type_annotation).clone() != None) && has_structure) { n.children.clone().first().cloned() } else { None @@ -1686,7 +1686,7 @@ pub fn node_type_shape( let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_leaf { { - let __is_named_ref = match n.inferred.clone().as_deref().cloned() { + let __is_named_ref = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -1797,23 +1797,23 @@ pub fn node_type_compatible( mut source_indices: Rc>>, ) -> bool { loop { - let left_err = if (left.inferred.clone() != None) { - is_compiler_error(left.inferred.clone().clone().unwrap()) + let left_err = if ((*left.inferred).clone() != None) { + is_compiler_error((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { - is_compiler_error(right.inferred.clone().clone().unwrap()) + let right_err = if ((*right.inferred).clone() != None) { + is_compiler_error((*right.inferred).clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { - is_type_variable(left.inferred.clone().clone().unwrap()) + let left_tv = if ((*left.inferred).clone() != None) { + is_type_variable((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { - is_type_variable(right.inferred.clone().clone().unwrap()) + let right_tv = if ((*right.inferred).clone() != None) { + is_type_variable((*right.inferred).clone().clone().unwrap()) } else { false }; @@ -2025,23 +2025,23 @@ pub fn node_type_equals( source_indices: Rc>>, ) -> bool { { - let left_err = if (left.inferred.clone() != None) { - is_compiler_error(left.inferred.clone().clone().unwrap()) + let left_err = if ((*left.inferred).clone() != None) { + is_compiler_error((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { - is_compiler_error(right.inferred.clone().clone().unwrap()) + let right_err = if ((*right.inferred).clone() != None) { + is_compiler_error((*right.inferred).clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { - is_type_variable(left.inferred.clone().clone().unwrap()) + let left_tv = if ((*left.inferred).clone() != None) { + is_type_variable((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { - is_type_variable(right.inferred.clone().clone().unwrap()) + let right_tv = if ((*right.inferred).clone() != None) { + is_type_variable((*right.inferred).clone().clone().unwrap()) } else { false }; @@ -2291,8 +2291,7 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left - .inferred + match (*left.inferred) .clone() .as_deref() .cloned() @@ -2300,8 +2299,7 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right - .inferred + }) => match (*right.inferred) .clone() .as_deref() .cloned() @@ -2318,7 +2316,7 @@ pub fn node_type_equals_core( _ => false, }, None => { - (right.inferred.clone() == None) + ((*right.inferred).clone() == None) } _ => false, } @@ -2344,18 +2342,18 @@ pub fn node_type_deps( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; if n_is_type_var { return Rc::new(vec![]); } - let __is_named_ref = if (n.inferred.clone() == None) { + let __is_named_ref = if ((*n.inferred).clone() == None) { false } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -2371,7 +2369,7 @@ pub fn node_type_deps( let has_structure = (n.connective.clone() != Connective::NoConnective); let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_named_ref { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Rc::new(vec![authored_name_at(source_indices.clone(), rt.clone())]) } @@ -2383,12 +2381,12 @@ pub fn node_type_deps( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.extend( - (*match child.inferred.clone().as_deref().cloned() { + (*match (*child.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } _ => { - if (child.inferred.clone() == None) { + if ((*child.inferred).clone() == None) { node_type_deps(child.clone(), source_indices.clone()) } else { Rc::new(vec![]) @@ -2402,8 +2400,8 @@ pub fn node_type_deps( __result }) } else { - if (n.inferred.clone() != None) { - match n.inferred.clone().as_deref().cloned() { + if ((*n.inferred).clone() != None) { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } @@ -2641,10 +2639,14 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { + Some(m) => match (*(*m.field_node).clone().inferred) + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match rt.inferred.clone().as_deref().cloned() { + match (*rt.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Rc::new(BinOpInferred { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 0da15e2a8e5..b167a2cd12c 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -32,7 +32,7 @@ pub fn check_bare_containers( source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let has_structure = ((match n.body.clone() { + let has_structure = ((match (*n.body).clone() { Some(_) => true, None => false, } || ((n.uses.clone().len() as i64) > 0)) @@ -98,13 +98,13 @@ pub fn check_bare_containers( } __result }); - let type_ann_diags = match n.type_annotation.clone() { + let type_ann_diags = match (*n.type_annotation).clone() { Some(ta) => { check_bare_containers(ta.clone(), module_name.clone(), source_indices.clone()) } None => Rc::new(vec![]), }; - let body_diags = match n.body.clone() { + let body_diags = match (*n.body).clone() { Some(b) => { check_bare_containers(b.clone(), module_name.clone(), source_indices.clone()) } @@ -113,7 +113,7 @@ pub fn check_bare_containers( let inferred_diags = if ((n.params.clone().len() as i64) > 0) { Rc::new(vec![]) } else { - match n.inferred.clone() { + match (*n.inferred).clone() { Some(inf) => match (*inf.clone()).clone() { InferredNode::Resolved { node: rn, .. } => check_bare_containers( rn.clone(), @@ -187,14 +187,17 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items(m.module.clone()); + let items = module_items((*m.module).clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { __result.extend( (*check_bare_containers( item.clone(), - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at( + source_indices.clone(), + (*m.module).clone(), + ), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 160e9fc850f..f4200b72527 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,14 +690,39 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn build_movable_set(proof: Rc) -> Rc> { +pub fn whole_value_borrow_count(usage: Rc) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for c in usage.consumers.clone().iter().cloned() { + if match c.kind.clone() { + EdgeKind::Read => true, + EdgeKind::Threaded => true, + _ => false, + } { + __result.push(c); + } + } + __result + }) + .len() as i64) +} + +pub fn build_movable_set( + proof: Rc, + param_names: Rc>, +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) + if ((match (*make_decision(usage.clone())).clone() { + OwnershipDecision::SoleOwner { .. } => true, + _ => false, + } && (whole_value_borrow_count(usage.clone()) == 0)) + && (is_owned_local(usage.binding_kind.clone()) + || v1_rt::set_contains(¶m_names, usage.name.clone()))) { __result.push(usage); } @@ -1138,13 +1163,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { + let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { + let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1233,6 +1258,337 @@ pub fn analyze_ownership( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiveState { + pub name: String, + pub whole: bool, + pub any_field: bool, + pub fields: Rc>, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct MoveLicenseAccum { + pub live: Rc>>, + pub licensed: Rc>, +} + +pub fn move_site_key(name: String, span_start: i64) -> String { + v1_rt::concat( + v1_rt::concat(name, "@".to_string()), + (span_start).to_string(), + ) +} + +pub fn empty_live_state(name: String) -> Rc { + Rc::new(LiveState { + name: name, + whole: false, + any_field: false, + fields: v1_rt::rc_empty_set::(), + }) +} + +pub fn live_state_of(acc: Rc, name: String) -> Rc { + match v1_rt::map_get(&acc.live.clone(), name.clone()) { + Some(st) => st.clone(), + None => empty_live_state(name.clone()), + } +} + +pub fn record_whole_use_site( + acc: Rc, + name: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !st.any_field.clone()); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: true, + any_field: st.any_field.clone(), + fields: st.fields.clone(), + }), + ), + licensed: licensed, + }) + } +} + +pub fn record_field_use_site( + acc: Rc, + name: String, + field: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !v1_rt::set_contains(&st.fields.clone(), field.clone())); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: st.whole.clone(), + any_field: true, + fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), + }), + ), + licensed: licensed, + }) + } +} + +pub fn merge_live_states(a: Rc, b: Rc) -> Rc { + Rc::new(LiveState { + name: a.name.clone(), + whole: (a.whole.clone() || b.whole.clone()), + any_field: (a.any_field.clone() || b.any_field.clone()), + fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), + }) +} + +pub fn merge_branch_licenses(branches: Rc>>) -> Rc { + branches.iter().cloned().fold( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + |acc: Rc, br: Rc| { + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + { + let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) + .iter() + .cloned() + .fold( + acc.live, + |lm: Rc>>, k: String| { + let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { + Some(s) => s.clone(), + None => empty_live_state(k.clone()), + }; + match v1_rt::map_get(&lm, k.clone()) { + Some(a_st) => v1_rt::rc_map_insert( + lm.clone(), + k.clone(), + merge_live_states(a_st.clone(), b_st.clone()), + ), + None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), + } + }, + ); + let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) + .iter() + .cloned() + .fold(acc.licensed, |l: Rc>, k: String| { + v1_rt::rc_map_insert(l, k.clone(), true) + }); + Rc::new(MoveLicenseAccum { + live: live_merged.clone(), + licensed: lic_merged.clone(), + }) + } + }, + ) +} + +pub fn license_walk( + acc: Rc, + texpr: Rc, + in_capture: bool, + si: Rc>>, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + match (*texpr.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_whole_use_site( + acc.clone(), + expr_var_name_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + ExprData::ExprLiteral { value: _, .. } => acc.clone(), + ExprData::ExprFieldAccess { .. } => { + let base_node = field_access_base(texpr.clone()); + match (*base_node.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_field_use_site( + acc.clone(), + expr_var_name_at(base_node.clone(), si.clone()), + field_access_field_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + _ => license_walk( + acc.clone(), + base_node.clone(), + in_capture.clone(), + si.clone(), + ), + } + } + ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }), + ExprData::ExprMethodCall { .. } => { + let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }); + license_walk( + args_acc, + method_receiver(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprIf => { + let t_acc = license_walk( + acc.clone(), + if_then_branch(texpr.clone()), + in_capture.clone(), + si.clone(), + ); + let e_acc = match if_else_branch(texpr.clone()) { + Some(eb) => { + license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) + } + None => acc.clone(), + }; + let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); + license_walk( + merged, + if_condition(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprMatch => { + let branch_accs = Rc::new({ + let mut __result = Vec::new(); + for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { + __result.push(license_walk( + acc.clone(), + arm_body(arm_node.clone()), + in_capture.clone(), + si.clone(), + )); + } + __result + }); + let merged = merge_branch_licenses(branch_accs); + license_walk( + merged, + match_scrutinee(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprLet => { + let body_acc = match let_body(texpr.clone()) { + Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), + None => acc.clone(), + }; + license_walk( + body_acc, + let_value(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprLambda => { + license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) + } + ExprData::ExprForEach => { + let body_acc = + license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); + license_walk( + body_acc, + foreach_collection(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, field: Rc| { + license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) + }), + _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + } + }) +} + +pub fn build_move_site_licenses( + body: Rc, + si: Rc>>, +) -> Rc> { + { + let walked = license_walk( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + body, + false, + si, + ); + walked.licensed.clone() + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index b2340d2e960..8cba6f4e406 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::ParseError; +use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,7 +91,11 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream.all.clone().get(stream.pos.clone() as usize).cloned() + stream + .all + .clone() + .get((stream.pos.clone()) as usize) + .cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -1945,7 +1949,7 @@ pub fn is_conj_with_children(n: Rc) -> bool { } pub fn child_inferred_or_empty(ch: Rc) -> Rc { - match ch.inferred.clone().as_deref().cloned() { + match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } @@ -1960,7 +1964,7 @@ pub fn node_inferred_to_outputs( let all_children_typed = { let mut __all = true; for ch in rt.children.clone().iter().cloned() { - if !(match ch.inferred.clone().as_deref().cloned() { + if !(match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }) { @@ -1978,7 +1982,7 @@ pub fn node_inferred_to_outputs( authored_name_at(source_indices.clone(), ch.clone()), child_inferred_or_empty(ch.clone()), Cardinality::Required, - ch.body.clone(), + (*ch.body).clone(), None, ch.span.clone(), node_name_span(ch.clone()), @@ -2076,7 +2080,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some(r.module.clone()), + module: Some((*r.module).clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2231,7 +2235,7 @@ pub fn parse_imports_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r.import.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r.import).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2279,7 +2283,7 @@ pub fn parse_items_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r.item.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r.item).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2592,7 +2596,7 @@ pub fn parse_item_prefix( let tokens = ret_result.tokens.clone(); let ctx = ret_result.ctx.clone(); let missing_required_ret = (form.return_required.clone() - && match ret_result.inferred.clone() { + && match (*ret_result.inferred).clone() { Some(_) => false, None => true, }); @@ -2634,7 +2638,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: ret_result.inferred.clone(), + inferred: (*ret_result.inferred).clone(), uses: Rc::new(vec![]), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -2646,7 +2650,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: ret_result.inferred.clone(), + inferred: (*ret_result.inferred).clone(), uses: uses_result.uses.clone(), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -3422,7 +3426,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![rv.variant.clone()]), + Rc::new(vec![(*rv.variant).clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3500,7 +3504,7 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = r.variant.clone(); + let first_variant = (*r.variant).clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), @@ -3571,7 +3575,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3590,7 +3594,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3627,7 +3631,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3646,7 +3650,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3774,7 +3778,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -4295,11 +4299,11 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), Cardinality::Required, None, None, - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4475,7 +4479,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4673,7 +4677,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: ret.type_expr.clone(), + node: (*ret.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4708,10 +4712,10 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), None, - r.type_expr.clone().span.clone(), - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), + (*r.type_expr).clone().span.clone(), ); acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4758,7 +4762,7 @@ pub fn finish_type_expr_from_name( if has_err(r.err.clone()) { return r.clone(); } - let first_arg = r.type_expr.clone(); + let first_arg = (*r.type_expr).clone(); let type_args = collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { @@ -4916,7 +4920,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); + let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -4950,16 +4954,16 @@ pub fn maybe_optional( children: te.children.clone(), connective: te.connective.clone(), params: te.params.clone(), - inferred: te.inferred.clone(), + inferred: (*te.inferred).clone(), return_cardinality: Cardinality::CardOptional, uses: te.uses.clone(), - body: te.body.clone(), - transport: te.transport.clone(), + body: (*te.body).clone(), + transport: (*te.transport).clone(), properties: te.properties.clone(), - type_annotation: te.type_annotation.clone(), + type_annotation: (*te.type_annotation).clone(), is_self_recursive: te.is_self_recursive.clone(), has_non_tail_self_call: te.has_non_tail_self_call.clone(), - match_pattern: te.match_pattern.clone(), + match_pattern: (*te.match_pattern).clone(), expr_data: te.expr_data.clone(), ident: None, }); @@ -5017,7 +5021,7 @@ pub fn parse_field_list_acc( }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -5079,7 +5083,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = __ec.clone(); @@ -5932,23 +5936,23 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - r3.type_expr.clone(), + (*r3.type_expr).clone(), start_span.clone(), r.span.clone(), ); @@ -6035,7 +6039,7 @@ pub fn parse_resource_config_acc( err: r3.err.clone(), }); } - let fi = make_field_init_node(field_name, r3.expr.clone(), zero_span, r.span.clone()); + let fi = make_field_init_node(field_name, (*r3.expr).clone(), zero_span, r.span.clone()); acc = v1_rt::rc_list_push(acc.clone(), fi); match (*eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { @@ -6071,7 +6075,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: r.type_expr.clone(), + node: (*r.type_expr).clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6237,12 +6241,12 @@ pub fn parse_service_after_kw( ); let svc_props = match r.config.clone() { Some(cfg) => service_config_properties( - cfg.endpoint.clone(), - cfg.auth.clone(), - cfg.auth_input.clone(), - cfg.auth_source.clone(), - cfg.rate_limit.clone(), - cfg.retry.clone(), + (*cfg.endpoint).clone(), + (*cfg.auth).clone(), + (*cfg.auth_input).clone(), + (*cfg.auth_source).clone(), + (*cfg.rate_limit).clone(), + (*cfg.retry).clone(), ), None => Rc::new(vec![]), }; @@ -6257,7 +6261,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some(r.transport.clone()), + transport: Some((*r.transport).clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6382,7 +6386,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.transport.clone(); + let __tco_2 = (*r.transport).clone(); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -6421,7 +6425,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); + let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6563,32 +6567,32 @@ pub fn parse_config_fields( }; match fname.as_str() { "endpoint" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); retry = __tco_0; continue; } @@ -6636,7 +6640,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6655,7 +6659,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6682,7 +6686,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6701,7 +6705,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6728,7 +6732,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6747,7 +6751,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6875,49 +6879,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*r3.expr.clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), + let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -7056,7 +7060,7 @@ pub fn parse_shell_fields( }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7162,7 +7166,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7309,7 +7313,7 @@ pub fn parse_operation_v2_inline( } let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); - let outputs = match ret.inferred.clone().as_deref().cloned() { + let outputs = match (*ret.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_inferred_to_outputs(rt.clone(), ctx.source_indices.clone()) } @@ -7431,7 +7435,7 @@ pub fn parse_operation_v1_body( r2.mock_props.clone(), r2.exit_props.clone(), r2.modifier_props.clone(), - r2.transport.clone(), + (*r2.transport).clone(), start_span.clone(), ctx.source_indices.clone(), ); @@ -7666,7 +7670,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some(r.transport.clone()); + let __tco_2 = Some((*r.transport).clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -8061,7 +8065,7 @@ pub fn node_to_name_str( None => v1_rt::concat(opt_prefix, effective_name.clone()), } } else { - if (effective_n.type_annotation.clone() != None) { + if ((*effective_n.type_annotation).clone() != None) { match effective_n.children.clone().first().cloned() { Some(ch) => v1_rt::concat( opt_prefix, @@ -8132,7 +8136,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = r.expr.clone(); + let code = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8161,7 +8165,7 @@ pub fn parse_exit_entries_acc( _ => r3.tokens.clone(), }; let code_str = status_expr_to_str(code, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( prop_name, @@ -8170,10 +8174,10 @@ pub fn parse_exit_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8459,7 +8463,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8479,7 +8483,7 @@ pub fn parse_response_entries_acc( }); } let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( prop_name, @@ -8488,10 +8492,10 @@ pub fn parse_response_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8608,7 +8612,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8627,7 +8631,7 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = r3.expr.clone(); + let body = (*r3.expr).clone(); let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), @@ -8858,7 +8862,8 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); + let __tco_2 = + v1_rt::rc_list_push(capabilities, (*r.capability).clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8978,7 +8983,7 @@ pub fn parse_resource_entries( } let fi = make_field_init_node( fname, - r3.expr.clone(), + (*r3.expr).clone(), make_span(0, 0), r.span.clone(), ); @@ -9183,7 +9188,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc node_inferred_to_outputs( rt.clone(), ret.ctx.clone().source_indices.clone(), @@ -9474,7 +9479,7 @@ pub fn parse_data_after_kw( err: r.err.clone(), }); } - let te = r.type_expr.clone(); + let te = (*r.type_expr).clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r.err.clone()) { return Rc::new(ItemResult { @@ -9502,7 +9507,7 @@ pub fn parse_data_after_kw( inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(r.expr.clone()), + body: Some((*r.expr).clone()), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -9587,7 +9592,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9660,7 +9665,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(r3.expr.clone()), + EatResult::EatConsumed { .. } => Some((*r3.expr).clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { name: name, span: span, ident_span: Some(name_span), - children: Rc::new(vec![r3.expr.clone()]), + children: Rc::new(vec![(*r3.expr).clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: ret.inferred.clone(), + inferred: (*ret.inferred).clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -10105,7 +10110,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![r3.expr.clone()]), + Rc::new(vec![(*r3.expr).clone()]), None, span, name_span, @@ -10118,17 +10123,17 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: node.inferred.clone(), + inferred: (*node.inferred).clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: node.body.clone(), + body: (*node.body).clone(), connective: node.connective.clone(), - transport: node.transport.clone(), + transport: (*node.transport).clone(), properties: cr.constraints.clone(), - type_annotation: node.type_annotation.clone(), + type_annotation: (*node.type_annotation).clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: node.match_pattern.clone(), + match_pattern: (*node.match_pattern).clone(), expr_data: node.expr_data.clone(), ident: None, }); @@ -10164,7 +10169,7 @@ pub fn parse_expr_bp( if has_err(r.err.clone()) { return r.clone(); } - let lhs = r.expr.clone(); + let lhs = (*r.expr).clone(); parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10199,7 +10204,7 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = post.expr.clone(); + let __tco_2 = (*post.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10261,7 +10266,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10270,7 +10275,7 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.expr.clone(); + let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10285,7 +10290,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10304,7 +10309,7 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - r.expr.clone(), + (*r.expr).clone(), ]), None, loop_span, @@ -10515,7 +10520,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -11385,13 +11390,13 @@ pub fn parse_index_or_slice( let r = parse_expr(r.tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let first_expr = r.expr.clone(); + let first_expr = (*r.expr).clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11399,13 +11404,13 @@ pub fn parse_index_or_slice( let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let end_expr = r.expr.clone(); + let end_expr = (*r.expr).clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11520,7 +11525,7 @@ pub fn parse_arg_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.arg.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.arg).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -11576,7 +11581,8 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some(r.expr.clone()), + guard: Some((*r.expr).clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12481,7 +12487,7 @@ pub fn parse_variant_pattern( } let fb = make_field_binding_node( "0".to_string(), - r.pattern.clone(), + (*r.pattern).clone(), span, kernel_span("0".to_string()), ); @@ -12567,7 +12573,7 @@ pub fn parse_variant_bindings_brace_acc( }); let fb = make_field_binding_node( field_name.clone(), - r2.pattern.clone(), + (*r2.pattern).clone(), bind_span, field_name_span, ); @@ -12631,7 +12637,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index a0826e3e1bf..d3042fd1aa4 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -229,12 +229,6 @@ pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() } -pub fn sorted_map_keys(m: &HashMap) -> Vec { - let mut keys = map_keys(m); - keys.sort(); - keys -} - pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -335,40 +329,6 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. -// take_owned_counted: the fail-closed replacement for the silent -// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: -// a failure arm must refuse or be counted, never silently widen). The ownership -// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose -// per-site frequency must stay observable, so the clone arm counts per emitted -// site (site = ":" of the use-site the emitter rewrote). -thread_local! { - static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = - std::cell::RefCell::new(HashMap::new()); -} - -pub fn take_owned_counted(x: Rc, site: &'static str) -> T { - Rc::try_unwrap(x).unwrap_or_else(|rc| { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); - (*rc).clone() - }) -} - -pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| { - let mut v: Vec<(String, u64)> = m - .borrow() - .iter() - .map(|(site, n)| (site.to_string(), *n)) - .collect(); - v.sort(); - v - }) -} - -pub fn reset_take_owned_clone_fallbacks() { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); -} - pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From a224dfd8f8f3d22e7e22cc926f7a9f7ba1b2818e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 03:33:04 +0000 Subject: [PATCH 10/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_compile.rs | 26 +- src/v1/stage0/src/v1_compiler_emit.rs | 44 +- .../src/v1_compiler_emit_core_support.rs | 24 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 8 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 8 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 54 +-- src/v1/stage0/src/v1_compiler_infer.rs | 414 +++++++++--------- .../stage0/src/v1_compiler_infer_emit_info.rs | 14 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 14 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 22 +- .../stage0/src/v1_compiler_infer_patterns.rs | 18 +- .../stage0/src/v1_compiler_infer_resolve.rs | 298 ++++++------- .../stage0/src/v1_compiler_infer_service.rs | 6 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 18 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 106 ++--- src/v1/stage0/src/v1_compiler_normalize.rs | 8 +- src/v1/stage0/src/v1_compiler_ownership.rs | 4 +- src/v1/stage0/src/v1_compiler_parse.rs | 84 ++-- src/v1/stage0/src/v1_compiler_resolve.rs | 2 +- 19 files changed, 586 insertions(+), 586 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 28965259701..bd68c32eb6e 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -135,7 +135,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> if { let mut __found = false; for item in m.items.clone().iter().cloned() { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { __found = true; break; } @@ -156,7 +156,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> for item in Rc::new({ let mut __result = Vec::new(); for item in m.items.clone().iter().cloned() { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { __result.push(item); } } @@ -170,7 +170,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> (*m.type_env).clone().source_indices.clone(), item.clone(), ), - body: (*item.body).clone().clone().unwrap(), + body: item.body.clone().clone().unwrap(), params: item.params.clone(), span: item.span.clone(), is_tail_recursive: (item.is_self_recursive.clone() @@ -200,7 +200,7 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc) -> Rc) -> bool { (import_is_all(n.clone()) - || (((((n.children.clone().len() as i64) > 0) && ((*n.body).clone() == None)) + || (((((n.children.clone().len() as i64) > 0) && (n.body.clone() == None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && ((n.params.clone().len() as i64) == 0))) } @@ -1880,7 +1880,7 @@ pub fn serialize_node_record( Connective::Disj => json_quote(connective_name(Connective::Disj)), Connective::NoConnective => "null".to_string(), Connective::Arrow => json_quote(connective_name(Connective::Arrow)), -}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref((*node.inferred).clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref((*node.body).clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref((*node.transport).clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref((*node.type_annotation).clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) +}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref(node.inferred.clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref(node.body.clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref(node.transport.clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref(node.type_annotation.clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) } pub fn serialize_typed_module( @@ -2276,7 +2276,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let mut __result = Vec::new(); for p in parse_results.clone().iter().cloned() { __result.extend( - (*match (*p.module).clone() { + (*match p.module.clone() { Some(m) => Rc::new(vec![m.clone()]), None => Rc::new(vec![]), }) diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index f8d7b8d487a..b79a0b20400 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -1249,7 +1249,7 @@ pub fn named_type_vars_in_inferred(inferred: Option>) -> Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_vars = named_type_vars_in_inferred((*n.inferred).clone()); + let self_vars = named_type_vars_in_inferred(n.inferred.clone()); let child_vars = Rc::new({ let mut __result = Vec::new(); for ch in n.children.clone().iter().cloned() { @@ -1326,13 +1326,13 @@ pub fn render_node_type( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); - let n_is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let n_is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; @@ -1340,7 +1340,7 @@ pub fn render_node_type( && ((n.children.clone().len() as i64) == 0)) { { - let is_named_type_var = match (*n.inferred).clone().as_deref().cloned() { + let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) } @@ -1379,7 +1379,7 @@ pub fn render_node_type( __result }); let param_str = param_strs.clone().join(&repr.param_separator.clone()); - let ret_str = match (*n.inferred).clone().as_deref().cloned() { + let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_node_type( rt.clone(), target.clone(), @@ -1463,7 +1463,7 @@ pub fn render_node_type( } if is_conj { { - if ((*n.type_annotation).clone() != None) { + if (n.type_annotation.clone() != None) { { let refined_str = match n.children.clone().first().cloned() { Some(base) => render_node_type( @@ -1484,7 +1484,7 @@ pub fn render_node_type( { let first_child = match n.children.clone().first().cloned() { Some(c) => { - if ((*c.inferred).clone() != None) { + if (c.inferred.clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1504,7 +1504,7 @@ pub fn render_node_type( }; let second_child = match n.children.clone().get(1 as usize).cloned() { Some(c) => { - if ((*c.inferred).clone() != None) { + if (c.inferred.clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1813,15 +1813,15 @@ pub fn has_service_items(typed: Rc) -> bool { } pub fn service_fallback_transport(item: Rc) -> Rc { - if ((*item.transport).clone() == None) { + if (item.transport.clone() == None) { local_transport_node(item.span.clone()) } else { - (*item.transport).clone().clone().unwrap() + item.transport.clone().clone().unwrap() } } pub fn effective_operation_transport(op_node: Rc, fallback: Rc) -> Rc { - match (*op_node.transport).clone() { + match op_node.transport.clone() { Some(op_transport) => op_transport.clone(), None => fallback, } @@ -1837,9 +1837,9 @@ pub fn service_has_rest( let from_ops = { let mut __found = false; for op in op_children.iter().cloned() { - if if ((*op.transport).clone() != None) { + if if (op.transport.clone() != None) { is_rest_transport( - (*op.transport).clone().clone().unwrap(), + op.transport.clone().clone().unwrap(), source_indices.clone(), ) } else { @@ -1861,8 +1861,8 @@ pub fn service_has_shell(fallback_transport: Rc, op_children: Rc { emit_node_type(n.clone(), target.clone(), source_indices.clone()) } diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index d61dd191831..39ad3967ac0 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -658,17 +658,17 @@ pub fn is_type_alias_return_node( } pub fn is_service_item(item: Rc) -> bool { - (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_type_def_item(item: Rc) -> bool { - ((item.connective.clone() != Connective::NoConnective) && ((*item.transport).clone() == None)) + ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) } pub fn is_bare_leaf_item(item: Rc) -> bool { - (((((item.connective.clone() == Connective::NoConnective) && ((*item.body).clone() == None)) + (((((item.connective.clone() == Connective::NoConnective) && (item.body.clone() == None)) && ((item.params.clone().len() as i64) == 0)) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) } @@ -686,26 +686,26 @@ pub fn is_type_decl_item( ) -> bool { ((is_bare_leaf_item(item.clone()) && !is_type_alias_return_node(resolved_type(item.clone()), source_indices)) - || (((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + || (((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0))) } pub fn is_function_item(item: Rc) -> bool { - (((*item.body).clone() != None) && ((*item.type_annotation).clone() == None)) + ((item.body.clone() != None) && (item.type_annotation.clone() == None)) } pub fn is_data_def_item(item: Rc) -> bool { - (((*item.body).clone() != None) && ((*item.type_annotation).clone() != None)) + ((item.body.clone() != None) && (item.type_annotation.clone() != None)) } pub fn is_service_def_item(item: Rc) -> bool { - (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_resource_def_item(item: Rc) -> bool { - ((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) - || (((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) == 0)) + (((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) + || ((((item.transport.clone() == None) && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) > 0)) - && ((*item.body).clone() == None))) + && (item.body.clone() == None))) } diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 177e2376db6..7eef606e0ae 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -717,7 +717,7 @@ pub fn emit_go_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -726,7 +726,7 @@ pub fn emit_go_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -735,8 +735,8 @@ pub fn emit_go_typed_item( if is_data_def_item(item.clone()) { emit_go_data_def( item_text, - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), 0, diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 1f2d2d804a1..af3d0bda615 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -607,7 +607,7 @@ pub fn emit_py_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -616,7 +616,7 @@ pub fn emit_py_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -625,8 +625,8 @@ pub fn emit_py_typed_item( if is_data_def_item(item.clone()) { emit_py_data_def( item_text, - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index edaf8bd9ff0..58ad35e2925 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -2100,7 +2100,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match (*wire_item.body).clone() { + match wire_item.body.clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2146,7 +2146,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match (*wc.body).clone() { + match wc.body.clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2293,7 +2293,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2311,7 +2311,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2370,7 +2370,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match (*item.type_annotation).clone() { + match item.type_annotation.clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2423,7 +2423,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2448,7 +2448,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -3266,7 +3266,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -7501,7 +7501,7 @@ pub fn emit_typed_item( }; let item_is_tco = is_tco_eligible( authored_name(env.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); @@ -7561,7 +7561,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7572,7 +7572,7 @@ pub fn emit_typed_item( item_text.clone(), item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7584,8 +7584,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text.clone(), - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -12119,7 +12119,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { + let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -15289,7 +15289,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if ((*arg_value(init_arg.clone()).inferred).clone() != None) { + if (arg_value(init_arg.clone()).inferred.clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -21734,7 +21734,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match (*state.node).clone() { + let next_node = match state.node.clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21770,7 +21770,7 @@ pub fn advance_wire_path_projection( }) } } else { - match (*state.node).clone() { + match state.node.clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -23006,7 +23006,7 @@ pub fn data_def_annotation_is_named_refinement( { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); ((((ann_name.clone() != "".to_string()) - && ((*annotation.type_annotation).clone() != None)) + && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -23646,7 +23646,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23905,7 +23905,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match (*data_item.body).clone() { + Some(data_item) => match data_item.body.clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23978,7 +23978,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if ((*item.body).clone() == None) { + if (item.body.clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 19cc103d962..635072e7f2f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -381,7 +381,7 @@ pub fn merge_scope_from_imports( svc_locals: svc_locals, }), |acc: Rc, titem: Rc| { - if (((*titem.transport).clone() != None) + if ((titem.transport.clone() != None) && ((titem.children.clone().len() as i64) > 0)) { { @@ -394,7 +394,7 @@ pub fn merge_scope_from_imports( c.clone(), ), outputs: inferred_to_outputs( - (*c.inferred).clone(), + c.inferred.clone(), c.span.clone(), env.source_indices.clone(), ), @@ -425,11 +425,11 @@ pub fn merge_scope_from_imports( }) } } else { - if ((((((*titem.body).clone() != None) + if (((((titem.body.clone() != None) && ((titem.params.clone().len() as i64) == 0)) - && ((*titem.transport).clone() == None)) + && (titem.transport.clone() == None)) && (titem.connective.clone() == Connective::NoConnective)) - && ((*titem.inferred).clone() != None)) + && (titem.inferred.clone() != None)) { Rc::new(InferScopeComponents { svc_registry: acc.svc_registry.clone(), @@ -514,7 +514,7 @@ pub fn classify_field_recursion( source_indices: Rc>>, ) -> Option> { { - let type_expr = match (*field_node.inferred).clone().as_deref().cloned() { + let type_expr = match field_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(field_node.clone()), }; @@ -975,7 +975,7 @@ pub fn record_lit_expanded_from_expected( { Some(exp.clone()) } else { - match (*exp.inferred).clone().as_deref().cloned() { + match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -1090,15 +1090,15 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { .return_cardinality .clone(), uses: sf.uses.clone(), - body: (*sf.body).clone(), - transport: (*sf.transport).clone(), + body: sf.body.clone(), + transport: sf.transport.clone(), properties: sf.properties.clone(), - type_annotation: (*sf.type_annotation).clone(), + type_annotation: sf.type_annotation.clone(), is_self_recursive: sf.is_self_recursive.clone(), has_non_tail_self_call: sf .has_non_tail_self_call .clone(), - match_pattern: (*sf.match_pattern).clone(), + match_pattern: sf.match_pattern.clone(), expr_data: sf.expr_data.clone(), ident: None, })); @@ -1146,7 +1146,7 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match (*arg_value(receiver_arg).inferred) + match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1166,7 +1166,7 @@ pub fn set_union_other_operand_is_resolved_non_set( other_arg: Rc, scope: Rc, ) -> bool { - match (*arg_value(other_arg).inferred).clone().as_deref().cloned() { + match arg_value(other_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. }) => !node_is_set_collection( @@ -1188,7 +1188,7 @@ pub fn set_element_type_from_receiver( } pub fn set_element_type_is_concrete(elem: Rc) -> bool { - match (*elem.inferred).clone() { + match elem.inferred.clone() { Some(inf) => !is_type_variable(inf.clone()), None => true, } @@ -1383,7 +1383,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1413,7 +1413,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1450,7 +1450,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1494,7 +1494,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match (*arg_value(insert_arg.clone()).inferred) + Some(insert_arg) => match arg_value(insert_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1508,7 +1508,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match (*arg_value(other_arg.clone()).inferred) + Some(other_arg) => match arg_value(other_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1545,7 +1545,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1617,7 +1617,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match (*arg_value(receiver_arg.clone()).inferred) + match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -2784,8 +2784,8 @@ pub fn infer_expr( scope.module_name.clone(), ) }; - let resolved_base_is_error = if ((*resolved_base.inferred).clone() != None) { - is_compiler_error((*resolved_base.inferred).clone().clone().unwrap()) + let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { + is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; @@ -3280,7 +3280,7 @@ pub fn infer_expr( scope.service_registry.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let is_known_method = ((*method_resolution.result_type).clone() != None); + let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { { let receiver = method_receiver.clone(); @@ -3293,18 +3293,18 @@ pub fn infer_expr( .collect::>(), ); let base_result_type = - match (*method_resolution.result_type).clone() { + match method_resolution.result_type.clone() { Some(mt) => mt.clone(), None => error_type(), }; - let method_tv = if ((*method_resolution.semantics).clone() == None) + let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()) + match (*method_resolution.semantics.clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3374,13 +3374,13 @@ pub fn infer_expr( }; let bridge_result_type = (*method_tv.ty).clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if ((*method_resolution.semantics) + let returns_receiver_self = if (method_resolution.semantics .clone() == None) { false } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()) + match (*method_resolution.semantics.clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3414,15 +3414,15 @@ pub fn infer_expr( })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), - body: (*receiver.body).clone(), - transport: (*receiver.transport).clone(), + body: receiver.body.clone(), + transport: receiver.transport.clone(), properties: receiver.properties.clone(), - type_annotation: (*receiver.type_annotation).clone(), + type_annotation: receiver.type_annotation.clone(), is_self_recursive: receiver.is_self_recursive.clone(), has_non_tail_self_call: receiver .has_non_tail_self_call .clone(), - match_pattern: (*receiver.match_pattern).clone(), + match_pattern: receiver.match_pattern.clone(), expr_data: receiver.expr_data.clone(), ident: None, }) @@ -3448,7 +3448,7 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: (*method_resolution.semantics) + method_semantics: method_resolution.semantics .clone(), }), v1_rt::concat( @@ -3827,7 +3827,7 @@ match bare_s { scope.service_registry.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let pipe_fb = match (*method_resolution.result_type).clone() { + let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { result_ty: rt.clone(), kernel_diags: Rc::new(vec![]), @@ -3840,13 +3840,13 @@ match bare_s { ), }; let base_result_type = (*pipe_fb.result_ty).clone(); - let method_tv_mc = if ((*method_resolution.semantics).clone() == None) { + let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()).clone() { + match (*method_resolution.semantics.clone().clone().unwrap()).clone() { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. @@ -3902,8 +3902,8 @@ match bare_s { }; let result_type = (*method_tv_mc.ty).clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); - let method_semantics = if ((*method_resolution.semantics).clone() != None) { - (*method_resolution.semantics).clone() + let method_semantics = if (method_resolution.semantics.clone() != None) { + method_resolution.semantics.clone() } else { Some(Rc::new(MethodSemantics::PlainMethodSemantics)) }; @@ -3937,7 +3937,7 @@ match bare_s { let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(scrut_typed.clone()); - let scrut_subject = pattern_subject_from_inferred((*scrut_typed.inferred).clone()); + let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ let mut __result = Vec::new(); @@ -4392,7 +4392,7 @@ match bare_s { let_name.clone(), Rc::new(ExprData::ExprLet), Rc::new(vec![val_typed.clone(), body_typed.clone()]), - (*body_typed.inferred).clone(), + body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), ); @@ -4766,13 +4766,13 @@ match bare_s { inferred: param_type.clone(), return_cardinality: pn.return_cardinality.clone(), uses: pn.uses.clone(), - body: (*pn.body).clone(), - transport: (*pn.transport).clone(), + body: pn.body.clone(), + transport: pn.transport.clone(), properties: pn.properties.clone(), - type_annotation: (*pn.type_annotation).clone(), + type_annotation: pn.type_annotation.clone(), is_self_recursive: pn.is_self_recursive.clone(), has_non_tail_self_call: pn.has_non_tail_self_call.clone(), - match_pattern: (*pn.match_pattern).clone(), + match_pattern: pn.match_pattern.clone(), expr_data: pn.expr_data.clone(), }) }); @@ -4782,7 +4782,7 @@ match bare_s { let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), - (*body_typed.inferred).clone(), + body_typed.inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -4896,7 +4896,7 @@ match bare_s { let si = (*scope.type_env).clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( - (*inner_typed.inferred).clone(), + inner_typed.inferred.clone(), target_name, span.clone(), si.clone(), @@ -4952,7 +4952,7 @@ match bare_s { variable.clone(), Rc::new(ExprData::ExprForEach), Rc::new(vec![coll_typed.clone(), body_typed.clone()]), - (*body_typed.inferred).clone(), + body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), ); @@ -4971,10 +4971,10 @@ match bare_s { let index_result = infer_expr(idx_key, scope.clone(), None); let index_typed = (*index_result.typed).clone(); let index_diags = index_result.diagnostics.clone(); - let index_check = match (*base_typed.inferred).clone().as_deref().cloned() { + let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match (*index_typed.inferred).clone().as_deref().cloned() { + }) => match index_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: index_type, .. }) => Some(check_index_access_node( @@ -4989,14 +4989,14 @@ match bare_s { _ => None, }; let access_failure_inferred = - match (*base_typed.inferred).clone().as_deref().cloned() { + match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - (*index_typed.inferred).clone() + index_typed.inferred.clone() } - _ => (*base_typed.inferred).clone(), + _ => base_typed.inferred.clone(), }; let idx_inferred = match index_check.clone() { - Some(checked) => (*checked.inferred).clone(), + Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid index access".to_string(), @@ -5035,13 +5035,13 @@ match bare_s { let end_result = infer_expr(end_expr, scope.clone(), None); let end_typed = (*end_result.typed).clone(); let end_diags = end_result.diagnostics.clone(); - let slice_check = match (*base_typed.inferred).clone().as_deref().cloned() { + let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match (*start_typed.inferred).clone().as_deref().cloned() { + }) => match start_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: start_type, .. - }) => match (*end_typed.inferred).clone().as_deref().cloned() { + }) => match end_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: end_type, .. }) => { Some(check_slice_access_node( base_type.clone(), @@ -5059,19 +5059,19 @@ match bare_s { _ => None, }; let access_failure_inferred = - match (*base_typed.inferred).clone().as_deref().cloned() { + match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - match (*start_typed.inferred).clone().as_deref().cloned() { + match start_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - (*end_typed.inferred).clone() + end_typed.inferred.clone() } - _ => (*start_typed.inferred).clone(), + _ => start_typed.inferred.clone(), } } - _ => (*base_typed.inferred).clone(), + _ => base_typed.inferred.clone(), }; let slc_inferred = match slice_check.clone() { - Some(checked) => (*checked.inferred).clone(), + Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid slice access".to_string(), @@ -5107,7 +5107,7 @@ match bare_s { let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), Rc::new(vec![(*inner_result.typed).clone()]), - (*(*inner_result.typed).clone().inferred).clone(), + (*inner_result.typed).clone().inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -5226,13 +5226,13 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if (((*n.inferred).clone() != None) && is_type_variable((*n.inferred).clone().clone().unwrap())) + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && ((*n.inferred).clone() == None)) + && (n.inferred.clone() == None)) { { let name = authored_name_at(env.source_indices.clone(), n.clone()); @@ -5258,7 +5258,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && ((*n.inferred).clone() == None)) + && (n.inferred.clone() == None)) { is_user_generic_use_site(n.clone(), env.clone()) } else { @@ -5272,7 +5272,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((binding.connective.clone() == Connective::NoConnective) && ((binding.children.clone().len() as i64) == 0)) - && ((*binding.inferred).clone() != None)) + && (binding.inferred.clone() != None)) { true } else { @@ -5280,7 +5280,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { && ((binding.children.clone().len() as i64) > 0)) { (is_user_generic_use_site(binding.clone(), env.clone()) - || ((*binding.inferred).clone() != None)) + || (binding.inferred.clone() != None)) } else { false } @@ -5308,7 +5308,7 @@ pub fn peel_alias_once_for_field_access( } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) - && ((*once.inferred).clone() == None)) + && (once.inferred.clone() == None)) { { let __tco_0 = once.clone(); @@ -5326,7 +5326,7 @@ pub fn structural_from_expanded_type(normed: Rc) -> Rc { match normed.connective.clone() { Connective::Conj => normed.clone(), Connective::Disj => normed.clone(), - _ => match (*normed.inferred).clone().as_deref().cloned() { + _ => match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => match target.connective.clone() { Connective::Conj => target.clone(), Connective::Disj => target.clone(), @@ -5347,7 +5347,7 @@ pub fn record_field_type_is_unresolved_param( if ((ft.connective.clone() == Connective::NoConnective) && ((ft.children.clone().len() as i64) == 0)) { - match (*ft.inferred).clone() { + match ft.inferred.clone() { Some(inf) => is_type_variable(inf.clone()), None => { let fname = authored_name_at(env.source_indices.clone(), ft.clone()); @@ -5461,11 +5461,11 @@ pub fn alias_chain_target_after_args( target.clone(), type_args.clone(), ); - let is_parameterized_alias = ((((*decl.inferred).clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: alias_body, .. }) => substitute_generics( @@ -5642,9 +5642,9 @@ pub fn record_lit_alias_struct_fields( Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) - && ((*decl.inferred).clone() != None)) + && (decl.inferred.clone() != None)) { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), _ => decl.clone(), } @@ -5866,7 +5866,7 @@ pub fn infer_record_lit( .cloned() { Some(sf) => { - let ft = match (*sf.inferred).clone().as_deref().cloned() { + let ft = match sf.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -5973,7 +5973,7 @@ pub fn infer_record_lit( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*(*fir.infer_result.clone().typed).clone().inferred).clone(), + inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -7110,7 +7110,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let type_based = match (*val.inferred).clone().as_deref().cloned() { + let type_based = match val.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if is_container_type(authored_name_at( (*ctx.type_env).clone().source_indices.clone(), @@ -8254,16 +8254,16 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: Rc::new(ExprData::ExprCall { call_semantics: cs.clone(), descent_evidence: Some(evidence), @@ -8544,16 +8544,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: v1_rt::concat(Rc::new(vec![annotated_scrut]), annotated_arms), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8654,16 +8654,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8777,16 +8777,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: threaded.children.clone(), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9044,16 +9044,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9115,16 +9115,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: Rc::new(vec![annotated_coll, annotated_body.clone()]), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9140,7 +9140,7 @@ pub fn resolved_type_name( n: Rc, source_indices: Rc>>, ) -> String { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, rt.clone()) } @@ -10696,7 +10696,7 @@ pub fn populate_output_provenance( None => acc.clone(), } } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { if !expr_has_self_call( body.clone(), @@ -10715,7 +10715,7 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = match (*item.inferred) + let variant_prov = match item.inferred .clone() .as_deref() .cloned() @@ -10876,16 +10876,16 @@ pub fn infer_property_values( children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: (*p.inferred).clone(), + inferred: p.inferred.clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: (*p.body).clone(), - transport: (*p.transport).clone(), + body: p.body.clone(), + transport: p.transport.clone(), properties: p.properties.clone(), - type_annotation: (*p.type_annotation).clone(), + type_annotation: p.type_annotation.clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: (*p.match_pattern).clone(), + match_pattern: p.match_pattern.clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -10939,16 +10939,16 @@ pub fn infer_auth_source_properties( children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: (*p.inferred).clone(), + inferred: p.inferred.clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: (*p.body).clone(), - transport: (*p.transport).clone(), + body: p.body.clone(), + transport: p.transport.clone(), properties: p.properties.clone(), - type_annotation: (*p.type_annotation).clone(), + type_annotation: p.type_annotation.clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: (*p.match_pattern).clone(), + match_pattern: p.match_pattern.clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -11000,16 +11000,16 @@ pub fn infer_transport_node( children: t.children.clone(), connective: t.connective.clone(), params: t.params.clone(), - inferred: (*t.inferred).clone(), + inferred: t.inferred.clone(), return_cardinality: t.return_cardinality.clone(), uses: t.uses.clone(), - body: (*t.body).clone(), - transport: (*t.transport).clone(), + body: t.body.clone(), + transport: t.transport.clone(), properties: prop_result.props.clone(), - type_annotation: (*t.type_annotation).clone(), + type_annotation: t.type_annotation.clone(), is_self_recursive: t.is_self_recursive.clone(), has_non_tail_self_call: t.has_non_tail_self_call.clone(), - match_pattern: (*t.match_pattern).clone(), + match_pattern: t.match_pattern.clone(), expr_data: t.expr_data.clone(), ident: None, })), @@ -11021,20 +11021,20 @@ pub fn infer_transport_node( pub fn infer_item(item: Rc, scope: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let typed_anno = (*item.type_annotation).clone(); + let typed_anno = item.type_annotation.clone(); let transport_scope = if ((item.params.clone().len() as i64) > 0) { build_params_scope(scope.clone(), item.params.clone()) } else { scope.clone() }; - let transport_result = infer_transport_node((*item.transport).clone(), transport_scope); - let typed_transport = (*transport_result.transport).clone(); + let transport_result = infer_transport_node(item.transport.clone(), transport_scope); + let typed_transport = transport_result.transport.clone(); let transport_diags = transport_result.diagnostics.clone(); let props_result = infer_auth_source_properties(item.properties.clone(), scope.clone()); let typed_properties = props_result.props.clone(); let props_diags = props_result.diagnostics.clone(); if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11066,7 +11066,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc diagnostics: v1_rt::concat(transport_diags, props_diags), }) } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { { let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( @@ -11083,22 +11083,22 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ) }, ); - let fn_return_expected = if ((*item.inferred).clone() != None) { + let fn_return_expected = if (item.inferred.clone() != None) { Some(resolved_type(item.clone())) } else { None }; let body_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), fn_scope.clone(), fn_return_expected, ); let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); - let inferred_ret = if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + let inferred_ret = if (item.inferred.clone() != None) { + item.inferred.clone() } else { - (*body_typed.inferred).clone() + body_typed.inferred.clone() }; let is_recursive = expr_has_self_call( body_typed.clone(), @@ -11166,13 +11166,13 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.inferred).clone() != None)) + if (((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() != None)) { { let fn_scope = scope.clone(); let body_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), fn_scope.clone(), Some(resolved_type(item.clone())), ); @@ -11185,7 +11185,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ident_span: item.ident_span.clone(), children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: Some(body_typed.clone()), @@ -11206,27 +11206,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { { - let data_expected = if ((*item.type_annotation).clone() != None) { - Some((*item.type_annotation).clone().clone().unwrap()) + let data_expected = if (item.type_annotation.clone() != None) { + Some(item.type_annotation.clone().clone().unwrap()) } else { None }; let val_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), scope.clone(), data_expected, ); let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let inferred_ret = if ((*item.type_annotation).clone() != None) { + let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { - node: (*item.type_annotation).clone().clone().unwrap(), + node: item.type_annotation.clone().clone().unwrap(), })) } else { - (*val_typed.inferred).clone() + val_typed.inferred.clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11257,7 +11257,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc } } else { if (((item.params.clone().len() as i64) > 0) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11275,8 +11275,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + inferred: if (item.inferred.clone() != None) { + item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11312,8 +11312,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + inferred: if (item.inferred.clone() != None) { + item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11375,7 +11375,7 @@ pub fn type_node_label( if (authored.clone() != "".to_string()) { authored.clone() } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id.clone(), _ => n.name.clone(), } @@ -11391,7 +11391,7 @@ pub fn param_is_generic_decl( let pt = param_node_type_expr(p.clone()); let pname = param_node_name_at(p.clone(), source_indices.clone()); let tname = type_node_label(pt.clone(), source_indices.clone()); - let type_expr_is_var = match (*pt.inferred).clone() { + let type_expr_is_var = match pt.inferred.clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -11415,7 +11415,7 @@ pub fn unify_generics( let f_bare = (((formal.children.clone().len() as i64) == 0) && (formal.connective.clone() == Connective::NoConnective)); if ((f_bare - || match (*formal.inferred).clone().as_deref().cloned() { + || match formal.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: _, .. }) => true, _ => false, }) @@ -11520,7 +11520,7 @@ pub fn unify_record_lit_field_walk( { Some(fi) => { let actual_value = field_init_node_value(fi.clone()); - let field_formal = match (*sf.inferred).clone().as_deref().cloned() { + let field_formal = match sf.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -11654,7 +11654,7 @@ pub fn substitute_generics_apply( source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => { match v1_rt::map_get(&subst, tv_id.clone()) { Some(c) => c.clone(), @@ -11695,7 +11695,7 @@ pub fn substitute_generics_apply( } __result }); - let new_inferred = match (*n.inferred).clone().as_deref().cloned() { + let new_inferred = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let new_rt = substitute_generics_apply( rt.clone(), @@ -11703,18 +11703,18 @@ pub fn substitute_generics_apply( source_indices.clone(), ); if v1_rt::rc_ptr_eq(new_rt.clone(), rt.clone()) { - (*n.inferred).clone() + n.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: new_rt.clone(), })) } } - _ => (*n.inferred).clone(), + _ => n.inferred.clone(), }; if ((v1_rt::rc_vec_ptr_eq(new_children.clone(), n.children.clone()) && v1_rt::rc_vec_ptr_eq(new_params.clone(), n.params.clone())) - && (new_inferred.clone() == (*n.inferred).clone())) + && (new_inferred.clone() == n.inferred.clone())) { n.clone() } else { @@ -11728,13 +11728,13 @@ pub fn substitute_generics_apply( inferred: new_inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -12303,7 +12303,7 @@ pub fn build_type_env( ), "'".to_string(), ), - span: (*imp.target_module).clone().clone().unwrap().span.clone(), + span: imp.target_module.clone().clone().unwrap().span.clone(), }), module_name_str.clone(), )]), @@ -12357,9 +12357,9 @@ pub fn build_type_env( ) } } else { - if ((((*item.inferred).clone() != None) + if (((item.inferred.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { { let alias_node = Rc::new(Node { @@ -12369,7 +12369,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12393,7 +12393,7 @@ pub fn build_type_env( ) } } else { - if (((*item.transport).clone() == None) + if ((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12418,8 +12418,8 @@ pub fn build_type_env( } else { if (((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + && (item.body.clone() == None)) + && (item.transport.clone() == None)) { { let bare_node = Rc::new(Node { @@ -12429,7 +12429,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: item.params.clone(), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12458,8 +12458,8 @@ pub fn build_type_env( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -12899,9 +12899,9 @@ pub fn build_type_env_unresolved( ) } } else { - if ((((*item.inferred).clone() != None) + if (((item.inferred.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { { let alias_node = Rc::new(Node { @@ -12911,7 +12911,7 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12935,7 +12935,7 @@ pub fn build_type_env_unresolved( ) } } else { - if (((*item.transport).clone() == None) + if ((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12960,8 +12960,8 @@ pub fn build_type_env_unresolved( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -13127,11 +13127,11 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name, kind: kind.clone(), - service_names: if ((*item.body).clone() == None) { + service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), source_indices.clone(), ) }, @@ -13144,30 +13144,30 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name, kind: kind.clone(), - service_names: if ((*item.body).clone() == None) { + service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), source_indices.clone(), ) }, resource_names: res_names, params: item.params.clone(), - is_self_recursive: if ((*item.body).clone() == None) { + is_self_recursive: if (item.body.clone() == None) { false } else { expr_has_self_call( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), item_name_str.clone(), source_indices.clone(), ) }, - has_non_tail_self_call: if ((*item.body).clone() == None) { + has_non_tail_self_call: if (item.body.clone() == None) { false } else { expr_has_non_tail_self_call( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), item_name_str.clone(), true, source_indices.clone(), @@ -13194,11 +13194,11 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let ritem = (*resolved.item).clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) - && ((*ritem.inferred).clone() != None)) - && ((*ritem.body).clone() != None)); + && (ritem.inferred.clone() != None)) + && (ritem.body.clone() != None)); let func_sig = if (is_func || is_zero_arg_func) { { - let declared_rt = if ((*ritem.inferred).clone() != None) { + let declared_rt = if (ritem.inferred.clone() != None) { Some(resolved_type(ritem.clone())) } else { None @@ -13218,7 +13218,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = if (((*ritem.transport).clone() != None) + let svc_entries = if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { Rc::new({ @@ -13231,7 +13231,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { Rc::new(vec![]) }; - let svc_local = if (((*ritem.transport).clone() != None) + let svc_local = if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { { @@ -13283,7 +13283,7 @@ pub fn fold_module_contributions( }); } Some(contribution) => { - let next_func_sigs = match (*contribution.func_sig).clone() { + let next_func_sigs = match contribution.func_sig.clone() { Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), None => func_sigs, }; @@ -13895,16 +13895,16 @@ pub fn typecheck_module( let data_locals = ctx.resolved_items.clone().iter().cloned().fold( ctx.locals.clone(), |acc: Rc>>, item: Rc| { - if (((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.inferred).clone() == None)) - && ((*item.type_annotation).clone() != None)) + if ((((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() == None)) + && (item.type_annotation.clone() != None)) { v1_rt::rc_map_insert( acc.clone(), authored_name_at(source_indices.clone(), item.clone()), Rc::new(TypeBinding { name: authored_name_at(source_indices.clone(), item.clone()), - resolved: (*item.type_annotation).clone().clone().unwrap(), + resolved: item.type_annotation.clone().clone().unwrap(), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ) @@ -13948,18 +13948,18 @@ pub fn typecheck_module( let mut __result = Vec::new(); for item in typed_items.clone().iter().cloned() { __result.push( - if (item.is_self_recursive.clone() && ((*item.body).clone() != None)) { + if (item.is_self_recursive.clone() && (item.body.clone() != None)) { Rc::new(Node { name: item.name.clone(), span: item.span.clone(), ident_span: item.ident_span.clone(), children: item.children.clone(), params: item.params.clone(), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), body: Some(annotate_descent_evidence( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), authored_name_at(source_indices.clone(), item.clone()), item.params.clone(), env.clone(), @@ -13967,12 +13967,12 @@ pub fn typecheck_module( updated_func_env.clone(), )), connective: item.connective.clone(), - transport: (*item.transport).clone(), + transport: item.transport.clone(), properties: item.properties.clone(), - type_annotation: (*item.type_annotation).clone(), + type_annotation: item.type_annotation.clone(), is_self_recursive: item.is_self_recursive.clone(), has_non_tail_self_call: item.has_non_tail_self_call.clone(), - match_pattern: (*item.match_pattern).clone(), + match_pattern: item.match_pattern.clone(), expr_data: item.expr_data.clone(), ident: None, }) @@ -14321,7 +14321,7 @@ pub fn collect_parent_envs( ), "'".to_string(), ), - span: (*imp.target_module).clone().clone().unwrap().span.clone(), + span: imp.target_module.clone().clone().unwrap().span.clone(), }), resolved_mod_name.clone(), )]), diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index e1056496101..b8089770e47 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -284,7 +284,7 @@ pub fn build_struct_field_summaries( |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); - if ((*child.inferred).clone() == None) { + if (child.inferred.clone() == None) { acc.clone() } else { { @@ -452,7 +452,7 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match (*child.inferred) + |acc: Rc>, child: Rc| match child.inferred .clone() .as_deref() .cloned() @@ -462,8 +462,8 @@ pub fn build_field_type_map( source_indices.clone(), normalize_access_type_node(ft.clone()), ); - let ft_is_type_var = if ((*ft.inferred).clone() != None) { - is_type_variable((*ft.inferred).clone().clone().unwrap()) + let ft_is_type_var = if (ft.inferred.clone() != None) { + is_type_variable(ft.inferred.clone().clone().unwrap()) } else { false }; @@ -488,7 +488,7 @@ pub fn build_type_summary( { if (((item.connective.clone() == Connective::NoConnective) || (item.connective.clone() == Connective::Arrow)) - || ((*item.transport).clone() != None)) + || (item.transport.clone() != None)) { return None; } @@ -503,7 +503,7 @@ pub fn build_type_summary( let has_fn = { let mut __found = false; for child in item.children.clone().iter().cloned() { - if match (*child.inferred).clone().as_deref().cloned() { + if match child.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.connective.clone() == Connective::Arrow) } @@ -663,7 +663,7 @@ pub fn add_emit_item_summary( let v_has_fn = { let mut __found = false; for vc in variant.children.clone().iter().cloned() { - if match (*vc.inferred).clone().as_deref().cloned() { + if match vc.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => (rt.connective.clone() == Connective::Arrow), diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 90356140623..95a6d52a3d7 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -164,26 +164,26 @@ pub fn inferred_to_outputs( pub fn item_kind(item: Rc) -> ItemKind { { let kind = if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { ItemKind::TypeItem } else { - if ((*item.transport).clone() != None) { + if (item.transport.clone() != None) { ItemKind::ServiceItem } else { - if (((*item.body).clone() != None) && ((item.uses.clone().len() as i64) > 0)) { + if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { ItemKind::FnItem } else { - if (((*item.body).clone() != None) - && ((*item.type_annotation).clone() != None)) + if ((item.body.clone() != None) + && (item.type_annotation.clone() != None)) { ItemKind::DataItem } else { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { ItemKind::FnItem } else { ItemKind::OtherItem diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 71b8b8be903..63743b2107e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -149,7 +149,7 @@ pub fn lookup_field_type_node( } } } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { lookup_field_type_node( target.clone(), @@ -237,8 +237,8 @@ pub fn resolve_scrutinee_type_node_seen( seen: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; @@ -248,9 +248,9 @@ pub fn resolve_scrutinee_type_node_seen( let normed = normalize_access_type_node(n.clone()); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) - && ((*normed.inferred).clone() != None)) + && (normed.inferred.clone() != None)) { - match (*normed.inferred).clone().as_deref().cloned() { + match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { resolve_scrutinee_type_node_seen(env.clone(), target.clone(), seen.clone()) } @@ -262,18 +262,18 @@ pub fn resolve_scrutinee_type_node_seen( { { let canonical = authored_name(env.clone(), normed.clone()); - if ((*normed.inferred).clone() != None) { + if (normed.inferred.clone() != None) { { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; - match (*normed.inferred).clone().as_deref().cloned() { + match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { if ((((authored_name(env.clone(), target.clone()) == canonical.clone()) - && ((*target.inferred).clone() == None)) + && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { @@ -305,7 +305,7 @@ pub fn resolve_scrutinee_type_node_seen( Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) == canonical.clone()) - && ((*resolved.inferred).clone() == None)) + && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) @@ -471,10 +471,10 @@ pub struct StructuralMethodLookup { } pub fn product_field_result_type(field: Rc) -> Option> { - match (*field.inferred).clone().as_deref().cloned() { + match field.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match (*rt.inferred).clone().as_deref().cloned() { + match rt.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Some(return_type.clone()), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index c4ead0b440c..4e0bf90d8ff 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -80,14 +80,14 @@ pub fn expand_scrut_from_decl( ) -> Rc { { let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = ((((*decl.inferred).clone() != None) + let has_inferred_alias = (((decl.inferred.clone() != None) && (decl.connective.clone() == Connective::NoConnective)) && ((decl.children.clone().len() as i64) == 0)); if decl_is_disj { decl.clone() } else { if has_inferred_alias { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let subst = generic_use_slot_bindings(scrut_node, env.clone()); substitute_type_slots( @@ -124,13 +124,13 @@ pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc } else { { let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = (((*decl.inferred).clone() != None) + let has_inferred_body = ((decl.inferred.clone() != None) && (decl.connective.clone() == Connective::NoConnective)); if def_is_disj { decl.clone() } else { if has_inferred_body { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_is_disj = (target.connective.clone() == Connective::Disj); @@ -165,7 +165,7 @@ pub fn expand_scrut_type_for_variant_lookup( if (is_disj || is_witness) { break scrut_node.clone(); } else { - match (*scrut_node.inferred).clone().as_deref().cloned() { + match scrut_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); scrut_node = __tco_0; @@ -384,8 +384,8 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { pub fn pattern_subject_from_node(mut n: Rc) -> Rc { loop { - let is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; @@ -394,9 +394,9 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && ((*n.inferred).clone() != None)) + && (n.inferred.clone() != None)) { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); n = __tco_0; diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index d3e82622f71..93bb2d20793 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -90,8 +90,8 @@ pub fn unit_variant_in_coproduct( } pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc { - if ((ty.connective.clone() == Connective::NoConnective) && ((*ty.inferred).clone() != None)) { - match (*ty.inferred).clone().as_deref().cloned() { + if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { + match ty.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), _ => ty.clone(), } @@ -182,16 +182,16 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc, env: Rc, module_name: S Some(resolved) => { let structural = if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred).clone().as_deref().cloned() { + match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { (*resolve_node_bounded( target.clone(), @@ -279,9 +279,9 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred).clone().as_deref().cloned() { + match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_resolved = (*resolve_node_bounded( target.clone(), @@ -461,7 +461,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { if is_container_type(n.name.clone()) { false } else { - if ((*decl.inferred).clone() != None) { + if (decl.inferred.clone() != None) { true } else { true @@ -484,8 +484,8 @@ pub fn substitute_type_slots( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_slot = (((((n.children.clone().len() as i64) == 0) && (n.connective.clone() == Connective::NoConnective)) - && ((*n.body).clone() == None)) - && ((*n.inferred).clone() == None)); + && (n.body.clone() == None)) + && (n.inferred.clone() == None)); if is_slot { match v1_rt::map_get( &slot_bindings, @@ -523,18 +523,18 @@ pub fn substitute_type_slots( children: substituted_args.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: (*child.inferred).clone(), + inferred: child.inferred.clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: child.properties.clone(), - type_annotation: (*child.type_annotation).clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: child.is_self_recursive.clone(), has_non_tail_self_call: child .has_non_tail_self_call .clone(), - match_pattern: (*child.match_pattern).clone(), + match_pattern: child.match_pattern.clone(), expr_data: child.expr_data.clone(), ident: None, }) @@ -551,7 +551,7 @@ pub fn substitute_type_slots( } __result }); - let new_inferred = match (*n.inferred).clone().as_deref().cloned() { + let new_inferred = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Some(Rc::new(InferredNode::Resolved { node: substitute_type_slots( @@ -562,7 +562,7 @@ pub fn substitute_type_slots( ), })) } - _ => (*n.inferred).clone(), + _ => n.inferred.clone(), }; Rc::new(Node { name: n.name.clone(), @@ -574,13 +574,13 @@ pub fn substitute_type_slots( inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -641,9 +641,9 @@ pub fn resolve_alias_target( pub fn is_parametric_type_alias_decl(item: Rc) -> bool { ((((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() != None)) + && (item.body.clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() != None)) } pub fn resolve_nominal_alias_rhs( @@ -691,13 +691,13 @@ pub fn resolve_nominal_alias_rhs( children: resolved_args, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -742,7 +742,7 @@ pub fn resolve_node_bounded( { let is_product = (n.connective.clone() == Connective::Conj); if is_product { - if ((*n.type_annotation).clone() != None) { + if (n.type_annotation.clone() != None) { match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( @@ -761,13 +761,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![base_resolved]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -787,7 +787,7 @@ pub fn resolve_node_bounded( let child_results = Rc::new({ let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { - __result.push(if ((*child.inferred).clone() == None) { + __result.push(if (child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: child.clone(), diagnostics: Rc::new(vec![]), @@ -820,13 +820,13 @@ pub fn resolve_node_bounded( .return_cardinality .clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: (*child.type_annotation) + type_annotation: child.type_annotation .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -863,13 +863,13 @@ pub fn resolve_node_bounded( children: resolved_children, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -912,7 +912,7 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if ((*field_child.inferred).clone() == None) + if (field_child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), @@ -970,10 +970,10 @@ pub fn resolve_node_bounded( })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), - body: (*field_child.body).clone(), - transport: (*field_child.transport).clone(), + body: field_child.body.clone(), + transport: field_child.transport.clone(), properties: v1_rt::concat(field_child.properties.clone(), rt_resolved.properties.clone()), - type_annotation: (*field_child.type_annotation).clone(), + type_annotation: field_child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1012,16 +1012,16 @@ pub fn resolve_node_bounded( children: resolved_fields.clone(), connective: variant_child.connective.clone(), params: variant_child.params.clone(), - inferred: (*variant_child.inferred).clone(), + inferred: variant_child.inferred.clone(), return_cardinality: variant_child .return_cardinality .clone(), uses: variant_child.uses.clone(), - body: (*variant_child.body).clone(), - transport: (*variant_child.transport).clone(), + body: variant_child.body.clone(), + transport: variant_child.transport.clone(), properties: variant_child.properties.clone(), - type_annotation: (*variant_child - .type_annotation) + type_annotation: variant_child + .type_annotation .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -1057,13 +1057,13 @@ pub fn resolve_node_bounded( children: resolved_variants, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1183,12 +1183,12 @@ pub fn resolve_node_bounded( } }, ); - let is_parameterized_alias = ((((*decl.inferred).clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { { - let alias_target = match (*decl.inferred).clone().as_deref().cloned() { + let alias_target = match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { substitute_type_slots( target.clone(), @@ -1214,16 +1214,16 @@ pub fn resolve_node_bounded( children: (*target_result.resolved).clone().children.clone(), connective: (*target_result.resolved).clone().connective.clone(), params: Rc::new(vec![]), - inferred: (*(*target_result.resolved).clone().inferred).clone(), + inferred: (*target_result.resolved).clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: (*target_result.resolved).clone().properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1239,13 +1239,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: (*target_result.resolved).clone().properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1280,16 +1280,16 @@ pub fn resolve_node_bounded( children: substituted_children, connective: decl.connective.clone(), params: Rc::new(vec![]), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: decl.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1306,13 +1306,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: decl.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -1354,7 +1354,7 @@ pub fn resolve_node_bounded( ); let val_resolved = (*val_result.resolved).clone(); let val_diags = val_result.diagnostics.clone(); - let key_param_name = if ((*key_child_node.inferred).clone() != None) { + let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { @@ -1362,7 +1362,7 @@ pub fn resolve_node_bounded( None => authored_name(env.clone(), key_child_node.clone()), } }; - let val_param_name = if ((*val_child_node.inferred).clone() != None) { + let val_param_name = if (val_child_node.inferred.clone() != None) { authored_name(env.clone(), val_child_node.clone()) } else { match container_param_name(type_name.clone(), 1) { @@ -1422,13 +1422,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_key_child, resolved_val_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1453,7 +1453,7 @@ pub fn resolve_node_bounded( ); let el_resolved = (*el_result.resolved).clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if ((*child_node.inferred).clone() + let el_param_name = if (child_node.inferred.clone() != None) { authored_name(env.clone(), child_node.clone()) @@ -1495,13 +1495,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1520,7 +1520,7 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = match (*n.inferred) + let n_target_is_coproduct_container = match n.inferred .clone() .as_deref() .cloned() @@ -1556,9 +1556,9 @@ pub fn resolve_node_bounded( == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred) + match resolved.inferred .clone() .as_deref() .cloned() @@ -1616,10 +1616,10 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if ((*n.inferred).clone() != None) + let n_is_error = if (n.inferred.clone() != None) { is_compiler_error( - (*n.inferred).clone().clone().unwrap(), + n.inferred.clone().clone().unwrap(), ) } else { false @@ -1627,9 +1627,9 @@ pub fn resolve_node_bounded( let n_is_callable = ((n.params.clone().len() as i64) > 0); let n_is_type_var = - if ((*n.inferred).clone() != None) { + if (n.inferred.clone() != None) { is_type_variable( - (*n.inferred).clone().clone().unwrap(), + n.inferred.clone().clone().unwrap(), ) } else { false @@ -1830,13 +1830,13 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), - body: (*authored_type.body).clone(), - transport: (*authored_type.transport).clone(), + body: authored_type.body.clone(), + transport: authored_type.transport.clone(), properties: type_resolved.properties.clone(), - type_annotation: (*authored_type.type_annotation).clone(), + type_annotation: authored_type.type_annotation.clone(), is_self_recursive: authored_type.is_self_recursive.clone(), has_non_tail_self_call: authored_type.has_non_tail_self_call.clone(), - match_pattern: (*authored_type.match_pattern).clone(), + match_pattern: authored_type.match_pattern.clone(), expr_data: authored_type.expr_data.clone(), ident: None, }) @@ -2102,7 +2102,7 @@ pub fn resolve_transport_binding( transport: make_transport_node( resolved_props, resolved_children, - (*transport.body).clone(), + transport.body.clone(), transport.span.clone(), ), diagnostics: v1_rt::concat(v1_rt::concat(prop_diags, child_diags), body_diags), @@ -2207,7 +2207,7 @@ pub fn resolve_expr_types( descent_evidence: de.clone(), }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2302,7 +2302,7 @@ pub fn resolve_expr_types( method_semantics: ms.clone(), }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2371,7 +2371,7 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match (*child.match_pattern).clone() { + match child.match_pattern.clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, @@ -2400,7 +2400,7 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match (*child.match_pattern).clone() { + match child.match_pattern.clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, @@ -2436,7 +2436,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprMatch), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2478,7 +2478,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprIf), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2516,7 +2516,7 @@ pub fn resolve_expr_types( let_binding_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprLet), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2576,7 +2576,7 @@ pub fn resolve_expr_types( parent_enum: pe.clone(), }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2613,7 +2613,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprListLit), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2646,7 +2646,7 @@ pub fn resolve_expr_types( algebra_field: af.clone(), }), Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(lr.diagnostics.clone(), rr.diagnostics.clone()), @@ -2664,7 +2664,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), Rc::new(vec![(*r.expr).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2691,7 +2691,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprLambda), v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2748,7 +2748,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2784,7 +2784,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprBlock), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2812,7 +2812,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprCast), Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(r.diagnostics.clone(), tr.diagnostics.clone()), @@ -2839,7 +2839,7 @@ pub fn resolve_expr_types( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2870,7 +2870,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprIndex), Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(br.diagnostics.clone(), ir.diagnostics.clone()), @@ -2913,7 +2913,7 @@ pub fn resolve_expr_types( (*sr.expr).clone(), (*er.expr).clone(), ]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2936,7 +2936,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprReturn), Rc::new(vec![(*r.expr).clone()]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -3026,7 +3026,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3118,7 +3118,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let ret_result = if is_parametric_type_alias_decl(item.clone()) { - match (*item.inferred).clone().as_deref().cloned() { + match item.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: authored_rhs, .. }) => resolve_nominal_alias_rhs( @@ -3127,17 +3127,17 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) module_name.clone(), ), _ => resolve_optional_node( - (*item.inferred).clone(), + item.inferred.clone(), env.clone(), module_name.clone(), ), } } else { - resolve_optional_node((*item.inferred).clone(), env.clone(), module_name.clone()) + resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; let ret_resolved = (*ret_result.resolved).clone(); let ret_diags = ret_result.diagnostics.clone(); - let resolved_ret = if ((*item.inferred).clone() == None) { + let resolved_ret = if (item.inferred.clone() == None) { None } else { Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) @@ -3167,59 +3167,59 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) } __result }); - let body_resolved = if ((*item.body).clone() == None) { + let body_resolved = if (item.body.clone() == None) { Rc::new(ExprResolveResult { expr: item.clone(), diagnostics: Rc::new(vec![]), }) } else { resolve_expr_types( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_body = if ((*item.body).clone() == None) { + let resolved_body = if (item.body.clone() == None) { None } else { Some((*body_resolved.expr).clone()) }; - let body_diags = if ((*item.body).clone() == None) { + let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) } else { body_resolved.diagnostics.clone() }; - let anno_resolved = if ((*item.type_annotation).clone() == None) { + let anno_resolved = if (item.type_annotation.clone() == None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), }) } else { resolve_node( - (*item.type_annotation).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_anno = if ((*item.type_annotation).clone() == None) { + let resolved_anno = if (item.type_annotation.clone() == None) { None } else { Some((*anno_resolved.resolved).clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); - let transport_resolved = if ((*item.transport).clone() == None) { + let transport_resolved = if (item.transport.clone() == None) { Rc::new(TransportResolveResult { transport: local_transport_node(no_span()), diagnostics: Rc::new(vec![]), }) } else { resolve_transport_binding( - (*item.transport).clone().clone().unwrap(), + item.transport.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_transport = if ((*item.transport).clone() == None) { + let resolved_transport = if (item.transport.clone() == None) { None } else { Some((*transport_resolved.transport).clone()) @@ -3251,7 +3251,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let child_results = if ((item.connective.clone() == Connective::Conj) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3276,16 +3276,16 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: child.children.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: (*child.inferred).clone(), + inferred: child.inferred.clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), (*tr.resolved).clone().properties.clone(), ), - type_annotation: (*child.type_annotation).clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3300,7 +3300,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }) } else { if ((item.connective.clone() == Connective::Disj) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3332,18 +3332,18 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: field.children.clone(), connective: field.connective.clone(), params: field.params.clone(), - inferred: (*field.inferred).clone(), + inferred: field.inferred.clone(), return_cardinality: field .return_cardinality .clone(), uses: field.uses.clone(), - body: (*field.body).clone(), - transport: (*field.transport).clone(), + body: field.body.clone(), + transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), (*tr.resolved).clone().properties.clone(), ), - type_annotation: (*field.type_annotation).clone(), + type_annotation: field.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3378,13 +3378,13 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: resolved_fields.clone(), connective: variant.connective.clone(), params: variant.params.clone(), - inferred: (*variant.inferred).clone(), + inferred: variant.inferred.clone(), return_cardinality: variant.return_cardinality.clone(), uses: variant.uses.clone(), - body: (*variant.body).clone(), - transport: (*variant.transport).clone(), + body: variant.body.clone(), + transport: variant.transport.clone(), properties: variant.properties.clone(), - type_annotation: (*variant.type_annotation).clone(), + type_annotation: variant.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 7e67bf3ddb2..8d0917f731a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -213,12 +213,12 @@ pub fn expand_transitive_services_once( let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { - let has_no_body = ((*item.body).clone() == None); + let has_no_body = (item.body.clone() == None); if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names((*item.body).clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), @@ -414,7 +414,7 @@ pub fn service_op_entry( Rc::new(OpEntry { name: authored_name_at(source_indices.clone(), child.clone()), outputs: inferred_to_outputs( - (*child.inferred).clone(), + child.inferred.clone(), child.span.clone(), source_indices.clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index f42fbef7d98..5d4fde8c998 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -99,10 +99,10 @@ pub fn collect_func_call_edges( let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( - (*if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) { + (*if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { collect_calls_in_expr( authored_name_at(source_indices.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), local_func_set.clone(), source_indices.clone(), ) @@ -226,7 +226,7 @@ pub fn declared_to_resolved(dsig: Rc) -> Rc { Rc::new(ResolvedFuncSig { name: dsig.name.clone(), params: dsig.params.clone(), - inferred: (*dsig.inferred).clone().clone().unwrap(), + inferred: dsig.inferred.clone().clone().unwrap(), is_async: dsig.is_async.clone(), output_provenance: dsig.output_provenance.clone(), variant_provenance: dsig.variant_provenance.clone(), @@ -243,7 +243,7 @@ pub fn merge_remaining_declared( .fold( resolved, |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -277,7 +277,7 @@ pub fn topo_resolve_loop( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -358,7 +358,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -394,7 +394,7 @@ pub fn topo_resolve_loop( cycle_accum.signatures.clone(), |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -427,7 +427,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -498,7 +498,7 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { __result.push(item); } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 35a27dd0431..74bdb302d18 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -83,14 +83,14 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn resolved_type(n: Rc) -> Rc { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } } pub fn child_type_node(ch: Rc) -> Rc { - if ((*ch.inferred).clone() != None) { + if (ch.inferred.clone() != None) { resolved_type(ch.clone()) } else { ch.clone() @@ -170,16 +170,16 @@ pub fn reground_alias_carrier_identity( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -201,16 +201,16 @@ pub fn structural_carrier_template_name( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -242,7 +242,7 @@ pub fn is_fully_resolved( source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_is_type_var = match (*n.inferred).clone() { + let self_is_type_var = match n.inferred.clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -752,16 +752,16 @@ pub fn enrich_base_with_fields( children: fields, connective: Connective::Conj, params: base.params.clone(), - inferred: (*base.inferred).clone(), + inferred: base.inferred.clone(), return_cardinality: base.return_cardinality.clone(), uses: base.uses.clone(), - body: (*base.body).clone(), - transport: (*base.transport).clone(), + body: base.body.clone(), + transport: base.transport.clone(), properties: base.properties.clone(), - type_annotation: (*base.type_annotation).clone(), + type_annotation: base.type_annotation.clone(), is_self_recursive: base.is_self_recursive.clone(), has_non_tail_self_call: base.has_non_tail_self_call.clone(), - match_pattern: (*base.match_pattern).clone(), + match_pattern: base.match_pattern.clone(), expr_data: base.expr_data.clone(), ident: None, }) @@ -1312,8 +1312,8 @@ pub fn apply_type_substitution( for ch in receiver.children.clone().iter().cloned() { if !({ let inner = child_type_node(ch.clone()); - if ((*inner.inferred).clone() != None) { - is_type_variable((*inner.inferred).clone().clone().unwrap()) + if (inner.inferred.clone() != None) { + is_type_variable(inner.inferred.clone().clone().unwrap()) } else { ((inner.ident_span.clone() == None) || !is_kernel_type(authored_name_at( @@ -1643,7 +1643,7 @@ pub fn callable_inferred(n: Rc) -> Rc { { let is_callable = ((n.params.clone().len() as i64) > 0); if is_callable { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: ret, .. }) => ret.clone(), None => error_type(), _ => error_type(), @@ -1657,7 +1657,7 @@ pub fn callable_inferred(n: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if (((*n.type_annotation).clone() != None) && has_structure) { + let unwrapped = if ((n.type_annotation.clone() != None) && has_structure) { n.children.clone().first().cloned() } else { None @@ -1686,7 +1686,7 @@ pub fn node_type_shape( let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_leaf { { - let __is_named_ref = match (*n.inferred).clone().as_deref().cloned() { + let __is_named_ref = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -1797,23 +1797,23 @@ pub fn node_type_compatible( mut source_indices: Rc>>, ) -> bool { loop { - let left_err = if ((*left.inferred).clone() != None) { - is_compiler_error((*left.inferred).clone().clone().unwrap()) + let left_err = if (left.inferred.clone() != None) { + is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if ((*right.inferred).clone() != None) { - is_compiler_error((*right.inferred).clone().clone().unwrap()) + let right_err = if (right.inferred.clone() != None) { + is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if ((*left.inferred).clone() != None) { - is_type_variable((*left.inferred).clone().clone().unwrap()) + let left_tv = if (left.inferred.clone() != None) { + is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if ((*right.inferred).clone() != None) { - is_type_variable((*right.inferred).clone().clone().unwrap()) + let right_tv = if (right.inferred.clone() != None) { + is_type_variable(right.inferred.clone().clone().unwrap()) } else { false }; @@ -2025,23 +2025,23 @@ pub fn node_type_equals( source_indices: Rc>>, ) -> bool { { - let left_err = if ((*left.inferred).clone() != None) { - is_compiler_error((*left.inferred).clone().clone().unwrap()) + let left_err = if (left.inferred.clone() != None) { + is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if ((*right.inferred).clone() != None) { - is_compiler_error((*right.inferred).clone().clone().unwrap()) + let right_err = if (right.inferred.clone() != None) { + is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if ((*left.inferred).clone() != None) { - is_type_variable((*left.inferred).clone().clone().unwrap()) + let left_tv = if (left.inferred.clone() != None) { + is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if ((*right.inferred).clone() != None) { - is_type_variable((*right.inferred).clone().clone().unwrap()) + let right_tv = if (right.inferred.clone() != None) { + is_type_variable(right.inferred.clone().clone().unwrap()) } else { false }; @@ -2291,7 +2291,7 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match (*left.inferred) + match left.inferred .clone() .as_deref() .cloned() @@ -2299,7 +2299,7 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match (*right.inferred) + }) => match right.inferred .clone() .as_deref() .cloned() @@ -2316,7 +2316,7 @@ pub fn node_type_equals_core( _ => false, }, None => { - ((*right.inferred).clone() == None) + (right.inferred.clone() == None) } _ => false, } @@ -2342,18 +2342,18 @@ pub fn node_type_deps( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; if n_is_type_var { return Rc::new(vec![]); } - let __is_named_ref = if ((*n.inferred).clone() == None) { + let __is_named_ref = if (n.inferred.clone() == None) { false } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -2369,7 +2369,7 @@ pub fn node_type_deps( let has_structure = (n.connective.clone() != Connective::NoConnective); let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_named_ref { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Rc::new(vec![authored_name_at(source_indices.clone(), rt.clone())]) } @@ -2381,12 +2381,12 @@ pub fn node_type_deps( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.extend( - (*match (*child.inferred).clone().as_deref().cloned() { + (*match child.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } _ => { - if ((*child.inferred).clone() == None) { + if (child.inferred.clone() == None) { node_type_deps(child.clone(), source_indices.clone()) } else { Rc::new(vec![]) @@ -2400,8 +2400,8 @@ pub fn node_type_deps( __result }) } else { - if ((*n.inferred).clone() != None) { - match (*n.inferred).clone().as_deref().cloned() { + if (n.inferred.clone() != None) { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } @@ -2639,14 +2639,14 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match (*(*m.field_node).clone().inferred) + Some(m) => match (*m.field_node).clone().inferred .clone() .as_deref() .cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match (*rt.inferred).clone().as_deref().cloned() { + match rt.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Rc::new(BinOpInferred { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index b167a2cd12c..e0740a56f2b 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -32,7 +32,7 @@ pub fn check_bare_containers( source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let has_structure = ((match (*n.body).clone() { + let has_structure = ((match n.body.clone() { Some(_) => true, None => false, } || ((n.uses.clone().len() as i64) > 0)) @@ -98,13 +98,13 @@ pub fn check_bare_containers( } __result }); - let type_ann_diags = match (*n.type_annotation).clone() { + let type_ann_diags = match n.type_annotation.clone() { Some(ta) => { check_bare_containers(ta.clone(), module_name.clone(), source_indices.clone()) } None => Rc::new(vec![]), }; - let body_diags = match (*n.body).clone() { + let body_diags = match n.body.clone() { Some(b) => { check_bare_containers(b.clone(), module_name.clone(), source_indices.clone()) } @@ -113,7 +113,7 @@ pub fn check_bare_containers( let inferred_diags = if ((n.params.clone().len() as i64) > 0) { Rc::new(vec![]) } else { - match (*n.inferred).clone() { + match n.inferred.clone() { Some(inf) => match (*inf.clone()).clone() { InferredNode::Resolved { node: rn, .. } => check_bare_containers( rn.clone(), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index f4200b72527..0c41f844575 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -1163,13 +1163,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 8cba6f4e406..c1414cba6ac 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -1949,7 +1949,7 @@ pub fn is_conj_with_children(n: Rc) -> bool { } pub fn child_inferred_or_empty(ch: Rc) -> Rc { - match (*ch.inferred).clone().as_deref().cloned() { + match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } @@ -1964,7 +1964,7 @@ pub fn node_inferred_to_outputs( let all_children_typed = { let mut __all = true; for ch in rt.children.clone().iter().cloned() { - if !(match (*ch.inferred).clone().as_deref().cloned() { + if !(match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }) { @@ -1982,7 +1982,7 @@ pub fn node_inferred_to_outputs( authored_name_at(source_indices.clone(), ch.clone()), child_inferred_or_empty(ch.clone()), Cardinality::Required, - (*ch.body).clone(), + ch.body.clone(), None, ch.span.clone(), node_name_span(ch.clone()), @@ -2596,7 +2596,7 @@ pub fn parse_item_prefix( let tokens = ret_result.tokens.clone(); let ctx = ret_result.ctx.clone(); let missing_required_ret = (form.return_required.clone() - && match (*ret_result.inferred).clone() { + && match ret_result.inferred.clone() { Some(_) => false, None => true, }); @@ -2638,7 +2638,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: (*ret_result.inferred).clone(), + inferred: ret_result.inferred.clone(), uses: Rc::new(vec![]), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -2650,7 +2650,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: (*ret_result.inferred).clone(), + inferred: ret_result.inferred.clone(), uses: uses_result.uses.clone(), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -4954,16 +4954,16 @@ pub fn maybe_optional( children: te.children.clone(), connective: te.connective.clone(), params: te.params.clone(), - inferred: (*te.inferred).clone(), + inferred: te.inferred.clone(), return_cardinality: Cardinality::CardOptional, uses: te.uses.clone(), - body: (*te.body).clone(), - transport: (*te.transport).clone(), + body: te.body.clone(), + transport: te.transport.clone(), properties: te.properties.clone(), - type_annotation: (*te.type_annotation).clone(), + type_annotation: te.type_annotation.clone(), is_self_recursive: te.is_self_recursive.clone(), has_non_tail_self_call: te.has_non_tail_self_call.clone(), - match_pattern: (*te.match_pattern).clone(), + match_pattern: te.match_pattern.clone(), expr_data: te.expr_data.clone(), ident: None, }); @@ -5325,7 +5325,7 @@ pub fn parse_fn_after_kw( err: ret.err.clone(), }); } - let inferred = (*ret.inferred).clone(); + let inferred = ret.inferred.clone(); let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); let r = parse_block(skip_newlines(tokens.clone()), ctx.clone()); @@ -5376,7 +5376,7 @@ pub fn parse_fn_body_from_prefix( let name_span = prefix.name_span.clone(); let type_params = prefix.type_params.clone(); let params = prefix.params.clone(); - let inferred = (*prefix.inferred).clone(); + let inferred = prefix.inferred.clone(); let ctx = prefix.ctx.clone(); let all_params = v1_rt::concat(type_params, params); let named_dummy = Rc::new(Node { @@ -5638,7 +5638,7 @@ pub fn parse_block_item_after_kw( err: ret.err.clone(), }); } - let inferred = (*ret.inferred).clone(); + let inferred = ret.inferred.clone(); let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); let uses_r = if form.has_uses.clone() { @@ -5709,7 +5709,7 @@ pub fn parse_block_body_from_prefix( let name = prefix.name.clone(); let name_span = prefix.name_span.clone(); let params = prefix.params.clone(); - let inferred = (*prefix.inferred).clone(); + let inferred = prefix.inferred.clone(); let uses = prefix.uses.clone(); let ctx = prefix.ctx.clone(); let named_dummy = Rc::new(Node { @@ -5782,7 +5782,7 @@ pub fn parse_no_body_from_prefix( ident_span: Some(prefix.name_span.clone()), children: Rc::new(vec![]), params: prefix.params.clone(), - inferred: (*prefix.inferred).clone(), + inferred: prefix.inferred.clone(), return_cardinality: Cardinality::Required, uses: prefix.uses.clone(), body: None, @@ -5941,17 +5941,17 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc service_config_properties( (*cfg.endpoint).clone(), - (*cfg.auth).clone(), - (*cfg.auth_input).clone(), - (*cfg.auth_source).clone(), - (*cfg.rate_limit).clone(), - (*cfg.retry).clone(), + cfg.auth.clone(), + cfg.auth_input.clone(), + cfg.auth_source.clone(), + cfg.rate_limit.clone(), + cfg.retry.clone(), ), None => Rc::new(vec![]), }; @@ -7313,7 +7313,7 @@ pub fn parse_operation_v2_inline( } let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); - let outputs = match (*ret.inferred).clone().as_deref().cloned() { + let outputs = match ret.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_inferred_to_outputs(rt.clone(), ctx.source_indices.clone()) } @@ -7435,7 +7435,7 @@ pub fn parse_operation_v1_body( r2.mock_props.clone(), r2.exit_props.clone(), r2.modifier_props.clone(), - (*r2.transport).clone(), + r2.transport.clone(), start_span.clone(), ctx.source_indices.clone(), ); @@ -8065,7 +8065,7 @@ pub fn node_to_name_str( None => v1_rt::concat(opt_prefix, effective_name.clone()), } } else { - if ((*effective_n.type_annotation).clone() != None) { + if (effective_n.type_annotation.clone() != None) { match effective_n.children.clone().first().cloned() { Some(ch) => v1_rt::concat( opt_prefix, @@ -9188,7 +9188,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc node_inferred_to_outputs( rt.clone(), ret.ctx.clone().source_indices.clone(), @@ -9953,17 +9953,17 @@ pub fn parse_constrained_assignment( ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: (*node.inferred).clone(), + inferred: node.inferred.clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: (*node.body).clone(), + body: node.body.clone(), connective: node.connective.clone(), - transport: (*node.transport).clone(), + transport: node.transport.clone(), properties: cr.constraints.clone(), - type_annotation: (*node.type_annotation).clone(), + type_annotation: node.type_annotation.clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: (*node.match_pattern).clone(), + match_pattern: node.match_pattern.clone(), expr_data: node.expr_data.clone(), ident: None, }); @@ -10048,7 +10048,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: (*node.inferred).clone(), + inferred: node.inferred.clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: (*node.body).clone(), + body: node.body.clone(), connective: node.connective.clone(), - transport: (*node.transport).clone(), + transport: node.transport.clone(), properties: cr.constraints.clone(), - type_annotation: (*node.type_annotation).clone(), + type_annotation: node.type_annotation.clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: (*node.match_pattern).clone(), + match_pattern: node.match_pattern.clone(), expr_data: node.expr_data.clone(), ident: None, }); @@ -12051,7 +12051,7 @@ pub fn parse_match_arm(tokens: Rc, ctx: Rc) -> Rc Date: Sun, 5 Jul 2026 03:43:46 +0000 Subject: [PATCH 11/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_compile.rs | 17 +- src/v1/stage0/src/v1_compiler_complexity.rs | 307 +- src/v1/stage0/src/v1_compiler_emit.rs | 101 +- .../src/v1_compiler_emit_core_support.rs | 17 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 28 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 32 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 148 +- src/v1/stage0/src/v1_compiler_infer.rs | 4068 ++++++++--------- src/v1/stage0/src/v1_compiler_infer_access.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 9 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 3 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 248 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 43 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 46 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 57 +- .../stage0/src/v1_compiler_infer_patterns.rs | 238 +- .../stage0/src/v1_compiler_infer_resolve.rs | 434 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 3 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 60 +- src/v1/stage0/src/v1_compiler_normalize.rs | 7 +- src/v1/stage0/src/v1_compiler_parse.rs | 340 +- src/v1/stage0/src/v1_rt.rs | 40 + 23 files changed, 2968 insertions(+), 3286 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index bd68c32eb6e..1c1e8ecd469 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -167,7 +167,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - (*m.type_env).clone().source_indices.clone(), + m.type_env.clone().source_indices.clone(), item.clone(), ), body: item.body.clone().clone().unwrap(), @@ -232,12 +232,12 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) } @@ -1894,7 +1891,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref((*module.module).clone(), key_to_id.clone()), + serialize_node_ref(module.module.clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2431,7 +2428,7 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - (*m.module).clone(), + m.module.clone(), )); } __result diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 182e9e48cc2..368276eb3bc 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -1372,7 +1372,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1393,7 +1393,7 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), empty_parser_progress_env(), proven.clone(), @@ -1671,7 +1671,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -2207,11 +2207,7 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names( - (*entry.body).clone(), - entry.params.clone(), - si.clone(), - ), + recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), ), None => acc.clone(), }, @@ -5757,7 +5753,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), local_func_set.clone(), si.clone(), )) @@ -6478,7 +6474,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - (*entry.body).clone(), + entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6486,7 +6482,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - (*entry.body).clone(), + entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6579,8 +6575,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6654,15 +6650,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6736,8 +6732,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6785,7 +6781,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6840,7 +6836,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6879,7 +6875,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - (*entry.body).clone(), + entry.body.clone(), name.clone(), si.clone(), ); @@ -7216,12 +7212,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7550,7 +7546,7 @@ pub fn resolve_callback_cost( fn_ref.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7559,7 +7555,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7570,7 +7566,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7583,7 +7579,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -7616,7 +7612,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - (*body_result.summary.clone().work).clone(), + body_result.summary.clone().work.clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7635,12 +7631,12 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: (*body_result.table).clone(), + table: body_result.table.clone(), }) } CostShape::ShapeSortBody => { @@ -7650,7 +7646,7 @@ pub fn cost_of_method_by_shape( la.clone(), func_index, scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7662,14 +7658,14 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { base: 2, argument: size.clone(), }); - let per_comparison = (*key_result.summary.clone().work).clone(); + let per_comparison = key_result.summary.clone().work.clone(); let sort_work = Rc::new(CostExpr::CostMul { left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, @@ -7684,12 +7680,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: (*key_result.table).clone(), + table: key_result.table.clone(), }) } CostShape::ShapeLinearScan => { @@ -7712,28 +7708,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -8557,7 +8553,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - (*lr.table).clone(), + lr.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8565,23 +8561,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*lr.summary.clone().work).clone(), + lr.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().work).clone(), + rr.summary.clone().work.clone(), ), ), span: cost_seq( - (*lr.summary.clone().span).clone(), + lr.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().span).clone(), + rr.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*rr.table).clone(), + table: rr.table.clone(), }) } ExprData::ExprCall { .. } => { @@ -8614,14 +8610,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*callee_result.table).clone(), + table: callee_result.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8629,34 +8625,34 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), span: cost_seq( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*args_result.summary.clone().work).clone(), - (*callee_result.summary.clone().work).clone(), + args_result.summary.clone().work.clone(), + callee_result.summary.clone().work.clone(), ), span: cost_seq( - (*args_result.summary.clone().span).clone(), - (*callee_result.summary.clone().span).clone(), + args_result.summary.clone().span.clone(), + callee_result.summary.clone().span.clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } ExprData::ExprMethodCall { @@ -8703,17 +8699,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), })), } } @@ -8731,14 +8727,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8746,40 +8742,40 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), span: cost_seq( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().work).clone(), + args_result.summary.clone().work.clone(), ), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().span).clone(), + args_result.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } } @@ -8805,7 +8801,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*s_r.table).clone(), + table: s_r.table.clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8814,7 +8810,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*(*acc.result).clone().table).clone(), + acc.result.clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8823,21 +8819,21 @@ pub fn cost_of_expr( result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_par( - (*(*acc.result).clone().summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), span: cost_par( - (*(*acc.result).clone().summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: (*ar.table).clone(), + table: ar.table.clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![(*ar.summary.clone().work).clone()]), + Rc::new(vec![ar.summary.clone().work.clone()]), ), }) }, @@ -8845,29 +8841,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*s_r.summary.clone().work).clone(), + s_r.summary.clone().work.clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - (*s_r.summary.clone().span).clone(), - Rc::new(vec![ - (*(*arms_accum.result).clone().summary.clone().span).clone() - ]), + s_r.summary.clone().span.clone(), + Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), ), - output_size: (*arms_accum.result) + output_size: arms_accum + .result .clone() .summary .clone() .output_size .clone(), - certainty: (*arms_accum.result) - .clone() - .summary - .clone() - .certainty - .clone(), + certainty: arms_accum.result.clone().summary.clone().certainty.clone(), }), - table: (*(*arms_accum.result).clone().table).clone(), + table: arms_accum.result.clone().table.clone(), }) } ExprData::ExprIf => { @@ -8886,7 +8876,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8897,14 +8887,14 @@ pub fn cost_of_expr( eb.clone(), func_index.clone(), scc_index.clone(), - (*t_r.table).clone(), + t_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: (*er.table).clone(), + table: er.table.clone(), }) } None => Rc::new(SummaryResult { @@ -8914,29 +8904,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*t_r.table).clone(), + table: t_r.table.clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*c_r.summary.clone().work).clone(), + c_r.summary.clone().work.clone(), Rc::new(vec![ - (*t_r.summary.clone().work).clone(), - (*e_result.summary.clone().work).clone(), + t_r.summary.clone().work.clone(), + e_result.summary.clone().work.clone(), ]), ), span: cost_conditional( - (*c_r.summary.clone().span).clone(), + c_r.summary.clone().span.clone(), Rc::new(vec![ - (*t_r.summary.clone().span).clone(), - (*e_result.summary.clone().span).clone(), + t_r.summary.clone().span.clone(), + e_result.summary.clone().span.clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: (*e_result.table).clone(), + table: e_result.table.clone(), }) } ExprData::ExprLet => { @@ -8956,7 +8946,7 @@ pub fn cost_of_expr( b.clone(), func_index.clone(), scc_index.clone(), - (*v_r.table).clone(), + v_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8964,17 +8954,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*v_r.summary.clone().work).clone(), - (*b_r.summary.clone().work).clone(), + v_r.summary.clone().work.clone(), + b_r.summary.clone().work.clone(), ), span: cost_seq( - (*v_r.summary.clone().span).clone(), - (*b_r.summary.clone().span).clone(), + v_r.summary.clone().span.clone(), + b_r.summary.clone().span.clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: (*b_r.table).clone(), + table: b_r.table.clone(), }) } None => v_r.clone(), @@ -8995,7 +8985,7 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9003,17 +8993,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*acc.summary.clone().work).clone(), - (*sr.summary.clone().work).clone(), + acc.summary.clone().work.clone(), + sr.summary.clone().work.clone(), ), span: cost_seq( - (*acc.summary.clone().span).clone(), - (*sr.summary.clone().span).clone(), + acc.summary.clone().span.clone(), + sr.summary.clone().span.clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: (*sr.table).clone(), + table: sr.table.clone(), }) }, ), @@ -9033,23 +9023,22 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = - cost_loop(binder, size.clone(), (*bd_r.summary.clone().work).clone()); + let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*c_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: (*bd_r.table).clone(), + table: bd_r.table.clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9067,7 +9056,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9075,17 +9064,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), span: cost_seq( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9104,7 +9093,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9112,17 +9101,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), span: cost_seq( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9180,7 +9169,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - (*entry.body).clone(), + entry.body.clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9199,12 +9188,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), scc_members.clone(), ), span: bounded_scc_cost( t.clone(), - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9214,12 +9203,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), func_name.clone(), ), span: bounded_recursive_cost( t.clone(), - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9230,16 +9219,13 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost((*bounded.work).clone()), - span: simplify_cost((*bounded.span).clone()), + work: simplify_cost(bounded.work.clone()), + span: simplify_cost(bounded.span.clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = cache_summary( - (*result.table).clone(), - func_name.clone(), - simplified.clone(), - ); + let final_table = + cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); Rc::new(SummaryResult { summary: simplified.clone(), table: final_table, @@ -9605,7 +9591,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9634,7 +9620,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - (*entry.body).clone(), + entry.body.clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9734,13 +9720,12 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) - > 0) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9813,12 +9798,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity((*sr.summary.clone().work).clone()); + let class_str = classify_complexity(sr.summary.clone().work.clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9826,12 +9811,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { + let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason((*sr.summary.clone().work).clone()), + reason: extract_unknown_reason(sr.summary.clone().work.clone()), span: entry.span.clone(), })]), ) @@ -9860,7 +9845,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - (*sr.table).clone(), + sr.table.clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index b79a0b20400..e7c5382b4eb 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -594,13 +594,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: (*typed_module.type_env).clone(), - func_env: (*typed_module.func_env).clone(), + type_env: typed_module.type_env.clone(), + func_env: typed_module.func_env.clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.type_env.clone().source_indices.clone(), + typed_module.module.clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -620,7 +620,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc, name: String, ) -> Option> { - lookup_func_sig((*scope.func_env).clone(), name) + lookup_func_sig(scope.func_env.clone(), name) } pub fn typed_named_arg_matches( @@ -672,10 +672,7 @@ pub fn order_typed_call_args( let has_unnamed = { let mut __found = false; for arg in args.clone().iter().cloned() { - if (arg_name_at( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) == None) + if (arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()) == None) { __found = true; break; @@ -694,7 +691,7 @@ pub fn order_typed_call_args( |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -710,7 +707,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), true, ) @@ -724,7 +721,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -742,7 +739,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -2544,15 +2541,12 @@ pub fn emit_shared_tco_expr( mut emit_default_return: impl Fn(Rc) -> String + Clone, ) -> String { loop { - let si = (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + let si = frame.scope.clone().type_env.clone().source_indices.clone(); + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at((*frame.expr).clone(), si) == fn_name) { + if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: (*frame.expr).clone().children.clone(), + args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2561,7 +2555,7 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value((*frame.expr).clone()); + let inner = return_value(frame.expr.clone()); { let __tco_0 = Rc::new(TcoFrame { expr: inner, @@ -2627,11 +2621,7 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr( - (*frame.expr).clone(), - frame.scope.clone(), - frame.depth.clone(), - ); + let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2645,18 +2635,15 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.expr.clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = recurse_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2683,11 +2670,11 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2808,17 +2795,14 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.expr.clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( @@ -2848,9 +2832,9 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { @@ -2952,10 +2936,7 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - (*input.scope.clone().type_env) - .clone() - .source_indices - .clone(), + input.scope.clone().type_env.clone().source_indices.clone(), ) }, |frame| { @@ -3130,7 +3111,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3230,10 +3211,10 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), @@ -3461,7 +3442,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -5264,7 +5245,7 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = (*scope.type_env).clone().source_indices.clone(); + let source_indices = scope.type_env.clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -5752,7 +5733,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5772,7 +5753,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = (*scope.type_env).clone().source_indices.clone(); + let fa_si = scope.type_env.clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 39ad3967ac0..e384a9d4951 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -585,7 +585,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )) { __result.push(p); @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -462,9 +462,9 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*typed_module.type_env).clone().source_indices.clone(); + let si = typed_module.type_env.clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( @@ -695,7 +695,7 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_go_type_def_from_connective(item.clone(), env.clone()) @@ -1141,7 +1141,7 @@ pub fn emit_go_fn_def( scope: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1255,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1388,7 +1388,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1800,7 +1800,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index af3d0bda615..ddb3cc3f4a9 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,16 +117,16 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )) { __result.push(p); @@ -187,8 +187,8 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -364,9 +364,9 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); @@ -582,7 +582,7 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_py_type_def_from_connective(item.clone(), env.clone()) @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 58ad35e2925..1f1ff4efb8b 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -2604,7 +2604,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, tm: Rc| { let module_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2660,7 +2660,7 @@ pub fn build_scoped_data_item_index( { let module_name = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2686,7 +2686,7 @@ pub fn build_scoped_data_item_index( ) }, ); - module_imports((*typed_module.module).clone()) + module_imports(typed_module.module.clone()) .iter() .cloned() .fold( @@ -3319,7 +3319,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc) -> Rc { }); let mod_filename = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3494,7 +3494,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result.push(emit_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -3502,7 +3502,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -3530,7 +3530,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for m in typed.modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -3713,10 +3713,10 @@ pub fn build_module_export_sets( |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); let exported = get_exported_names( - (*tm.module).clone(), + tm.module.clone(), (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( @@ -3747,7 +3747,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3757,7 +3757,7 @@ pub fn emit_module_full( ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.clone()).iter().cloned() { + for imp in module_imports(Rc::new(m.clone())).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), @@ -3793,12 +3793,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); let imports_str = emit_imports( - module_imports(m.clone()), + module_imports(Rc::new(m.clone())), emit_info.clone(), registry.clone(), local_type_names, @@ -3813,14 +3813,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3881,7 +3881,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3896,7 +3896,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ), "::*;".to_string(), )); @@ -3917,12 +3917,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); - let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(Rc::new(m.clone())); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3985,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4003,26 +4003,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4141,7 +4141,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>, tm: Rc| { let nm = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4154,7 +4154,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4213,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports((*tm.module).clone()), + Some(tm) => module_imports(tm.module.clone()), None => Rc::new(vec![]), } } @@ -4230,7 +4230,7 @@ pub fn module_name_from_filename( for tm in mods.clone().iter().cloned() { __result.push(authored_name_at( source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); } __result @@ -4404,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4496,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4607,7 +4607,7 @@ pub fn reexport_source_module_name_with_visited( for imp in Rc::new({ let mut __result = Vec::new(); for imp in - module_imports((*tm.module).clone()).iter().cloned() + module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4658,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()) + for imp in module_imports(tm.module.clone()) .iter() .cloned() { @@ -4926,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5183,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5219,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5679,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5708,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5847,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - (*scope.type_env).clone(), + scope.type_env.clone(), name.clone(), ) { true @@ -7232,15 +7232,15 @@ pub fn emit_typed_item( let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - env.clone(), + Rc::new(env.clone()), emit_info.clone(), wire_contract_item, data_items, @@ -7500,7 +7500,7 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), @@ -7547,7 +7547,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7599,7 +7599,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env.clone()), ) } else { if is_resource_def_item(item.clone()) { @@ -7607,7 +7607,7 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env.clone()), ) } else { v1_rt::concat( @@ -9682,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9691,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9709,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9942,7 +9942,7 @@ pub fn emit_func_def( (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -12508,7 +12508,7 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); match find_child_named( @@ -12542,7 +12542,7 @@ pub fn field_access_field_is_boxed( (*scope.type_env).clone().source_indices.clone(), )) || is_recursive_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), field_ty_name.clone(), )) } @@ -13292,7 +13292,7 @@ pub fn emit_rust_expr_record_lit( let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13838,7 +13838,7 @@ pub fn emit_discriminant_call_lowering( arg.clone(), (*scope.type_env).clone().source_indices.clone(), ); - match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { + match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13847,7 +13847,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name((*scope.type_env).clone(), child.clone()); + authored_name(scope.type_env.clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -17578,7 +17578,7 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name((*scope.type_env).clone(), struct_name) { + match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, @@ -18368,7 +18368,7 @@ pub fn emit_typed_record_lit( { let resolved_struct = (*resolve_node( resolved_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) .resolved) @@ -18787,7 +18787,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -19413,7 +19413,7 @@ pub fn emit_rust_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -19450,9 +19450,9 @@ pub fn emit_rust_tco_if( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19729,8 +19729,8 @@ pub fn emit_rust_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19903,14 +19903,14 @@ pub fn emit_rust_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -20057,7 +20057,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - (*frame.expr).clone(), + frame.expr.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -23323,7 +23323,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23646,7 +23646,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -24026,7 +24026,7 @@ pub fn collect_workflow_funcs( item.clone(), authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), registry.clone(), tm.items.clone(), @@ -24121,7 +24121,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )), None => "".to_string(), }; @@ -24142,7 +24142,7 @@ pub fn emit_main_rs( for m in modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 635072e7f2f..988059445b2 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,18 +45,20 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, - is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, - lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, - rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, + empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, + inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, + lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + put_inductive_field, put_inductive_field_cross, record_build_type_env_call, + record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; +pub use crate::v1_compiler_infer_items::{ + inferred_to_outputs, item_kind, variant_locals_from_items, +}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -107,11 +109,13 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; +// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. +use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, - VariantCollision, + InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -142,19 +146,18 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, - import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, - is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, - is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, - lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, - make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, - make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, - make_param_node, make_span, make_text_part_node, make_transport_node, map_children, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, - module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, - param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, - return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, - with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, + index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, + is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, + is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, + let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, + make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, + make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, + make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, + method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, + node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, + resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, + string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -248,7 +251,7 @@ pub fn infer_block_stmts( let is_last = (remaining_count.clone() == 1); let stmt_expected = if is_last { expected.clone() } else { None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = (*stmt_result.typed).clone(); + let stmt_typed = stmt_result.typed.clone(); let stmt_diags = stmt_result.diagnostics.clone(); let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = @@ -770,66 +773,53 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), - )) - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + Some(authored_name_at( + scope.type_env.clone().source_indices.clone(), + binding.resolved.clone(), + )) } else { None } + } else { + None } - None => None, } - } + None => None, + }, None => None, } } -pub fn variant_owner_node_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup +// via the binding edge — replaced by regen's true emission of variant_owner_node +// in the convergence commit. pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(owner) => { - let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); - if owner_is_coproduct { - if has_child_named( - owner.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(owner.clone()) - } else { - None - } - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(owner) => { + if owner.connective.clone() == Connective::Disj + && has_child_named( + owner.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) + { + Some(owner) + } else { + None } - None => None, } - } + None => None, + }, None => None, } } @@ -852,6 +842,45 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, + name: String, + scope_enum: String, + expected: Option>, +) -> Option { + match expected { + Some(exp_node) => { + let exp_name = authored_name_at( + scope.type_env.clone().source_indices.clone(), + exp_node.clone(), + ); + if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) + && (exp_name.clone() != name.clone())) + { + match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { + Some(exp_type) => { + if ((exp_type.connective.clone() == Connective::Disj) + && has_child_named( + exp_type.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { + Some(exp_name.clone()) + } else { + None + } + } + None => None, + } + } else { + None + } + } + None => None, + } +} + pub fn inference_error( message: String, span: Rc, @@ -882,15 +911,7 @@ pub fn type_mismatch_error( ) } -pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -898,30 +919,32 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { + if (expected.return_cardinality.clone() != Cardinality::CardOptional) { + return false; + } let expected_resolved = - match lookup_type_for(env, with_required_cardinality(expected.clone())) { + match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = ((expected.return_cardinality.clone() - == Cardinality::CardOptional) - && (expected_resolved.connective.clone() == Connective::Disj)); - let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) - == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); + let expected_is_optional_coproduct = + (expected_resolved.connective.clone() == Connective::Disj); + let got_shape = node_type_shape(got.clone(), source_indices.clone()); + let got_is_string = (got_shape == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - { - let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - ((ft.return_cardinality.clone() == Cardinality::CardOptional) - && (inner.connective.clone() == Connective::Disj)) + if (ft.return_cardinality.clone() != Cardinality::CardOptional) { + return false; } + let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { + Some(resolved) => resolved.clone(), + None => with_required_cardinality(ft.clone()), + }; + (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -929,14 +952,17 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { Some(direct) => direct.children.clone(), + // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), + // no name round-trip, no whole-env scan fallback. Regen replaces + // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -958,6 +984,37 @@ pub fn record_lit_expected_fields( } } +pub fn record_lit_variant_fields_from_visible_env( + env: Rc, + variant_name: String, + module_name: String, +) -> Rc>> { + let source_indices = env.source_indices.clone(); + let visible = flatten_visible_bindings(env.clone()); + for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { + let node = expand_type_for_field_access( + binding.resolved.clone(), + env.clone(), + module_name.clone(), + ); + if (node.connective.clone() == Connective::Disj) { + for arm in node.children.clone().iter().cloned() { + let arm_name = authored_name_at(source_indices.clone(), arm.clone()); + if (arm_name == variant_name.clone()) { + let expanded = + expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); + if (expanded.connective.clone() == Connective::Conj) { + return expanded.children.clone(); + } else { + return arm.children.clone(); + } + } + } + } + } + Rc::new(vec![]) +} + pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -967,7 +1024,7 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) @@ -978,7 +1035,7 @@ pub fn record_lit_expanded_from_expected( match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), expanded.clone(), ) == tn.clone()) { @@ -990,7 +1047,7 @@ pub fn record_lit_expanded_from_expected( _ => { let rt = resolved_type(exp.clone()); if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), rt.clone(), ) == tn.clone()) { @@ -1035,17 +1092,15 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - exp.clone(), - ) != tn.clone()) + if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) + != tn.clone()) { None } else { if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for((*scope.type_env).clone(), exp.clone()) { + match lookup_type_for(scope.type_env.clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1054,7 +1109,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1079,7 +1134,8 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -1129,7 +1185,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1139,24 +1195,20 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred - .clone() - .as_deref() - .cloned() - { + match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( receiver_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1171,7 +1223,7 @@ pub fn set_union_other_operand_is_resolved_non_set( node: other_type, .. }) => !node_is_set_collection( other_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1181,7 +1233,7 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { + match set_element_type_in_env(receiver_type, scope.type_env.clone()) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, } @@ -1383,7 +1435,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1391,19 +1444,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env( - receiver_type.clone(), - (*scope.type_env).clone(), - ) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) + }) => { + match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type.clone()) + } else { + with_optional_cardinality(value_type.clone()) + } } + None => resolve_builtin_call_type(func_name.clone()), } - None => resolve_builtin_call_type(func_name.clone()), - }, + } _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1413,7 +1465,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1422,12 +1475,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), (*scope.type_env).clone()) - { + match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { - bt: (*lk.ty).clone(), + bt: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1450,7 +1502,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1460,12 +1513,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( .. }) => match map_value_type_in_env( receiver_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(Tier2bBt { - bt: (*lv.ty).clone(), + bt: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1494,7 +1547,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()).inferred + Some(insert_arg) => match arg_value(insert_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1508,7 +1562,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()).inferred + Some(other_arg) => match arg_value(other_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1517,7 +1572,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: other_type, .. }) => match set_element_type_in_env( other_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, @@ -1545,7 +1600,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1566,7 +1622,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(oe) => set_element_types_mismatch( re.clone(), oe.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }, @@ -1617,7 +1673,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()).inferred + match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1628,11 +1685,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => match recv_elem.clone() { Some(_) => receiver_type.clone(), None => match operand_elem.clone() { - Some(element) => (*set_kernel_ty_from_element( - element.clone(), - ) - .ty) - .clone(), + Some(element) => { + set_kernel_ty_from_element(element.clone()) + .ty + .clone() + } None => { resolve_builtin_call_type(func_name.clone()) } @@ -1700,11 +1757,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(MethodPipeFallback { - result_ty: (*lk.ty).clone(), + result_ty: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1715,11 +1772,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(MethodPipeFallback { - result_ty: (*lv.ty).clone(), + result_ty: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1853,7 +1910,7 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - (*scope.type_env).clone(), + scope.type_env.clone(), scrutinee_type.clone(), )), PatternSubject::PatternDynamic { @@ -1884,7 +1941,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1928,7 +1985,7 @@ pub fn annotate_pattern_parent_enums( resolved_scrut.clone(), variant_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); @@ -1940,16 +1997,16 @@ pub fn annotate_pattern_parent_enums( variant_subject.clone(), field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -1988,11 +2045,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), + param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2001,8 +2058,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2020,8 +2077,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2046,8 +2103,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2086,8 +2143,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2115,7 +2172,7 @@ pub fn scope_after_stmt_node( scope.clone(), let_binding_name_at( stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2141,7 +2198,7 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(n.clone()), ), _ => "".to_string(), @@ -2151,7 +2208,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for((*scope.type_env).clone(), scrut_type_name.clone()); + inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2211,7 +2268,7 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); @@ -2224,13 +2281,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2320,7 +2377,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(a); } @@ -2341,9 +2398,9 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), - (*init_result.typed).clone(), + init_result.typed.clone(), ia.span.clone(), ia.span.clone(), ), @@ -2370,7 +2427,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2378,9 +2435,9 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2441,10 +2498,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2507,8 +2564,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2525,9 +2582,9 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -2549,8 +2606,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2616,11 +2673,8 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - (*ar.typed).clone(), + arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), + ar.typed.clone(), arg.span.clone(), arg.span.clone(), ), @@ -2657,15 +2711,16 @@ pub fn infer_expr( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let name = + expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { + // HAND-PATCH (§1c): the expected-type-as-owner-picker + // is deleted; the binding edge alone names the owner. + // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( name.clone(), Rc::new(ExprData::ExprVar { @@ -2677,7 +2732,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span.clone(), @@ -2692,7 +2747,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span.clone(), @@ -2700,7 +2755,7 @@ pub fn infer_expr( } } } - None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { + None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( @@ -2711,7 +2766,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*fsig.inferred).clone(), + node: fsig.inferred.clone(), })), span.clone(), span.clone(), @@ -2728,7 +2783,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - (*fsig.inferred).clone(), + fsig.inferred.clone(), ), })), span.clone(), @@ -2766,34 +2821,44 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let base_rt = resolved_type(base_typed.clone()); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { + if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; - let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { + let resolved_base_is_error = if resolved_base.inferred.clone() != None { is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; if resolved_base_is_error { + // HAND-PATCH (debug instrumentation, removed with regen): + // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - "error type cascade".to_string(), + format!( + "error type cascade (field '{}' on error-typed base '{}' in {})", + field_name, + authored_name_at( + scope.type_env.clone().source_indices.clone(), + base_typed.clone() + ), + scope.module_name + ), span.clone(), ), diagnostics: base_diags, @@ -2803,19 +2868,19 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { let field_summary = match field_summary_for_type( base_rt.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ) { Some(s) => Some(s.clone()), None => field_summary_for_type( resolved_base.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ), }; @@ -2839,7 +2904,7 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); if base_is_type_var { { @@ -2868,7 +2933,7 @@ pub fn infer_expr( base_rt.clone(), field_name.clone(), scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( @@ -2902,7 +2967,8 @@ pub fn infer_expr( "' on type '".to_string(), ), authored_name_at( - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -2936,13 +3002,11 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = expr_call_func_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let func_name = + expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); + let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -2974,7 +3038,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -2986,13 +3050,13 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type((*first_result.typed).clone()); + let first_type = resolved_type(first_result.typed.clone()); let elem_type = for_each_element_type_node( first_type, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - (*first_result.typed).clone(), + first_result.typed.clone(), elem_type.clone(), scope.clone(), ); @@ -3010,9 +3074,9 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), - (*first_result.typed).clone(), + first_result.typed.clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3031,7 +3095,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3045,7 +3109,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3057,7 +3121,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -3093,7 +3157,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3114,11 +3178,11 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), - (*ar.typed).clone(), + ar.typed.clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3126,9 +3190,9 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type((*ar.typed).clone()), + resolved_type(ar.typed.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.subst.clone(), ) } @@ -3140,12 +3204,9 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -3164,7 +3225,7 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3180,9 +3241,9 @@ pub fn infer_expr( { let resolved_type = match sig.clone() { Some(s) => substitute_generics( - (*s.inferred).clone(), + s.inferred.clone(), call_subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => error_type(), }; @@ -3191,7 +3252,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3206,7 +3267,7 @@ pub fn infer_expr( value_params_for_check, typed_args.clone(), call_subst.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; @@ -3242,7 +3303,7 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) @@ -3269,7 +3330,7 @@ pub fn infer_expr( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3278,7 +3339,7 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { @@ -3292,13 +3353,11 @@ pub fn infer_expr( .skip(1 as usize) .collect::>(), ); - let base_result_type = - match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) - { + let base_result_type = match method_resolution.result_type.clone() { + Some(mt) => mt.clone(), + None => error_type(), + }; + let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), @@ -3315,7 +3374,8 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3348,7 +3408,8 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3372,10 +3433,9 @@ pub fn infer_expr( }), } }; - let bridge_result_type = (*method_tv.ty).clone(); + let bridge_result_type = method_tv.ty.clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics - .clone() + let returns_receiver_self = if (method_resolution.semantics.clone() == None) { false @@ -3396,11 +3456,11 @@ pub fn infer_expr( let final_receiver = if ((returns_receiver_self && is_fully_resolved( bridge_result_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && !is_fully_resolved( first_arg_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3435,7 +3495,7 @@ pub fn infer_expr( __result.push(make_arg_node( arg_name_at( ta.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), arg_value(ta.clone()), span.clone(), @@ -3448,8 +3508,7 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics - .clone(), + method_semantics: method_resolution.semantics.clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), @@ -3475,7 +3534,7 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3539,7 +3598,7 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3607,7 +3666,7 @@ match bare_s { scope.clone(), span.clone(), ); - let bt = (*tier2b.bt).clone(); + let bt = tier2b.bt.clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3641,7 +3700,8 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if (((*binding.resolved) + if ((binding + .resolved .clone() .params .clone() @@ -3649,7 +3709,7 @@ match bare_s { as i64) > 0) { - Some((*binding.resolved).clone()) + Some(binding.resolved.clone()) } else { None } @@ -3686,7 +3746,7 @@ match bare_s { Some(ctor_result) => ctor_result.clone(), None => { let type_match = lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), func_name.clone(), ); let resolved_type = match type_match.clone() @@ -3735,21 +3795,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = (*recv_result.typed).clone(); + let recv_typed = recv_result.typed.clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( resolved_type(recv_typed.clone()), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3760,7 +3820,7 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( @@ -3780,7 +3840,7 @@ match bare_s { let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3793,7 +3853,7 @@ match bare_s { }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { @@ -3825,7 +3885,7 @@ match bare_s { None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { @@ -3839,7 +3899,7 @@ match bare_s { span.clone(), ), }; - let base_result_type = (*pipe_fb.result_ty).clone(); + let base_result_type = pipe_fb.result_ty.clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), @@ -3855,7 +3915,7 @@ match bare_s { if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { { @@ -3879,7 +3939,7 @@ match bare_s { mc_arg_types, recv_rt.clone(), mc_fold_overrides, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } } else { @@ -3900,7 +3960,7 @@ match bare_s { }), } }; - let result_type = (*method_tv_mc.ty).clone(); + let result_type = method_tv_mc.ty.clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); let method_semantics = if (method_resolution.semantics.clone() != None) { method_resolution.semantics.clone() @@ -3934,7 +3994,7 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = (*scrut_result.typed).clone(); + let scrut_typed = scrut_result.typed.clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(scrut_typed.clone()); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); @@ -3966,7 +4026,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -3984,7 +4044,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, @@ -4004,7 +4064,7 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.body_type).clone()); + __result.push(ar.body_type.clone()); } __result }); @@ -4023,14 +4083,14 @@ match bare_s { prefer_specific_type( acc, t.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); @@ -4087,8 +4147,8 @@ match bare_s { }), }; if !is_fully_resolved( - (*original.body_type).clone(), - (*scope.type_env).clone().source_indices.clone(), + original.body_type.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4121,7 +4181,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4139,7 +4199,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, @@ -4169,7 +4229,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.typed_arm).clone()); + __result.push(ar.typed_arm.clone()); } __result }); @@ -4202,7 +4262,7 @@ match bare_s { } => check_match_exhaustiveness( resolved_scrutinee.clone(), typed_arms.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), span.clone(), scope.module_name.clone(), ), @@ -4229,23 +4289,23 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = (*cond_result.typed).clone(); + let cond_typed = cond_result.typed.clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type((*then_result.typed).clone()); - let else_rt = resolved_type((*else_result.typed).clone()); + let then_rt = resolved_type(then_result.typed.clone()); + let else_rt = resolved_type(else_result.typed.clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { @@ -4253,30 +4313,30 @@ match bare_s { }; let else_result = if (!is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = (*else_result.typed).clone(); + let else_typed = else_result.typed.clone(); let else_diags = else_result.diagnostics.clone(); let then_rt = resolved_type(then_typed.clone()); let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4288,14 +4348,14 @@ match bare_s { .to_string(), node_type_shape( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), span.clone(), @@ -4333,7 +4393,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4344,7 +4404,7 @@ match bare_s { binding_kind: _, .. } => { (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), bd.clone(), ) == let_name.clone()) } @@ -4358,7 +4418,7 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { @@ -4386,7 +4446,7 @@ match bare_s { ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( let_name.clone(), @@ -4409,7 +4469,7 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), field_inits, span.clone(), @@ -4425,7 +4485,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4447,7 +4507,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push((*r.typed).clone()); + __result.push(r.typed.clone()); } __result }); @@ -4460,7 +4520,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type((*r.typed).clone()), + Some(r) => resolved_type(r.typed.clone()), None => unit_type(), } } else { @@ -4468,7 +4528,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => child_type_node(elem.clone()), @@ -4486,7 +4546,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4516,7 +4576,7 @@ match bare_s { Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: (*list_k.ty).clone(), + node: list_k.ty.clone(), })), span.clone(), ); @@ -4533,15 +4593,15 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = (*left_result.typed).clone(); + let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = (*right_result.typed).clone(); + let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), resolved_type(left_typed.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -4550,7 +4610,7 @@ match bare_s { }), Rc::new(vec![left_typed.clone(), right_typed]), Some(Rc::new(InferredNode::Resolved { - node: (*binop_info.result_type).clone(), + node: binop_info.result_type.clone(), })), span.clone(), ); @@ -4563,7 +4623,7 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = (*operand_result.typed).clone(); + let operand_typed = operand_result.typed.clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), @@ -4585,7 +4645,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4715,8 +4775,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: (*lam_scope.type_env).clone(), - func_env: (*lam_scope.func_env).clone(), + type_env: lam_scope.type_env.clone(), + func_env: lam_scope.func_env.clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4725,7 +4785,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4751,7 +4811,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), None => None, }; @@ -4800,10 +4860,7 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node( - (*r.typed).clone(), - part_node.span.clone(), - ) + make_interp_part_node(r.typed.clone(), part_node.span.clone()) } None => part_node.clone(), }, @@ -4862,7 +4919,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: (*state.last_type).clone(), + node: state.last_type.clone(), })), span.clone(), ); @@ -4891,9 +4948,9 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = (*inner_result.typed).clone(); + let inner_typed = inner_result.typed.clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( inner_typed.inferred.clone(), @@ -4922,17 +4979,17 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = (*coll_result.typed).clone(); + let coll_typed = coll_result.typed.clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( resolved_type(coll_typed.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( coll_typed.clone(), @@ -4946,7 +5003,7 @@ match bare_s { elem_provenance, ); let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( variable.clone(), @@ -4966,10 +5023,10 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = (*index_result.typed).clone(); + let index_typed = index_result.typed.clone(); let index_diags = index_result.diagnostics.clone(); let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -4982,19 +5039,17 @@ match bare_s { index_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - index_typed.inferred.clone() - } - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), + _ => base_typed.inferred.clone(), + }; let idx_inferred = match index_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5027,13 +5082,13 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = (*start_result.typed).clone(); + let start_typed = start_result.typed.clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = (*end_result.typed).clone(); + let end_typed = end_result.typed.clone(); let end_diags = end_result.diagnostics.clone(); let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -5049,7 +5104,7 @@ match bare_s { end_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) } _ => None, @@ -5058,18 +5113,18 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() - } - _ => start_typed.inferred.clone(), + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => { + match start_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + end_typed.inferred.clone() } + _ => start_typed.inferred.clone(), } - _ => base_typed.inferred.clone(), - }; + } + _ => base_typed.inferred.clone(), + }; let slc_inferred = match slice_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5106,8 +5161,8 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*inner_result.typed).clone()]), - (*inner_result.typed).clone().inferred.clone(), + Rc::new(vec![inner_result.typed.clone()]), + inner_result.typed.clone().inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -5144,8 +5199,8 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), parent_enum.clone()) { + let si = scope.type_env.clone().source_indices.clone(); + match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { Some(variant_node) => { @@ -5226,8 +5281,7 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) - { + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { if (((n.connective.clone() == Connective::NoConnective) @@ -5300,7 +5354,9 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); + let once = resolve_node(n, env.clone(), module_name.clone()) + .resolved + .clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { @@ -5589,13 +5645,17 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) } pub fn expand_type_for_field_access_with_seen( @@ -5607,38 +5667,23 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) - } + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) -} - pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) @@ -5653,7 +5698,7 @@ pub fn record_lit_alias_struct_fields( }; let expanded = expand_type_for_field_access( to_expand, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5673,8 +5718,8 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + let si = scope.type_env.clone().source_indices.clone(); + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5698,50 +5743,73 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); - match variant_owner_node(scope.clone(), type_name.clone()) { - Some(owner) => { - let mut __found = false; - for arm in owner.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { + let si = scope.type_env.clone().source_indices.clone(); + { + let mut __found = false; + for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( + scope.type_env.clone(), + ))) + .iter() + .cloned() + { + if { + let node = binding.resolved.clone(); + if (node.connective.clone() == Connective::Disj) { { - let ea = expand_type_for_field_access( - arm.clone(), - (*scope.type_env).clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) == field.clone()) { - __found = true; - break; + let mut __found = false; + for arm in node.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) + == type_name.clone()) + { + { + let ea = expand_type_for_field_access( + arm.clone(), + scope.type_env.clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) + { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) + == field.clone()) + { + __found = true; + break; + } + } + __found + } } + } else { + false + } { + __found = true; + break; } - __found } + __found } } else { false - } { - __found = true; - break; } + } { + __found = true; + break; } - __found } - None => false, + __found } } } pub fn type_has_sole_constructor(type_name: String, scope: Rc) -> bool { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5765,28 +5833,38 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { + // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is + // deleted; the ladder is instantiate -> expected -> declaration/ + // binding-edge only. Regen replaces this with the dag source's true + // emission. let struct_fields = match type_name.clone() { - Some(tn) => match record_lit_instantiated_fields( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( + Some(tn) => { + match record_lit_instantiated_fields( type_name.clone(), expected.clone(), scope.clone(), ) { Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_fields_from_expected( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields.clone(), + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => { + match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields.clone(), + None => { + record_lit_expected_fields(type_name.clone(), scope.clone()) + } + } + } }, }, - }, - }, + } + } None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), @@ -5817,7 +5895,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5853,7 +5931,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5870,11 +5948,11 @@ pub fn infer_record_lit( Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if (((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone())) + if ((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone()) || field_type_is_optional_coproduct( ft.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), )) { Some(ft.clone()) @@ -5889,7 +5967,7 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = (*ar.typed).clone(); + let ar_typed = ar.typed.clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { @@ -5897,30 +5975,28 @@ pub fn infer_record_lit( if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - (*scope.type_env).clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), ) { - { - let expected_for_shape = match lookup_type_for( - (*scope.type_env).clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) - } + let expected_for_shape = match lookup_type_for( + scope.type_env.clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape, + scope.type_env.clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + scope.type_env.clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) } else { Rc::new(vec![]) } @@ -5947,7 +6023,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push((*fir.typed_field).clone()); + __result.push(fir.typed_field.clone()); } __result }); @@ -5965,15 +6041,15 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - (*fir.typed_field).clone(), - (*scope.type_env).clone().source_indices.clone(), + fir.typed_field.clone(), + scope.type_env.clone().source_indices.clone(), ), - span: (*fir.typed_field).clone().span.clone(), - ident_span: (*fir.typed_field).clone().ident_span.clone(), + span: fir.typed_field.clone().span.clone(), + ident_span: fir.typed_field.clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), + inferred: fir.infer_result.clone().typed.clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6024,7 +6100,7 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); + lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { @@ -6034,7 +6110,7 @@ pub fn infer_record_lit( lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for((*scope.type_env).clone(), local_node.clone()) + lookup_type_for(scope.type_env.clone(), local_node.clone()) } None => None, } @@ -6054,8 +6130,8 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( - (*fir.typed_field).clone(), - (*scope.type_env).clone().source_indices.clone(), + fir.typed_field.clone(), + scope.type_env.clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6067,7 +6143,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - (*val_fir.infer_result.clone().typed).clone(), + val_fir.infer_result.clone().typed.clone(), )), None => raw_resolved, } @@ -6075,6 +6151,9 @@ pub fn infer_record_lit( } else { raw_resolved }; + // HAND-PATCH (§1c): unbound constructor literal is the typed + // UnresolvedType diagnostic, not a generic InternalError message. + // Regen replaces this with the dag source's true emission. let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( @@ -6088,7 +6167,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6173,7 +6252,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6183,7 +6262,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { Some(_) => Some(Rc::new(SizeExpr::ParamSize { @@ -6211,7 +6290,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() @@ -6260,7 +6339,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6325,7 +6404,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6336,7 +6415,7 @@ pub fn classify_collection_shrink( } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (rname == param_name.clone()) { { @@ -6381,10 +6460,7 @@ Rc::new(SubValueRelation::StrictSubValue { } => { let aname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env) - .clone() - .source_indices - .clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6592,12 +6668,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6617,7 +6693,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6652,12 +6728,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6677,7 +6753,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6721,7 +6797,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6729,7 +6805,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6756,7 +6832,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ) .iter() @@ -6795,7 +6871,7 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { @@ -6831,10 +6907,8 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = expr_method_name_at( - expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let inner_mname = + expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) @@ -6863,10 +6937,8 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = expr_var_name_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let vname = + expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6874,25 +6946,23 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = field_access_field_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let field = + field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + scope.type_env.clone().source_indices.clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -6928,8 +6998,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = - expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -6941,15 +7010,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), @@ -6961,8 +7028,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + ctx.type_env.clone().source_indices.clone(), + binding.resolved.clone(), ), None => match v1_rt::map_get( &ctx.param_names.clone(), @@ -6975,7 +7042,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) @@ -7037,7 +7104,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let iname = expr_var_name_at( inner.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -7065,7 +7132,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { if is_container_type(authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), c.clone(), ), None => "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) + && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { let fields = - inductive_fields_for((*ctx.type_env).clone(), elem.clone()); + inductive_fields_for(ctx.type_env.clone(), elem.clone()); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7177,7 +7244,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7224,7 +7291,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7248,7 +7315,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7309,7 +7376,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7367,7 +7434,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env) + ctx.type_env .clone() .source_indices .clone(), @@ -7437,7 +7504,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7484,7 +7551,7 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) @@ -7527,7 +7594,7 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) @@ -7542,7 +7609,7 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7550,7 +7617,7 @@ pub fn classify_argument( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -7571,7 +7638,7 @@ pub fn classify_argument( } } }; - let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); + let fields = inductive_fields_for(ctx.type_env.clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7609,24 +7676,22 @@ pub fn classify_argument( SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); - let from_provenance = match lookup_func_sig( - (*ctx.func_env).clone(), - callee.clone(), - ) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, + let from_provenance = + match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map.clone(), + ctx.clone(), + ), + None => None, + } } - } - None => None, - }; + None => None, + }; match from_provenance { Some(prov_rel) => prov_rel.clone(), None => { @@ -7642,7 +7707,7 @@ pub fn classify_argument( None => "".to_string(), }; let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), type_name, ); let cf = Rc::new({ @@ -7720,13 +7785,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7764,13 +7829,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7782,13 +7847,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7885,7 +7950,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7901,16 +7966,14 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7918,10 +7981,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + ctx.type_env.clone().source_indices.clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -7992,7 +8055,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8011,7 +8074,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8080,7 +8143,7 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { Some(t) => t.clone(), @@ -8118,7 +8181,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8153,11 +8216,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8205,13 +8268,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8225,7 +8288,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8236,7 +8299,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8279,7 +8342,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), @@ -8306,7 +8369,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8314,7 +8377,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -8324,7 +8387,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ); Rc::new({ @@ -8352,7 +8415,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "first".to_string()) || (mname.clone() == "last".to_string())) @@ -8368,7 +8431,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() + && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8376,9 +8439,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8414,20 +8477,20 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8439,14 +8502,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: (*ic.type_env).clone(), + type_env: ic.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: (*ic.func_env).clone(), + func_env: ic.func_env.clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8462,9 +8525,9 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8476,14 +8539,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8499,11 +8562,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8512,14 +8575,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8560,10 +8623,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = let_binding_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let binding_name = + let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { @@ -8599,7 +8660,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8615,7 +8676,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }) } @@ -8623,7 +8684,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( @@ -8635,7 +8696,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }), }; @@ -8681,7 +8742,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8716,7 +8777,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8732,7 +8793,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8740,7 +8801,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8754,7 +8815,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8795,10 +8856,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = expr_method_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let mname = + expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { @@ -8810,7 +8869,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) @@ -8825,7 +8884,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let base = field_access_base(receiver.clone()); let fname = field_access_field_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8833,7 +8892,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -8862,7 +8921,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ) .iter() @@ -8888,7 +8947,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { @@ -8931,7 +8990,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); lparams .clone() @@ -8951,7 +9010,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), @@ -8971,14 +9030,14 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -8986,7 +9045,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -9007,7 +9066,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9020,7 +9079,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9067,10 +9126,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = foreach_variable_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let fe_var = + foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9081,7 +9138,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), fe_var.clone(), @@ -9091,18 +9148,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; @@ -9759,7 +9816,7 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = (*unwrapped.expr).clone(); + let terminal = unwrapped.expr.clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( terminal, @@ -9805,15 +9862,11 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { + match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*arm_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() + for fi in + arm_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9840,16 +9893,10 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { + let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*then_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { + for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9867,30 +9914,24 @@ pub fn classify_terminal_per_field( Some(else_expr) => { let else_unwrapped = unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = - match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in (*else_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() + { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -10058,13 +10099,13 @@ pub fn arm_ctx_from_variant_provenance( } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); + call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10082,8 +10123,8 @@ pub fn arm_ctx_from_variant_provenance( call_args.clone(), c.param_order.clone(), c.param_names.clone(), - (*c.type_env).clone(), - (*c.func_env).clone(), + c.type_env.clone(), + c.func_env.clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10111,7 +10152,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10119,7 +10160,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10341,7 +10382,7 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - (*sig.inferred).clone(), + sig.inferred.clone(), ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -10674,7 +10715,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10715,36 +10756,34 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = match item.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { - node: rt, .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, + let variant_prov = + match item.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: rt, + .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, + >, >, >, >, - >, - >( - ), - }; + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10759,7 +10798,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10873,7 +10912,7 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -10925,7 +10964,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -10936,7 +10975,7 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -11044,7 +11083,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); + __result.push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11076,7 +11115,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), @@ -11093,7 +11132,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), fn_return_expected, ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let inferred_ret = if (item.inferred.clone() != None) { item.inferred.clone() @@ -11103,22 +11142,22 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let is_recursive = expr_has_self_call( body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { annotate_descent_evidence( body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), item.params.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), fn_scope.locals.clone(), - (*scope.func_env).clone(), + scope.func_env.clone(), ) } else { body_typed.clone() @@ -11132,7 +11171,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push((*infer_item(c.clone(), scope.clone()).item).clone()); + .push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11149,11 +11188,11 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc has_non_tail_self_call: expr_has_non_tail_self_call( body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), true, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11176,7 +11215,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), Some(resolved_type(item.clone())), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11206,8 +11245,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { { let data_expected = if (item.type_annotation.clone() != None) { Some(item.type_annotation.clone().clone().unwrap()) @@ -11219,7 +11257,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc scope.clone(), data_expected, ); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { @@ -11256,8 +11294,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) - && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11268,8 +11305,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11305,8 +11341,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11501,13 +11536,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); + authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11537,7 +11572,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.clone(), ) } @@ -11558,7 +11593,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11575,7 +11610,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } else { @@ -11583,7 +11618,7 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) && (formal_name.clone() == record_type_name.clone())) @@ -11603,7 +11638,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11613,7 +11648,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11623,7 +11658,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11762,10 +11797,10 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps((*b.resolved).clone(), source_indices); - let is_bare_self = (((((*b.resolved).clone().connective.clone() + let deps0 = node_type_deps(b.resolved.clone(), source_indices); + let is_bare_self = ((((b.resolved.clone().connective.clone() == Connective::NoConnective) - && (((*b.resolved).clone().children.clone().len() as i64) == 0)) + && ((b.resolved.clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11832,6 +11867,14 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { + if resolved_imports.len() == 1 { + if let Some(imp) = resolved_imports.first().cloned() { + if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + return parent.type_env_cache.clone(); + } + } + return empty_type_env_cache(); + } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11844,29 +11887,58 @@ pub fn union_parent_type_env_caches( ) } -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - let is_coproduct = - ((*binding.resolved).clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - (*binding.resolved) +pub fn union_parent_variant_locals( + resolved_imports: Rc>>, + parent_index: Rc>>, +) -> Rc>> { + resolved_imports.iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, imp: Rc| match v1_rt::map_get( + &parent_index, + imp.module_path.clone(), + ) { + Some(parent) => v1_rt::rc_map_merge( + acc.clone(), + parent.type_env_cache.clone().variant_locals.clone(), + ), + None => acc.clone(), + }, + ) +} + +pub fn fold_local_coproduct_variant_locals( + bindings: Rc>>, + imported_variants: Rc>, + source_indices: Rc>>, + init_locals: Rc>>, +) -> Rc { + Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + Rc::new(VariantFoldState { + locals: init_locals, + collision_errors: Rc::new(vec![]), + }), + |acc: Rc, binding: Rc| { + let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + { + let binding_enum_name = + authored_name_at(source_indices.clone(), binding.resolved.clone()); + binding + .resolved .clone() .children .clone() @@ -11874,28 +11946,70 @@ pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>>, child: Rc| { + |vacc: Rc, child: Rc| { let child_name = - authored_name_at(env.source_indices.clone(), child.clone()); - match v1_rt::map_get(&vacc, child_name.clone()) { - Some(_prev) => vacc.clone(), - None => v1_rt::rc_map_insert( - vacc.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: (*binding.resolved).clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), + authored_name_at(source_indices.clone(), child.clone()); + let curr_child_is_imported = is_imported_variant_owned_by( + imported_variants.clone(), + child_name.clone(), + binding_enum_name.clone(), + ); + match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { + Some(_prev) => { + if curr_child_is_imported.clone() { + Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }) + } else { + vacc.clone() + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }), } }, ) - } else { - acc.clone() } - }, - ), + } else { + acc.clone() + } + }, + ) +} + +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => fold_local_coproduct_variant_locals( + kernel.bindings.clone(), + v1_rt::rc_empty_map::(), + env.source_indices.clone(), + v1_rt::rc_empty_map::>(), + ) + .locals + .clone(), None => v1_rt::rc_empty_map::>(), } } @@ -11952,26 +12066,9 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ); - let filtered_ancestry = - Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: Rc::new(v1_rt::map_keys(&parent_env.str_bindings.clone())) .iter() .cloned() .fold( @@ -11980,10 +12077,8 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -11993,11 +12088,30 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get( + &parent_env.ancestry_str_bindings.clone(), + name.clone(), + ) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ), parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12011,258 +12125,271 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, - parent_index: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, intern_table: Rc, -) -> Rc { - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) +) -> Rc { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }) +} + +pub fn build_type_env( + module: Rc, + parent_index: Rc>>, + source_indices: Rc>>, + intern_table: Rc, +) -> Rc { + record_build_type_env_call(); + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), ) }, ); - let kernel = Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }); - let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let intern_table = seed_kernel_intern_table(intern_table.clone()); + let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); + let kernel_cache = type_env_cache_from_bindings( + kernel.bindings.clone(), + source_indices.clone(), + compiler_recursive_name_set(), + ); + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12270,7 +12397,7 @@ pub fn build_type_env( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12280,7 +12407,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12314,7 +12441,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12479,7 +12606,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let param_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12531,15 +12658,10 @@ pub fn build_type_env( }, ); let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); - let kernel_cache = type_env_cache_from_bindings( - kernel_bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), - ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12580,53 +12702,52 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -12650,7 +12771,7 @@ pub fn build_type_env( local_name_set, all_deps_map.clone(), ); - let resolved_env_out = (*resolved.env).clone(); + let resolved_env_out = resolved.env.clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), @@ -12683,6 +12804,7 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { + record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12837,7 +12959,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12845,7 +12967,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12856,7 +12978,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12987,8 +13109,8 @@ pub fn build_type_env_unresolved( ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13029,53 +13151,52 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -13191,7 +13312,7 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = (*resolved.item).clone(); + let ritem = resolved.item.clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) && (ritem.inferred.clone() != None)) @@ -13214,516 +13335,328 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc Rc>>>>, >(), })) - } - } else { - None - }; - let svc_entries = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) - } - } else { - None - }; - Rc::new(ItemContribution { - resolved_item: ritem.clone(), - resolve_diagnostics: resolved.diagnostics.clone(), - func_sig: func_sig, - svc_entries: svc_entries, - svc_local: svc_local, - item_info: build_item_info( - ritem.clone(), - env.source_indices.clone(), - module_name.clone(), - ), - }) - } -} - -pub fn fold_module_contributions( - mut remaining: Rc>>, - mut resolved_items: Rc>>, - mut func_sigs: Rc>>, - mut svc_registry: Rc>>>>, - mut svc_locals: Rc>>, - mut item_registry: Rc>>, - mut diag_chunks: Rc>>>>, - mut source_indices: Rc>>, -) -> Rc { - loop { - match remaining.clone().first().cloned() { - None => { - break Rc::new(LocalContributionState { - resolved_items: resolved_items, - func_sigs: func_sigs, - svc_registry: svc_registry, - svc_locals: svc_locals, - item_registry: item_registry, - diag_chunks: diag_chunks, - }); - } - Some(contribution) => { - let next_func_sigs = match contribution.func_sig.clone() { - Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), - None => func_sigs, - }; - let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { - v1_rt::rc_map_insert( - svc_registry, - authored_name_at( - source_indices.clone(), - (*contribution.resolved_item).clone(), - ), - contribution.svc_entries.clone(), - ) - } else { - svc_registry - }; - let next_svc_locals = match contribution.svc_local.clone() { - Some(binding) => { - v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) - } - None => svc_locals, - }; - { - let __tco_0 = Rc::new( - remaining - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ); - let __tco_1 = - v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); - let __tco_2 = next_func_sigs; - let __tco_3 = next_svc_registry; - let __tco_4 = next_svc_locals; - let __tco_5 = v1_rt::rc_map_insert( - item_registry, - contribution.item_info.clone().name.clone(), - contribution.item_info.clone(), - ); - let __tco_6 = - v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); - remaining = __tco_0; - resolved_items = __tco_1; - func_sigs = __tco_2; - svc_registry = __tco_3; - svc_locals = __tco_4; - item_registry = __tco_5; - diag_chunks = __tco_6; - continue; - } - } - } - } -} - -pub fn constructor_binding_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn insert_variant_owner_checked( - state: Rc, - arm_name: String, - owner: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); - let owner_name = authored_name_at(source_indices.clone(), owner.clone()); - let same_owner = (((prev_name.clone() == owner_name.clone()) - && ((*prev.resolved).clone().span.clone().file.clone() - == owner.span.clone().file.clone())) - && ((*prev.resolved).clone().span.clone().start.clone() - == owner.span.clone().start.clone())); - if same_owner { - state.clone() - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name.clone(), - enum1: prev_name.clone(), - enum2: owner_name.clone(), - span: owner.span.clone(), - }), - module_name, - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name.clone(), - resolved: owner.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } -} - -pub fn bind_coproduct_item_arms( - state: Rc, - item: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - item.children.clone().iter().cloned().fold( - state, - |vacc: Rc, child: Rc| { - insert_variant_owner_checked( - vacc, - authored_name_at(source_indices.clone(), child.clone()), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - }, - ) -} - -pub fn build_local_variants( - items: Rc>>, - source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { - items - .iter() - .cloned() - .fold(init, |acc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - acc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - acc.clone() - } - }) -} - -pub fn reexport_chain_authority() -> String { - thread_local! { - static CACHED: String = { - "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn owner_of_exported_arm( - mut module_path: String, - mut arm_name: String, - mut parent_index: Rc>>, - mut source_indices: Rc>>, -) -> Option> { - loop { - match v1_rt::map_get(&parent_index, module_path) { - None => { - break None; - } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for c in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()) - == arm_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); - } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == arm_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } - } + } + } else { + None + }; + let svc_entries = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) } - } - } + } else { + None + }; + Rc::new(ItemContribution { + resolved_item: ritem.clone(), + resolve_diagnostics: resolved.diagnostics.clone(), + func_sig: func_sig, + svc_entries: svc_entries, + svc_local: svc_local, + item_info: build_item_info( + ritem.clone(), + env.source_indices.clone(), + module_name.clone(), + ), + }) } } -pub fn exported_coproduct_item( - mut module_path: String, - mut enum_name: String, - mut parent_index: Rc>>, +pub fn fold_module_contributions( + mut remaining: Rc>>, + mut resolved_items: Rc>>, + mut func_sigs: Rc>>, + mut svc_registry: Rc>>>>, + mut svc_locals: Rc>>, + mut item_registry: Rc>>, + mut diag_chunks: Rc>>>>, mut source_indices: Rc>>, -) -> Option> { +) -> Rc { loop { - match v1_rt::map_get(&parent_index, module_path) { + match remaining.clone().first().cloned() { None => { - break None; + break Rc::new(LocalContributionState { + resolved_items: resolved_items, + func_sigs: func_sigs, + svc_registry: svc_registry, + svc_locals: svc_locals, + item_registry: item_registry, + diag_chunks: diag_chunks, + }); } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if (authored_name_at(source_indices.clone(), item.clone()) - == enum_name.clone()) - { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); + Some(contribution) => { + let next_func_sigs = match contribution.func_sig.clone() { + Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), + None => func_sigs, + }; + let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { + v1_rt::rc_map_insert( + svc_registry, + authored_name_at( + source_indices.clone(), + contribution.resolved_item.clone(), + ), + contribution.svc_entries.clone(), + ) + } else { + svc_registry + }; + let next_svc_locals = match contribution.svc_local.clone() { + Some(binding) => { + v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) + None => svc_locals, + }; + { + let __tco_0 = Rc::new( + remaining .iter() .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == enum_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } + .skip(1 as usize) + .collect::>(), + ); + let __tco_1 = + v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); + let __tco_2 = next_func_sigs; + let __tco_3 = next_svc_registry; + let __tco_4 = next_svc_locals; + let __tco_5 = v1_rt::rc_map_insert( + item_registry, + contribution.item_info.clone().name.clone(), + contribution.item_info.clone(), + ); + let __tco_6 = + v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); + remaining = __tco_0; + resolved_items = __tco_1; + func_sigs = __tco_2; + svc_registry = __tco_3; + svc_locals = __tco_4; + item_registry = __tco_5; + diag_chunks = __tco_6; + continue; + } + } + } + } +} + +pub fn enum_parents_for_variant_in_items( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for child in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) + { + __found = true; + break; } } + __found + } { + __result.push(item); } } + __result + }) + .iter() + .cloned() + { + __result.push(authored_name_at(source_indices.clone(), item.clone())); + } + __result + }) +} + +pub fn unique_imported_variant_owner( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Option { + { + let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); + if ((parents.clone().len() as i64) == 1) { + parents.clone().first().cloned() + } else { + None } } } +pub fn is_imported_variant_owned_by( + imported_variants: Rc>, + variant_name: String, + enum_name: String, +) -> bool { + match v1_rt::map_get(&imported_variants, variant_name) { + Some(unique_parent) => (unique_parent.clone() == enum_name), + None => false, + } +} + pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { +) -> Rc> { resolved_imports.iter().cloned().fold( - init, - |acc: Rc, imp: Rc| { - let with_glob = if imp.is_all.clone() { - { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.clone().iter().cloned().fold( - acc.clone(), - |iacc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - iacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - iacc.clone() - } - }, - ) - } - } else { - acc.clone() - }; + v1_rt::rc_empty_map::(), + |acc: Rc>, imp: Rc| { imp.specific_names.clone().iter().cloned().fold( - with_glob.clone(), - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms( - nacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ), - None => nacc.clone(), - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked( - after_enum.clone(), - name.clone(), - owner.clone(), - source_indices.clone(), - module_name.clone(), + acc, + |inner: Rc>, variant_name: String| { + if v1_rt::map_contains_key(&inner, variant_name.clone()) { + inner.clone() + } else { + { + let source_items = + match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + match unique_imported_variant_owner( + variant_name.clone(), + source_items.clone(), + source_indices.clone(), + ) { + Some(parent) => v1_rt::rc_map_insert( + inner.clone(), + variant_name.clone(), + parent.clone(), + ), + None => inner.clone(), + } + } + } + }, + ) + }, + ) +} + +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain +// followers — a module re-exports its specific-name imports, so the binder +// walks the acyclic import chain to the defining module's coproduct. Replaced +// by regen's true emission in the convergence commit. +pub fn owner_of_exported_arm( + module_path: String, + arm_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && item + .children + .iter() + .cloned() + .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == arm_name) + }); + match reexport { + Some(imp) => owner_of_exported_arm( + authored_name_at(source_indices.clone(), imp), + arm_name, + parent_index, + source_indices, ), - None => after_enum.clone(), + None => None, } - }, - ) - }, - ) + } + } + } + } +} + +pub fn exported_coproduct_item( + module_path: String, + enum_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && authored_name_at(source_indices.clone(), item.clone()) == enum_name + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == enum_name) + }); + match reexport { + Some(imp) => exported_coproduct_item( + authored_name_at(source_indices.clone(), imp), + enum_name, + parent_index, + source_indices, + ), + None => None, + } + } + } + } + } } pub fn build_module_context( @@ -13744,21 +13677,134 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - let local_variant_fold = build_local_variants( - local.resolved_items.clone(), - env.source_indices.clone(), - module_name.clone(), + // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional + // realization of the new v1.compiler.infer dag source — replaced + // wholesale by regen output in the convergence commit. Constructor + // namespace is FLAT: local coproduct arms + direct imports' + // contributions; the binding carries the owner NODE; one arm name + // bound to two different owners = VariantCollision (per-file wall). + let insert_variant_owner_checked = |state: Rc, + arm_name: String, + owner: Rc| + -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = + authored_name_at(env.source_indices.clone(), prev.resolved.clone()); + let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); + let same_owner = prev_name == owner_name + && prev.resolved.span.file == owner.span.file + && prev.resolved.span.start == owner.span.start; + if same_owner { + state + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name, + enum1: prev_name, + enum2: owner_name, + span: owner.span.clone(), + }), + module_name.clone(), + )]), + ), + }) + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name, + resolved: owner, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } + }; + let bind_coproduct_item_arms = + |state: Rc, item: Rc| -> Rc { + item.children + .clone() + .iter() + .cloned() + .fold(state, |vacc, child| { + insert_variant_owner_checked( + vacc, + authored_name_at(env.source_indices.clone(), child.clone()), + item.clone(), + ) + }) + }; + let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), + |acc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(acc, item) + } else { + acc + } + }, ); - let variant_fold = build_imported_variants( - resolved_imports.clone(), - parent_index.clone(), - env.source_indices.clone(), - module_name.clone(), + let variant_fold = resolved_imports.clone().iter().cloned().fold( local_variant_fold, + |acc: Rc, imp: Rc| { + // Glob (is_all) imports bind the target's OWN coproduct arms only. + let with_glob = if imp.is_all { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.iter().cloned().fold( + acc, + |iacc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(iacc, item) + } else { + iacc + } + }, + ) + } else { + acc + }; + // Specific names resolve through the re-export chain to the + // defining module (owner_of_exported_arm / exported_coproduct_item). + imp.specific_names.iter().cloned().fold( + with_glob, + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms(nacc, item), + None => nacc, + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked(after_enum, name, owner), + None => after_enum, + } + }, + ) + }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13775,7 +13821,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), + Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), None => Rc::new(vec![]), }) .iter() @@ -13788,7 +13834,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name.clone(), + module_name, env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13802,7 +13848,7 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: (*resolve_result.func_env).clone(), + func_env: resolve_result.func_env.clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, variant_locals: env_variant_locals.clone(), @@ -13843,7 +13889,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = (*env_result.env).clone(); + let env = env_result.env.clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13859,7 +13905,7 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: (*resolved.module).clone(), + module: resolved.module.clone(), items: Rc::new(vec![]), type_env: env.clone(), type_env_cache: env_cache.clone(), @@ -13873,10 +13919,10 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), (*resolved.module).clone()); + authored_name_at(source_indices.clone(), resolved.module.clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items((*resolved.module).clone()).iter().cloned() { + for item in module_items(resolved.module.clone()).iter().cloned() { __result.push(analyze_item( item.clone(), env.clone(), @@ -13915,7 +13961,7 @@ pub fn typecheck_module( ); let infer_scope = Rc::new(InferScope { type_env: env.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13927,7 +13973,7 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push((*tir.item).clone()); + __result.push(tir.item.clone()); } __result }); @@ -13940,7 +13986,7 @@ pub fn typecheck_module( }); let updated_func_env = populate_output_provenance( typed_items.clone(), - (*ctx.func_env).clone(), + ctx.func_env.clone(), env.clone(), data_locals.clone(), ); @@ -13985,12 +14031,12 @@ pub fn typecheck_module( }); let typed_base = module_node( resolved_module_name.clone(), - module_imports((*resolved.module).clone()), + module_imports(resolved.module.clone()), ctx.resolved_items.clone(), - (*resolved.module).clone().span.clone(), + resolved.module.clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: (*resolved.module).clone().ident_span.clone(), + ident_span: resolved.module.clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { @@ -14141,12 +14187,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); + let pre = binding.resolved.clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14164,7 +14210,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14205,11 +14251,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); + let pre = binding.resolved.clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14227,7 +14273,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14298,7 +14344,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); + let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14359,7 +14405,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items .clone() .iter() @@ -14424,7 +14470,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14479,11 +14525,9 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().source_indices.clone(), - )) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14522,7 +14566,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().recursive_type_set.clone(), + &m.type_env.clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), + intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14673,7 +14717,7 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), (*typed.module).clone()), + authored_name_at(source_indices.clone(), typed.module.clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); @@ -14681,526 +14725,209 @@ pub fn typecheck_modules( v1_rt::rc_list_push(diag_chunks, parent_result.diagnostics.clone()), tc_diags, ); - remaining = __tco_0; - modules = __tco_1; - module_index = __tco_2; - item_registry = __tco_3; - diag_chunks = __tco_4; - continue; - } - } - } - } -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct StrBindingsRewireAccum { - pub str_bindings: Rc>>, - pub ancestry_str_bindings: Rc>>, -} - -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn local_authority_binding(owner: Rc, name: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values( - &(*owner.type_env).clone().bindings.clone(), - )) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .first() - .cloned() - { - Some(binding) => Some(binding.clone()), - None => None, - } -} - -pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if module_exports_type_name(m.clone(), name.clone()) { - __result.push(m); - } - } - __result - }) - .len() as i64) -} - -pub fn local_authority_for_name_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn local_authority_for_name( - modules: Rc>>, - name: String, -) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) - { - __result.push(m); - } - } - __result - }) - .last() - .cloned() - { - Some(owner) => Some(owner.clone()), - None => None, - } -} - -pub fn module_exports_type_name(m: Rc, name: String) -> bool { - ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) -} - -pub fn direct_import_exporter_count( - m: Rc, - name: String, - index: Rc>>, - source_indices: Rc>>, -) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { - if { - let path = import_module_path_at(imp.clone(), source_indices.clone()); - match v1_rt::map_get(&index, path.clone()) { - Some(parent) => module_exports_type_name(parent.clone(), name.clone()), - None => false, - } - } { - __result.push(imp); - } - } - __result - }) - .len() as i64) -} - -pub fn rewire_inherited_str_binding( - modules: Rc>>, - module_index: Rc>>, - consumer: Rc, - source_indices: Rc>>, - local_names: Rc>, - str_bindings: Rc>>, - ancestry_str_bindings: Rc>>, - name: String, -) -> Rc { - if ((v1_rt::set_contains(&local_names, name.clone()) - || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) - > 1)) - || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) - { - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } else { - match local_authority_for_name(modules.clone(), name.clone()) { - Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { - Some(canonical) => { - let ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings.clone(), - name.clone(), - canonical.clone(), - ); - let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { - Some(_) => v1_rt::rc_map_insert( - str_bindings.clone(), - name.clone(), - canonical.clone(), - ), - None => str_bindings.clone(), - }; - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - }, - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - } - } -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - { - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), - m.clone(), - ) - }, - ); - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - __result.push({ - let local_names = - Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { - v1_rt::rc_set_insert(acc, b.name.clone()) - }); - let ancestry_keys = Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().ancestry_str_bindings.clone(), - )); - let str_keys = - Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); - let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); - let rewired = inherited_keys.clone().iter().cloned().fold( - Rc::new(StrBindingsRewireAccum { - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - }), - |acc: Rc, name: String| { - rewire_inherited_str_binding( - modules.clone(), - index.clone(), - m.clone(), - source_indices.clone(), - local_names.clone(), - acc.str_bindings.clone(), - acc.ancestry_str_bindings.clone(), - name.clone(), - ) - }, - ); - Rc::new(TypedModule { - module: (*m.module).clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: rewired.str_bindings.clone(), - ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), - parents: (*m.type_env).clone().parents.clone(), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), - item_registry: m.item_registry.clone(), - }) - }); + remaining = __tco_0; + modules = __tco_1; + module_index = __tco_2; + item_registry = __tco_3; + diag_chunks = __tco_4; + continue; + } } - __result - }) + } } } -pub fn compiler_kernel_type_env( +pub fn import_module_path_at( + imp: Rc, source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + record_rewire_type_env_import_str_binding_call(); + fn local_authority_binding(owner: Rc, name: String) -> Option> { + owner + .type_env + .bindings + .values() + .find(|b| b.name.clone() == name) + .cloned() + } + + fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { + modules + .iter() + .filter(|m| module_exports_type_name((**m).clone(), name)) + .count() + } + + fn local_authority_for_name( + modules: Rc>>, + name: String, + ) -> Option> { + // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) + modules .iter() + .rev() + .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + } + + fn module_exports_type_name(m: Rc, name: &str) -> bool { + m.type_env + .bindings + .values() + .any(|b| b.name.as_str() == name) + } + + fn direct_import_exporter_count( + m: Rc, + name: &str, + index: &HashMap>, + source_indices: Rc>>, + ) -> usize { + module_imports(m.module.clone()) + .iter() + .filter(|imp| { + let path = import_module_path_at((*imp).clone(), source_indices.clone()); + index.get(&path).map_or(false, |parent| { + module_exports_type_name(parent.clone(), name) + }) + }) + .count() + } + + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), m.module.clone()), + m.clone(), + ) + }, + ); + + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + let local_names: std::collections::HashSet = m + .type_env + .bindings + .values() + .map(|b| b.name.clone()) + .collect(); + let mut str_bindings = m.type_env.str_bindings.clone(); + let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); + let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) .iter() + .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + .filter(|name| !local_names.contains(name)) + .collect(); + inherited_names.sort(); + for name in inherited_names { + if direct_import_exporter_count( + m.clone(), + name.as_str(), + &index, + source_indices.clone(), + ) > 1 + || global_type_exporter_count(modules.clone(), name.as_str()) > 1 + { + continue; + } + if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { + if let Some(canonical) = local_authority_binding(owner, name.clone()) { + if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { + Some(existing) => { + Rc::ptr_eq(&existing.resolved, &canonical.resolved) + && existing.name == canonical.name + } + None => false, + } { + continue; + } + ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings, + name.clone(), + canonical.clone(), + ); + if v1_rt::map_contains_key(&str_bindings, name.clone()) { + str_bindings = + v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); + } + } + } } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices, - intern_table: intern_table.clone(), - }) - } + __result.push(Rc::new(TypedModule { + module: m.module.clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: m.type_env.bindings.clone(), + str_bindings, + ancestry_str_bindings, + parents: m.type_env.parents.clone(), + recursive_types: m.type_env.recursive_types.clone(), + recursive_type_set: m.type_env.recursive_type_set.clone(), + inductive_fields: m.type_env.inductive_fields.clone(), + source_indices: m.type_env.source_indices.clone(), + intern_table: m.type_env.intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: m.func_env.clone(), + item_registry: m.item_registry.clone(), + })); + } + __result + }) } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { + record_rewire_type_env_parent_links_call(); { + let intern_table = modules + .first() + .map(|m| m.type_env.intern_table.clone()) + .unwrap_or_else(empty_intern_table); + let shared_kernel = modules + .iter() + .find_map(|m| { + m.type_env.parents.last().and_then(|kernel| { + if kernel.bindings.is_empty() { + None + } else { + Some(kernel.clone()) + } + }) + }) + .unwrap_or_else(|| { + compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) + }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, ); - let shared_kernel = match modules.clone().iter().cloned().fold( - None, - |acc, m: Rc| match acc.clone() { - Some(_) => acc.clone(), - None => match (*m.type_env).clone().parents.clone().last().cloned() { - Some(kernel) => Some(kernel.clone()), - None => None, - }, - }, - ) { - Some(kernel) => kernel.clone(), - None => match modules.clone().first().cloned() { - Some(m) => compiler_kernel_type_env( - source_indices.clone(), - (*m.type_env).clone().intern_table.clone(), - ), - None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), - }, - }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = @@ -15208,7 +14935,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - (*parent.type_env).clone(), + parent.type_env.clone(), )]), None => Rc::new(vec![]), } @@ -15219,28 +14946,23 @@ pub fn rewire_type_env_parent_links( } __result }); + let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - parents: v1_rt::concat( - import_parents.clone(), - Rc::new(vec![shared_kernel.clone()]), - ), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), + bindings: m.type_env.clone().bindings.clone(), + str_bindings: m.type_env.clone().str_bindings.clone(), + ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), + parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), + recursive_types: m.type_env.clone().recursive_types.clone(), + recursive_type_set: m.type_env.clone().recursive_type_set.clone(), + inductive_fields: m.type_env.clone().inductive_fields.clone(), + source_indices: m.type_env.clone().source_indices.clone(), + intern_table: m.type_env.clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), + func_env: m.func_env.clone(), item_registry: m.item_registry.clone(), }) }); @@ -15260,7 +14982,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -15271,13 +14993,13 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), + Some(parent) => Rc::new(vec![parent.func_env.clone()]), None => Rc::new(vec![]), } }) @@ -15288,12 +15010,12 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), - type_env: (*m.type_env).clone(), + type_env: m.type_env.clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: (*m.func_env).clone().local.clone(), + local: m.func_env.clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index 0ca86943c45..c3d02096a6e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -131,7 +131,7 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - (*parts.key_type).clone(), + parts.key_type.clone(), normed_index.clone(), source_indices.clone(), ) { @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality((*parts.value_type).clone()), + with_optional_cardinality(parts.value_type.clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 80801b55852..0dc55228a93 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -229,10 +229,11 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { - __result.push(b.name.clone()); - } + let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .map(|b| b.name.clone()) + .collect(); + __result.sort(); __result }); let name_set = all_names diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b8089770e47..b19d756df6d 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -452,7 +452,8 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child.inferred + |acc: Rc>, child: Rc| match child + .inferred .clone() .as_deref() .cloned() diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index daa958bdc8e..dc7b6acbab3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,12 +17,82 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +use std::sync::atomic::{AtomicU64, Ordering}; + +// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). +static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); +static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); +static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); + +pub fn flatten_visible_parent_recurses() -> u64 { + FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) +} + +pub fn build_type_env_calls() -> u64 { + BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) +} + +pub fn merge_type_env_cache_calls() -> u64 { + MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_parent_links_calls() -> u64 { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_import_str_binding_calls() -> u64 { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) +} + +pub fn reset_flatten_visible_profile() { + FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); +} + +pub fn reset_type_env_lookup_profile() { + reset_flatten_visible_profile(); + BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); + MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); +} + +pub fn maybe_print_type_env_lookup_profile() { + if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { + eprintln!( + "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", + flatten_visible_parent_recurses(), + build_type_env_calls(), + merge_type_env_cache_calls(), + rewire_type_env_parent_links_calls(), + rewire_type_env_import_str_binding_calls(), + ); + } +} + +pub fn record_flatten_visible_parent_recurse() { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_build_type_env_call() { + BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_parent_links_call() { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_import_str_binding_call() { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, + #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -31,6 +101,10 @@ pub struct TypeEnv { pub intern_table: Rc, } +fn empty_type_env_parents() -> Rc>> { + Rc::new(vec![]) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -46,60 +120,6 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } -pub fn type_env_compositional_authority_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_work_count_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_key_determinism_authority() -> String { - thread_local! { - static CACHED: String = { - "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn flatten_visible_bindings_invariant() -> String { - thread_local! { - static CACHED: String = { - "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -109,34 +129,16 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn build_type_env_calls() -> i64 { - 0 -} - -pub fn merge_type_env_cache_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_parent_links_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_import_str_binding_calls() -> i64 { - 0 -} - -pub fn type_env_counter_dissolution() -> String { - thread_local! { - static CACHED: String = { - "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn record_merge_type_env_cache_call() { + MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { + record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), + // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at + // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -162,21 +164,42 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( + let mut pairs: Vec<(String, Rc)> = bindings + .values() + .map(|binding| (binding.name.clone(), binding.clone())) + .collect(); + pairs.sort_by(|a, b| a.0.cmp(&b.0)); + pairs.into_iter().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) + |acc: Rc>>, (name, binding)| { + v1_rt::rc_map_insert(acc, name, binding) + }, + ) +} + +// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value +// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). +#[allow(dead_code)] +pub fn deterministic_str_binding_map( + m: Rc>>, +) -> Rc>> { + let mut keys: Vec = m.keys().cloned().collect(); + keys.sort(); + keys.iter().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, key: &String| { + v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { + match v1_rt::map_get(&env.str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { + None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name.clone()) { - Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), + None => match intern_find(env.intern_table.clone(), name) { + Some(id) => v1_rt::map_get(&env.bindings, id), None => None, }, }, @@ -188,7 +211,7 @@ pub fn lookup_binding(env: Rc, ident: i64) -> Option> { Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env.clone(), name) + lookup_binding_by_name(env, name) } } } @@ -201,7 +224,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name) { + match intern_find(env.intern_table.clone(), name.clone()) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } @@ -209,14 +232,14 @@ pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } @@ -240,26 +263,18 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) => fields.clone(), - None => Rc::new(vec![]), - }; - if ((local.clone().len() as i64) > 0) { - local.clone() - } else { - env.parents.clone().iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, parent: Rc| { - if ((acc.clone().len() as i64) > 0) { - acc.clone() - } else { - inductive_fields_for(parent.clone(), type_name.clone()) - } - }, - ) + match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) if !fields.is_empty() => fields.clone(), + _ => { + for parent in env.parents.iter() { + let fields = inductive_fields_for(parent.clone(), type_name.clone()); + if !fields.is_empty() { + return fields; + } + } + Rc::new(vec![]) } - }) + } } pub fn is_inductive_field( @@ -385,27 +400,12 @@ pub fn inductive_fields_list_to_map( ) } -pub fn flatten_visible_parent_recurses() -> i64 { - 0 -} - -pub fn reset_flatten_visible_profile() -> () { - {} -} - -pub fn reset_type_env_lookup_profile() -> () { - reset_flatten_visible_profile() -} - -pub fn maybe_print_type_env_lookup_profile() -> () { - {} -} - pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -469,7 +469,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings.clone(), + str_bindings: merged_bindings, ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 95a6d52a3d7..02b08953fa8 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,10 +2,12 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; +pub use crate::std_induction::SubValueRelation; +use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -174,13 +176,10 @@ pub fn item_kind(item: Rc) -> ItemKind { if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { ItemKind::FnItem } else { - if ((item.body.clone() != None) - && (item.type_annotation.clone() != None)) - { + if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { ItemKind::DataItem } else { if (item.body.clone() != None) { @@ -197,6 +196,38 @@ pub fn item_kind(item: Rc) -> ItemKind { } } +pub fn variant_locals_from_items( + items: Rc>>, + init: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + items.iter().cloned().fold( + init, + |acc: Rc>>, item: Rc| { + let is_coproduct = (item.connective.clone() == Connective::Disj); + if is_coproduct.clone() { + item.children.clone().iter().cloned().fold( + acc.clone(), + |vacc: Rc>>, child: Rc| { + let child_name = authored_name_at(source_indices.clone(), child.clone()); + v1_rt::rc_map_insert( + vacc, + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: item.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ) + } else { + acc.clone() + } + }, + ) +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 63743b2107e..ac704dae929 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } @@ -126,12 +126,12 @@ pub fn lookup_field_type_node( None => nominal_type_ref("V".to_string()), }; Some( - (*make_container_type( + make_container_type( "Witness".to_string(), value_child, ) - .ty) - .clone(), + .ty + .clone(), ) } } else { @@ -217,14 +217,18 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved.connective.clone() == Connective::Conj) - || ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone()))) - { + if (resolved.connective.clone() == Connective::Conj) { resolved.clone() } else { - receiver_type.clone() + let resolved_name = + authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone())) + { + resolved.clone() + } else { + receiver_type.clone() + } } } } @@ -499,7 +503,11 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some((*make_container_type("Witness".to_string(), raw.clone()).ty).clone()) + Some( + make_container_type("Witness".to_string(), raw.clone()) + .ty + .clone(), + ) } } None => None, @@ -579,12 +587,12 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if (((*enriched.ty).clone().connective.clone() == Connective::Conj) - && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) + if ((enriched.ty.clone().connective.clone() == Connective::Conj) + && ((enriched.ty.clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( - (*enriched.ty).clone(), + enriched.ty.clone(), method_name.clone(), source_indices.clone(), ); @@ -613,8 +621,8 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: (*mfr.field_node).clone(), - result_type: (*mfr.result_type).clone(), + field_node: mfr.field_node.clone(), + result_type: mfr.result_type.clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), algebra_template: Some(t.clone()), @@ -660,7 +668,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: (*mfr.field_node).clone(), + method_def: mfr.field_node.clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -668,7 +676,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some((*mfr.result_type).clone()), + result_type: Some(mfr.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -686,7 +694,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some((*svc_result.result_type).clone()), + result_type: Some(svc_result.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 12c6fb18bc5..96d9884ceb1 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,24 +44,28 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - (*make_map_type( + make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty) - .clone() + .ty + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() + make_container_type("List".to_string(), type_variable_node(id)) + .ty + .clone() } pub fn list_of_element(element: Rc) -> Rc { - (*make_container_type("List".to_string(), element).ty).clone() + make_container_type("List".to_string(), element).ty.clone() } pub fn witness_of_element(element: Rc) -> Rc { - (*make_container_type("Witness".to_string(), element).ty).clone() + make_container_type("Witness".to_string(), element) + .ty + .clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -123,12 +127,12 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = (*make_container_type( + let set_ty = make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty) - .clone(); + .ty + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); @@ -250,6 +254,41 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_loc".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_test_fns".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_names".to_string(), + list_of_type_variable("test_migration_debt_module_name_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_known_covered_module_is_not_debt".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_holds".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_uncovered_deletes".to_string(), + list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), + ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 4e0bf90d8ff..1dd9fc95134 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,148 +37,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), - None => acc.clone(), - } - }, - ) - } -} - -pub fn expand_scrut_from_decl( - decl: Rc, - scrut_node: Rc, - name: String, - env: Rc, -) -> Rc { - { - let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = (((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)) - && ((decl.children.clone().len() as i64) == 0)); - if decl_is_disj { - decl.clone() - } else { - if has_inferred_alias { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node, env.clone()); - substitute_type_slots( - target.clone(), - subst, - name, - env.source_indices.clone(), - ) - } - _ => scrut_node, - } - } else { - scrut_node - } - } - } -} - -pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { - { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())); - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if is_generic_use { - expand_scrut_from_decl( - decl.clone(), - scrut_node.clone(), - name.clone(), - env.clone(), - ) - } else { - { - let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = ((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)); - if def_is_disj { - decl.clone() - } else { - if has_inferred_body { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let target_is_disj = - (target.connective.clone() == Connective::Disj); - if target_is_disj { - target.clone() - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - } - } - } - None => scrut_node.clone(), - } - } -} - -pub fn expand_scrut_type_for_variant_lookup( - mut scrut_node: Rc, - mut env: Rc, -) -> Rc { - loop { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_disj = (scrut_node.connective.clone() == Connective::Disj); - let is_witness = is_witness_type_name(name); - if (is_disj || is_witness) { - break scrut_node.clone(); - } else { - match scrut_node.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let __tco_0 = target.clone(); - scrut_node = __tco_0; - continue; - } - _ => { - break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); - } - } - } - } -} - pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -469,6 +327,102 @@ pub fn variant_not_found_result( )])) } +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), + None => acc, + } + }, + ) +} + +pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { + return scrut_node.clone(); + } + if (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())) + { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if (((decl.inferred.clone() != None) + && ((decl.children.clone().len() as i64) == 0)) + && (decl.connective.clone() == Connective::NoConnective)) + { + match decl.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); + let expanded = substitute_type_slots( + target, + subst, + name.clone(), + env.source_indices.clone(), + ); + return expanded; + } + _ => scrut_node.clone(), + } + } else if (decl.connective.clone() == Connective::Disj) { + decl.clone() + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } else { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(def) => { + if (def.connective.clone() == Connective::Disj) { + def.clone() + } else if ((def.inferred.clone() != None) + && (def.connective.clone() == Connective::NoConnective)) + { + match def.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + if (target.connective.clone() == Connective::Disj) { + target + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } +} + pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 93bb2d20793..84f1b36551f 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, - lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, + is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -117,41 +117,24 @@ pub fn lookup_unit_variant_phantom_type( } } -pub fn phantom_match_flat_scope() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - { - let direct_bindings = env.parents.clone().iter().cloned().fold( - env.str_bindings.clone(), - |acc: Rc>>, parent: Rc| { - v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) + Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), }, - ); - Rc::new(v1_rt::map_values(&direct_bindings)) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), - }, - ) - } + ) } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -196,22 +179,13 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { - thread_local! { - static CACHED: String = { - "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices, structural.clone()))) + && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -220,9 +194,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if ((((brand_name.clone() != "".to_string()) + if (((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone())) + && !is_declared_container_alias_spelling(brand_name.clone()) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -242,34 +216,32 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S && (resolved.inferred.clone() != None)) { match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - (*resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved) - .clone() - } - _ => (*resolve_node_bounded( + Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved + .clone(), + _ => resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(), + .resolved + .clone(), } } else { - (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved) + resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved .clone() }; - if ((((brand.clone() != "".to_string()) + if (((brand.clone() != "".to_string()) && (brand.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand.clone())) + && !is_declared_container_alias_spelling(brand.clone()) && !is_transparent_primitive_alias_rhs( structural.clone(), source_indices.clone(), @@ -283,14 +255,14 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = (*resolve_node_bounded( + let target_resolved = resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(); + .resolved + .clone(); with_authored_identity(n.clone(), target_resolved) } _ => resolved.clone(), @@ -375,61 +347,6 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { - thread_local! { - static CACHED: String = { - "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for parent in env.parents.clone().iter().cloned() { - if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), - None => false, - } { - __result.push(parent); - } - } - __result - }) - .first() - .cloned() - { - Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => Some((*b.resolved).clone()), - None => None, - }, - None => None, - } -} - -pub fn resolve_paramless_generic_use_decl( - env: Rc, - n: Rc, - decl: Rc, - brand: String, -) -> Rc { - match ((n.children.clone().len() as i64) > 0) { - true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { - Some(user_decl) => user_decl.clone(), - None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) - { - true => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl, - }, - false => decl, - }, - }, - false => decl, - } -} - pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); @@ -437,8 +354,45 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { decl.clone() + } else if ((n.children.clone().len() as i64) > 0) { + // HAND-PATCH (parameterized use site prefers parameterized + // decl; replaced at regen): a use site WITH type args whose + // primary lookup lands paramless (kernel prelude shadowing + // an imported user generic, e.g. Optional) retries the + // ancestry binding for a parameterized decl. + let ancestry_generic = env.parents.iter().fold( + None, + |acc: Option>, parent: &Rc| { + if acc.is_some() { + return acc; + } + match v1_rt::map_get(&parent.str_bindings, brand.clone()) { + Some(b) => { + if ((b.resolved.params.clone().len() as i64) > 0) { + Some(b.resolved.clone()) + } else { + acc + } + } + None => acc, + } + }, + ); + match ancestry_generic { + Some(user_decl) => user_decl, + None => { + if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { + match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural.clone(), + None => decl.clone(), + } + } else { + decl.clone() + } + } + } } else { - resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) + decl.clone() } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { @@ -624,7 +578,8 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - (*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) + resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) + .resolved .clone() } AliasKind::AliasLeaf => match lookup_type_by_name( @@ -670,7 +625,7 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -751,7 +706,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let base_resolved = (*base_result.resolved).clone(); + let base_resolved = base_result.resolved.clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -801,7 +756,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = (*rt_result.resolved).clone(); + let rt_resolved = rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -826,8 +781,7 @@ pub fn resolve_node_bounded( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation - .clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -844,7 +798,7 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.resolved).clone()); + __result.push(cr.resolved.clone()); } __result }); @@ -893,7 +847,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = (*inner_result.resolved).clone(); + let inner_resolved = inner_result.resolved.clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: with_optional_cardinality(inner_resolved), @@ -912,8 +866,7 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) - { + if (field_child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -954,7 +907,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - (*rt_result.resolved).clone(); + rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -991,7 +944,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.resolved).clone()); + __result.push(fr.resolved.clone()); } __result }); @@ -1038,7 +991,7 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push((*vr.resolved).clone()); + __result.push(vr.resolved.clone()); } __result }); @@ -1114,7 +1067,7 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -1211,15 +1164,15 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: (*target_result.resolved).clone().children.clone(), - connective: (*target_result.resolved).clone().connective.clone(), + children: target_result.resolved.clone().children.clone(), + connective: target_result.resolved.clone().connective.clone(), params: Rc::new(vec![]), - inferred: (*target_result.resolved).clone().inferred.clone(), + inferred: target_result.resolved.clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1241,7 +1194,7 @@ pub fn resolve_node_bounded( uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1344,7 +1297,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = (*key_result.resolved).clone(); + let key_resolved = key_result.resolved.clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1352,7 +1305,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = (*val_result.resolved).clone(); + let val_resolved = val_result.resolved.clone(); let val_diags = val_result.diagnostics.clone(); let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) @@ -1451,10 +1404,9 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = (*el_result.resolved).clone(); + let el_resolved = el_result.resolved.clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() - != None) + let el_param_name = if (child_node.inferred.clone() != None) { authored_name(env.clone(), child_node.clone()) } else { @@ -1520,26 +1472,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = match n.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { node: target, .. }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = + match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: target, .. + }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) + > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1558,7 +1510,8 @@ pub fn resolve_node_bounded( == 0)) && (resolved.inferred.clone() != None)) { - match resolved.inferred + match resolved + .inferred .clone() .as_deref() .cloned() @@ -1586,14 +1539,14 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - (*resolve_node_bounded( + resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved) - .clone() + .resolved + .clone() } else { target.clone() } @@ -1616,8 +1569,7 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) - { + let n_is_error = if (n.inferred.clone() != None) { is_compiler_error( n.inferred.clone().clone().unwrap(), ) @@ -1626,14 +1578,14 @@ pub fn resolve_node_bounded( }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = - if (n.inferred.clone() != None) { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = if (n.inferred.clone() != None) + { + is_type_variable( + n.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1773,7 +1725,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), missing_generic_args_diagnostics( @@ -1800,7 +1752,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> type_resolved, field_node_cardinality(field.clone()), match default_resolved.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1816,7 +1768,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1864,7 +1816,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> None => Rc::new(vec![]), }; let default_expr = match default_resolved.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }; Rc::new(ParamResult { @@ -1888,7 +1840,7 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( @@ -1909,7 +1861,7 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( @@ -1934,7 +1886,7 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( @@ -1969,13 +1921,13 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = (*body_result.expr).clone(); + let body_expr = body_result.expr.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( arm_pattern(arm.clone()), match guard_result.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, body_expr, @@ -2000,7 +1952,7 @@ pub fn resolve_string_part( }), StringPart::Interpolation { expr: expr, .. } => { let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = (*expr_result.expr).clone(); + let resolved_expr = expr_result.expr.clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { @@ -2036,7 +1988,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - (*val_result.expr).clone(), + val_result.expr.clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2049,7 +2001,7 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -2074,7 +2026,7 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.expr).clone()); + __result.push(cr.expr.clone()); } __result }); @@ -2149,7 +2101,7 @@ pub fn resolve_expr_types( }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| (*r.expr).clone()), + expr: map_children(texpr.clone(), |child| r.expr.clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2175,7 +2127,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - (*vr.expr).clone(), + vr.expr.clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2188,7 +2140,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2244,7 +2196,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*rr.expr).clone(), + expr: rr.expr.clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2269,7 +2221,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - (*vr.expr).clone(), + vr.expr.clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2284,7 +2236,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2336,7 +2288,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*sr.expr).clone(), + expr: sr.expr.clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2375,8 +2327,8 @@ pub fn resolve_expr_types( Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some((*guard_r.expr).clone()), - (*body_r.expr).clone(), + Some(guard_r.expr.clone()), + body_r.expr.clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2405,7 +2357,7 @@ pub fn resolve_expr_types( None => Rc::new(MatchPattern::Wildcard), }, None, - (*body_r.expr).clone(), + body_r.expr.clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2421,7 +2373,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2467,12 +2419,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![ - (*cr.expr).clone(), - (*tr.expr).clone(), - (*r.expr).clone(), - ]), - None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), + Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( @@ -2508,8 +2456,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), - None => Rc::new(vec![(*vr.expr).clone()]), + Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![vr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( @@ -2545,7 +2493,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - (*vr.expr).clone(), + vr.expr.clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2558,7 +2506,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2598,7 +2546,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2645,7 +2593,7 @@ pub fn resolve_expr_types( op: op.clone(), algebra_field: af.clone(), }), - Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), + Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2663,7 +2611,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![(*r.expr).clone()]), + Rc::new(vec![r.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2690,7 +2638,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), + v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2715,7 +2663,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - (*r.expr).clone(), + r.expr.clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2733,7 +2681,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2769,7 +2717,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2811,7 +2759,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), + Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2838,7 +2786,7 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), + Rc::new(vec![cr.expr.clone(), br.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), @@ -2869,7 +2817,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), + Rc::new(vec![br.expr.clone(), ir.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2908,11 +2856,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![ - (*br.expr).clone(), - (*sr.expr).clone(), - (*er.expr).clone(), - ]), + Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2935,7 +2879,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*r.expr).clone()]), + Rc::new(vec![r.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -3084,7 +3028,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding.clone(), + tp_binding, ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3106,7 +3050,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push((*pr.param).clone()); + __result.push(pr.param.clone()); } __result }); @@ -3126,16 +3070,12 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) env.clone(), module_name.clone(), ), - _ => resolve_optional_node( - item.inferred.clone(), - env.clone(), - module_name.clone(), - ), + _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), } } else { resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; - let ret_resolved = (*ret_result.resolved).clone(); + let ret_resolved = ret_result.resolved.clone(); let ret_diags = ret_result.diagnostics.clone(); let resolved_ret = if (item.inferred.clone() == None) { None @@ -3156,7 +3096,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push((*ur.resource_use).clone()); + __result.push(ur.resource_use.clone()); } __result }); @@ -3182,7 +3122,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_body = if (item.body.clone() == None) { None } else { - Some((*body_resolved.expr).clone()) + Some(body_resolved.expr.clone()) }; let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) @@ -3204,7 +3144,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_anno = if (item.type_annotation.clone() == None) { None } else { - Some((*anno_resolved.resolved).clone()) + Some(anno_resolved.resolved.clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); let transport_resolved = if (item.transport.clone() == None) { @@ -3222,7 +3162,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_transport = if (item.transport.clone() == None) { None } else { - Some((*transport_resolved.transport).clone()) + Some(transport_resolved.transport.clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3239,7 +3179,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -3283,7 +3223,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: child.type_annotation.clone(), is_self_recursive: false, @@ -3299,9 +3239,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) - && (item.transport.clone() == None)) - { + if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3341,7 +3279,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: field.type_annotation.clone(), is_self_recursive: false, @@ -3359,7 +3297,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.item).clone()); + __result.push(fr.item.clone()); } __result }); @@ -3414,7 +3352,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.item).clone()); + __result.push(cr.item.clone()); } __result }); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 8d0917f731a..76923b77bc0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,7 +210,7 @@ pub fn expand_transitive_services_once( registry: Rc>>, ) -> Rc>> { modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { let has_no_body = (item.body.clone() == None); @@ -218,7 +218,7 @@ if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 5d4fde8c998..ef23eba9abf 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -498,8 +498,7 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) - { + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 74bdb302d18..27e0642597b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -866,9 +866,9 @@ pub fn instantiate_algebra_type( }; let inner_b = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, (*inner_b.ty).clone()); + let built = make_container_type(kind_name, inner_b.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -879,16 +879,16 @@ pub fn instantiate_algebra_type( let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -928,13 +928,13 @@ pub fn instantiate_algebra_type( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, (*rb.ty).clone()), + ty: make_callable_type(param_nodes, rb.ty.clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,7 +962,7 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -974,7 +974,7 @@ pub fn instantiate_algebra_field( __result }); let return_b = instantiate_algebra_type( - (*template.return_type).clone(), + template.return_type.clone(), base.clone(), source_indices.clone(), ); @@ -982,10 +982,10 @@ pub fn instantiate_algebra_field( algebra_method_field( template.name.clone(), param_types.clone(), - (*return_b.ty).clone(), + return_b.ty.clone(), ) } else { - algebra_value_field(template.name.clone(), (*return_b.ty).clone()) + algebra_value_field(template.name.clone(), return_b.ty.clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1017,7 +1017,7 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1475,9 +1475,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, (*inner_applied.ty).clone()); + let built = make_container_type(kind_name, inner_applied.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1492,7 +1492,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } @@ -1503,9 +1503,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1551,7 +1551,7 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1583,7 +1583,7 @@ pub fn apply_type_substitution( } __result }), - (*rb.ty).clone(), + rb.ty.clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1592,11 +1592,11 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self((*template.return_type).clone()) + is_receiver_self(template.return_type.clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable((*template.return_type).clone()) + has_type_variable(template.return_type.clone()) } pub fn has_type_variable(t: Rc) -> bool { @@ -1631,7 +1631,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - (*template.return_type).clone(), + template.return_type.clone(), subst, receiver_type.clone(), source_indices.clone(), @@ -2291,7 +2291,8 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left.inferred + match left + .inferred .clone() .as_deref() .cloned() @@ -2299,7 +2300,8 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right.inferred + }) => match right + .inferred .clone() .as_deref() .cloned() @@ -2639,11 +2641,7 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match (*m.field_node).clone().inferred - .clone() - .as_deref() - .cloned() - { + Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { match rt.inferred.clone().as_deref().cloned() { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index e0740a56f2b..0da15e2a8e5 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -187,17 +187,14 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items((*m.module).clone()); + let items = module_items(m.module.clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { __result.extend( (*check_bare_containers( item.clone(), - authored_name_at( - source_indices.clone(), - (*m.module).clone(), - ), + authored_name_at(source_indices.clone(), m.module.clone()), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index c1414cba6ac..b2340d2e960 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; +use crate::v1_std_core::CompilerDiagnostic::ParseError; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,11 +91,7 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream - .all - .clone() - .get((stream.pos.clone()) as usize) - .cloned() + stream.all.clone().get(stream.pos.clone() as usize).cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -2080,7 +2076,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some((*r.module).clone()), + module: Some(r.module.clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2235,7 +2231,7 @@ pub fn parse_imports_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.import).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.import.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2283,7 +2279,7 @@ pub fn parse_items_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.item).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.item.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -3426,7 +3422,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![(*rv.variant).clone()]), + Rc::new(vec![rv.variant.clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3504,7 +3500,7 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = (*r.variant).clone(); + let first_variant = r.variant.clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), @@ -3575,7 +3571,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3594,7 +3590,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3631,7 +3627,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3650,7 +3646,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3778,7 +3774,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -4299,11 +4295,11 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), Cardinality::Required, None, None, - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4479,7 +4475,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4677,7 +4673,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*ret.type_expr).clone(), + node: ret.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4712,10 +4708,10 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), None, - (*r.type_expr).clone().span.clone(), - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), + r.type_expr.clone().span.clone(), ); acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4762,7 +4758,7 @@ pub fn finish_type_expr_from_name( if has_err(r.err.clone()) { return r.clone(); } - let first_arg = (*r.type_expr).clone(); + let first_arg = r.type_expr.clone(); let type_args = collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { @@ -4920,7 +4916,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); + let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -5021,7 +5017,7 @@ pub fn parse_field_list_acc( }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); + let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -5083,7 +5079,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = __ec.clone(); @@ -5936,23 +5932,23 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - (*r3.type_expr).clone(), + r3.type_expr.clone(), start_span.clone(), r.span.clone(), ); @@ -6039,7 +6035,7 @@ pub fn parse_resource_config_acc( err: r3.err.clone(), }); } - let fi = make_field_init_node(field_name, (*r3.expr).clone(), zero_span, r.span.clone()); + let fi = make_field_init_node(field_name, r3.expr.clone(), zero_span, r.span.clone()); acc = v1_rt::rc_list_push(acc.clone(), fi); match (*eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { @@ -6075,7 +6071,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: (*r.type_expr).clone(), + node: r.type_expr.clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6241,7 +6237,7 @@ pub fn parse_service_after_kw( ); let svc_props = match r.config.clone() { Some(cfg) => service_config_properties( - (*cfg.endpoint).clone(), + cfg.endpoint.clone(), cfg.auth.clone(), cfg.auth_input.clone(), cfg.auth_source.clone(), @@ -6261,7 +6257,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some((*r.transport).clone()), + transport: Some(r.transport.clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6386,7 +6382,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = (*r.transport).clone(); + let __tco_2 = r.transport.clone(); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -6425,7 +6421,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); + let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6567,32 +6563,32 @@ pub fn parse_config_fields( }; match fname.as_str() { "endpoint" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); retry = __tco_0; continue; } @@ -6640,7 +6636,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6659,7 +6655,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6686,7 +6682,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6705,7 +6701,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6732,7 +6728,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6751,7 +6747,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6879,49 +6875,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), + let h = match (*r3.expr.clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -7060,7 +7056,7 @@ pub fn parse_shell_fields( }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7166,7 +7162,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7670,7 +7666,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some((*r.transport).clone()); + let __tco_2 = Some(r.transport.clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -8136,7 +8132,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = (*r.expr).clone(); + let code = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8165,7 +8161,7 @@ pub fn parse_exit_entries_acc( _ => r3.tokens.clone(), }; let code_str = status_expr_to_str(code, ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( prop_name, @@ -8174,10 +8170,10 @@ pub fn parse_exit_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8463,7 +8459,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8483,7 +8479,7 @@ pub fn parse_response_entries_acc( }); } let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( prop_name, @@ -8492,10 +8488,10 @@ pub fn parse_response_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8612,7 +8608,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8631,7 +8627,7 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = (*r3.expr).clone(); + let body = r3.expr.clone(); let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), @@ -8862,8 +8858,7 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = - v1_rt::rc_list_push(capabilities, (*r.capability).clone()); + let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8983,7 +8978,7 @@ pub fn parse_resource_entries( } let fi = make_field_init_node( fname, - (*r3.expr).clone(), + r3.expr.clone(), make_span(0, 0), r.span.clone(), ); @@ -9479,7 +9474,7 @@ pub fn parse_data_after_kw( err: r.err.clone(), }); } - let te = (*r.type_expr).clone(); + let te = r.type_expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r.err.clone()) { return Rc::new(ItemResult { @@ -9507,7 +9502,7 @@ pub fn parse_data_after_kw( inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some((*r.expr).clone()), + body: Some(r.expr.clone()), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -9592,7 +9587,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9665,7 +9660,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some((*r3.expr).clone()), + EatResult::EatConsumed { .. } => Some(r3.expr.clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { name: name, span: span, ident_span: Some(name_span), - children: Rc::new(vec![(*r3.expr).clone()]), + children: Rc::new(vec![r3.expr.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: ret.inferred.clone(), @@ -10110,7 +10105,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![(*r3.expr).clone()]), + Rc::new(vec![r3.expr.clone()]), None, span, name_span, @@ -10169,7 +10164,7 @@ pub fn parse_expr_bp( if has_err(r.err.clone()) { return r.clone(); } - let lhs = (*r.expr).clone(); + let lhs = r.expr.clone(); parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10204,7 +10199,7 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = (*post.expr).clone(); + let __tco_2 = post.expr.clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10266,7 +10261,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10275,7 +10270,7 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = (*r.expr).clone(); + let __tco_2 = r.expr.clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10290,7 +10285,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10309,7 +10304,7 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - (*r.expr).clone(), + r.expr.clone(), ]), None, loop_span, @@ -10520,7 +10515,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -11390,13 +11385,13 @@ pub fn parse_index_or_slice( let r = parse_expr(r.tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let first_expr = (*r.expr).clone(); + let first_expr = r.expr.clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11404,13 +11399,13 @@ pub fn parse_index_or_slice( let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let end_expr = (*r.expr).clone(); + let end_expr = r.expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11525,7 +11520,7 @@ pub fn parse_arg_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.arg).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.arg.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -11581,8 +11576,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some((*r.expr).clone()), + guard: Some(r.expr.clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12487,7 +12481,7 @@ pub fn parse_variant_pattern( } let fb = make_field_binding_node( "0".to_string(), - (*r.pattern).clone(), + r.pattern.clone(), span, kernel_span("0".to_string()), ); @@ -12573,7 +12567,7 @@ pub fn parse_variant_bindings_brace_acc( }); let fb = make_field_binding_node( field_name.clone(), - (*r2.pattern).clone(), + r2.pattern.clone(), bind_span, field_name_span, ); @@ -12637,7 +12631,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc(m: &HashMap) -> Vec { m.keys().cloned().collect() } +pub fn sorted_map_keys(m: &HashMap) -> Vec { + let mut keys = map_keys(m); + keys.sort(); + keys +} + pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -329,6 +335,40 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. +// take_owned_counted: the fail-closed replacement for the silent +// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: +// a failure arm must refuse or be counted, never silently widen). The ownership +// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose +// per-site frequency must stay observable, so the clone arm counts per emitted +// site (site = ":" of the use-site the emitter rewrote). +thread_local! { + static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = + std::cell::RefCell::new(HashMap::new()); +} + +pub fn take_owned_counted(x: Rc, site: &'static str) -> T { + Rc::try_unwrap(x).unwrap_or_else(|rc| { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); + (*rc).clone() + }) +} + +pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| { + let mut v: Vec<(String, u64)> = m + .borrow() + .iter() + .map(|(site, n)| (site.to_string(), *n)) + .collect(); + v.sort(); + v + }) +} + +pub fn reset_take_owned_clone_fallbacks() { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); +} + pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From 8623a275d7aacfab2fa474f68bf7ea08f0ffabdb Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 03:54:12 +0000 Subject: [PATCH 12/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/bin/regen_stage0.rs | 2 + src/v1/stage0/src/extdeps_cargo.rs | 14 +- src/v1/stage0/src/extdeps_cargo_version.rs | 6 +- .../stage0/src/extdeps_languages_go_types.rs | 2 +- .../src/extdeps_languages_python_types.rs | 2 +- .../stage0/src/extdeps_languages_rust_emit.rs | 4 +- src/v1/stage0/src/extdeps_uri.rs | 2 +- src/v1/stage0/src/extdeps_uri_path.rs | 29 +- src/v1/stage0/src/extdeps_version_semver.rs | 18 +- src/v1/stage0/src/std_computation.rs | 51 +- src/v1/stage0/src/std_effects.rs | 72 +- src/v1/stage0/src/std_graph.rs | 9 +- src/v1/stage0/src/std_http_path.rs | 42 +- src/v1/stage0/src/std_induction.rs | 123 +- src/v1/stage0/src/std_integer.rs | 38 +- src/v1/stage0/src/std_logic.rs | 5 - src/v1/stage0/src/std_measure.rs | 158 +- src/v1/stage0/src/std_nat.rs | 8 +- src/v1/stage0/src/std_realization_schedule.rs | 90 +- src/v1/stage0/src/std_termination.rs | 18 +- src/v1/stage0/src/std_types.rs | 4 +- src/v1/stage0/src/v1_compiler_artifact.rs | 2 +- src/v1/stage0/src/v1_compiler_coercion.rs | 16 +- src/v1/stage0/src/v1_compiler_compile.rs | 194 +- .../src/v1_compiler_compiler_tests_rust.rs | 32 +- src/v1/stage0/src/v1_compiler_complexity.rs | 1268 ++-- src/v1/stage0/src/v1_compiler_emit.rs | 526 +- .../src/v1_compiler_emit_core_support.rs | 55 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 101 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 80 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2479 ++++--- src/v1/stage0/src/v1_compiler_infer.rs | 5672 +++++++++-------- src/v1/stage0/src/v1_compiler_infer_access.rs | 16 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 17 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 22 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 270 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 63 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 150 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 63 +- .../stage0/src/v1_compiler_infer_patterns.rs | 294 +- .../stage0/src/v1_compiler_infer_resolve.rs | 988 +-- .../stage0/src/v1_compiler_infer_service.rs | 33 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 29 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 530 +- src/v1/stage0/src/v1_compiler_languages.rs | 24 +- src/v1/stage0/src/v1_compiler_normalize.rs | 37 +- src/v1/stage0/src/v1_compiler_ownership.rs | 135 +- src/v1/stage0/src/v1_compiler_parse.rs | 1519 +++-- src/v1/stage0/src/v1_compiler_resolve.rs | 32 +- .../stage0/src/v1_compiler_stage0_crates.rs | 4 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 90 +- src/v1/stage0/src/v1_compiler_trace.rs | 39 +- src/v1/stage0/src/v1_rt.rs | 17 +- src/v1/stage0/src/v1_std_core.rs | 258 +- 54 files changed, 7772 insertions(+), 7980 deletions(-) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 60ab5a5e5c8..7ede06053a0 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -73,6 +73,8 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "v1_compiler_compile.rs", "v1_compiler_compiler_tests_rust.rs", "v1_compiler_complexity.rs", + "v1_compiler_dag_collect.rs", + "v1_compiler_dag_collect_support.rs", "v1_compiler_effect_derivation.rs", "v1_compiler_emit.rs", "v1_compiler_emit_core_support.rs", diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 3de394df2a6..f9572bb101d 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -64,14 +64,14 @@ pub fn default_rust_edition() -> RustEdition { CACHED.with(|c: &RustEdition| c.clone()) } -pub fn min_cargo_version() -> CargoToolVersionFloor { +pub fn min_cargo_version() -> SemVerConstraint { thread_local! { - static CACHED: CargoToolVersionFloor = { + static CACHED: SemVerConstraint = { serde_json::from_value(serde_json::json!(">= 1.56")) .expect("valid data definition") }; } - CACHED.with(|c: &CargoToolVersionFloor| c.clone()) + CACHED.with(|c: &SemVerConstraint| c.clone()) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -139,7 +139,7 @@ pub fn cargo_target_source_path( segments: Rc::new(vec![ "src".to_string(), "bin".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), + v1_rt::concat(name, ".rs".to_string()), ]), }) } @@ -147,19 +147,19 @@ pub fn cargo_target_source_path( CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "tests".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), + v1_rt::concat(name, ".rs".to_string()), ]), }), CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "examples".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), + v1_rt::concat(name, ".rs".to_string()), ]), }), CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "benches".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), + v1_rt::concat(name, ".rs".to_string()), ]), }), } diff --git a/src/v1/stage0/src/extdeps_cargo_version.rs b/src/v1/stage0/src/extdeps_cargo_version.rs index ecec54e6a94..8457d1c1876 100644 --- a/src/v1/stage0/src/extdeps_cargo_version.rs +++ b/src/v1/stage0/src/extdeps_cargo_version.rs @@ -28,11 +28,11 @@ pub fn extdeps_external_authority_anchor() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub type CargoPackageVersion = SemVerIdentity; +pub type CargoPackageVersion = VersionIdentity; -pub type CargoVersionRequirement = SemVerConstraint; +pub type CargoVersionRequirement = VersionConstraint; -pub type CargoToolVersionFloor = SemVerConstraint; +pub type CargoToolVersionFloor = VersionConstraint; pub fn default_stage0_package_version() -> String { thread_local! { diff --git a/src/v1/stage0/src/extdeps_languages_go_types.rs b/src/v1/stage0/src/extdeps_languages_go_types.rs index b4715e2dbde..699cea85247 100644 --- a/src/v1/stage0/src/extdeps_languages_go_types.rs +++ b/src/v1/stage0/src/extdeps_languages_go_types.rs @@ -4,7 +4,7 @@ pub use crate::extdeps_external_authority::ExternalAuthority; use crate::extdeps_uri::UriScheme::Https; pub use crate::extdeps_uri::{Uri, UriScheme}; -pub use crate::std_coercion::{CallableRepr, CastSyntax, InhabitantDecl, TypeCheckpoint}; +pub use crate::std_coercion::{CallableRepr, CastRule, CastSyntax, InhabitantDecl, TypeCheckpoint}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index f64787e8873..b4c3a4195fa 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -5,7 +5,7 @@ use self::PythonTypeKind::*; pub use crate::extdeps_external_authority::ExternalAuthority; use crate::extdeps_uri::UriScheme::Https; pub use crate::extdeps_uri::{Uri, UriScheme}; -pub use crate::std_coercion::{CallableRepr, CastSyntax, InhabitantDecl, TypeCheckpoint}; +pub use crate::std_coercion::{CallableRepr, CastRule, CastSyntax, InhabitantDecl, TypeCheckpoint}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 328ecc12d3d..9ace4c79b53 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -536,8 +536,8 @@ pub fn is_rt_function(name: String) -> bool { pub fn rt_bridge_name(name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), name.clone()) { - Some(bridge) => bridge.clone(), - None => name.clone(), + Some(bridge) => bridge, + None => name, } } diff --git a/src/v1/stage0/src/extdeps_uri.rs b/src/v1/stage0/src/extdeps_uri.rs index a60e44657d0..41675e15268 100644 --- a/src/v1/stage0/src/extdeps_uri.rs +++ b/src/v1/stage0/src/extdeps_uri.rs @@ -138,7 +138,7 @@ pub fn parse_href_scheme(url: String) -> Rc { }) } else { if (v1_rt::starts_with(s.clone(), "mailto:".to_string()) - || v1_rt::starts_with(s.clone(), "MAILTO:".to_string())) + || v1_rt::starts_with(s, "MAILTO:".to_string())) { Rc::new(ParsedHrefScheme::HrefScheme { scheme: UriScheme::Mailto, diff --git a/src/v1/stage0/src/extdeps_uri_path.rs b/src/v1/stage0/src/extdeps_uri_path.rs index 37d17b8ee15..2a4214c593b 100644 --- a/src/v1/stage0/src/extdeps_uri_path.rs +++ b/src/v1/stage0/src/extdeps_uri_path.rs @@ -88,8 +88,8 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let after_open = match before_and_rest.clone().get(1 as usize).cloned() { - Some(r) => r.clone(), + let after_open = match before_and_rest.get(1 as usize).cloned() { + Some(r) => r, None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -112,7 +112,7 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }); } let param_name = match name_and_suffix.clone().first().cloned() { - Some(p) => p.clone(), + Some(p) => p, None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -121,8 +121,8 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let suffix = match name_and_suffix.clone().get(1 as usize).cloned() { - Some(s) => s.clone(), + let suffix = match name_and_suffix.get(1 as usize).cloned() { + Some(s) => s, None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -131,9 +131,7 @@ pub fn parse_segment_tokens(seg: String) -> Rc { } }; let prefix_tokens = if (prefix.clone() != "".to_string()) { - Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { - text: prefix.clone(), - })]) + Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: prefix })]) } else { Rc::new(vec![]) }; @@ -151,9 +149,9 @@ pub fn parse_segment_tokens(seg: String) -> Rc { } else { Rc::new(vec![]) }; - if (((param_name.clone() == "".to_string()) + if (((param_name == "".to_string()) || v1_rt::contains(suffix.clone(), "{".to_string())) - || v1_rt::contains(suffix.clone(), "}".to_string())) + || v1_rt::contains(suffix, "}".to_string())) { Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -182,7 +180,7 @@ pub fn parse_path_template(raw: String) -> Rc { .first() .cloned() { - Some(p) => p.clone(), + Some(p) => p, None => raw.clone(), }; let segments = Rc::new({ @@ -208,15 +206,15 @@ pub fn parse_path_template(raw: String) -> Rc { tokens: Rc::new(vec![]), }), }), - Some(first_seg) => match (*parse_segment_tokens(first_seg.clone())).clone() { + Some(first_seg) => match (*parse_segment_tokens(first_seg)).clone() { PathSegmentTokensResult::MalformedPathSegment { segment: s, reason: r, .. } => Rc::new(PathTemplateParseResult::MalformedPathTemplate { raw: raw.clone(), - segment: s.clone(), - reason: r.clone(), + segment: s, + reason: r, }), PathSegmentTokensResult::ParsedSegmentTokens { tokens: first_tokens, @@ -224,7 +222,6 @@ pub fn parse_path_template(raw: String) -> Rc { } => { let parsed = Rc::new( segments - .clone() .iter() .cloned() .skip(1 as usize) @@ -235,7 +232,7 @@ pub fn parse_path_template(raw: String) -> Rc { .fold( Rc::new(PathTemplateParseResult::ParsedPathTemplate { template: Rc::new(PathTemplate { - tokens: first_tokens.clone(), + tokens: first_tokens, }), }), |acc: Rc, seg: String| match (*acc.clone()).clone() diff --git a/src/v1/stage0/src/extdeps_version_semver.rs b/src/v1/stage0/src/extdeps_version_semver.rs index 03bc8938a22..8802a372920 100644 --- a/src/v1/stage0/src/extdeps_version_semver.rs +++ b/src/v1/stage0/src/extdeps_version_semver.rs @@ -55,7 +55,7 @@ pub struct SemVerVersion { pub build: Rc>>, } -pub fn semver_compare_non_negative_int(a: NonNegativeInt, b: NonNegativeInt) -> Ordering { +pub fn semver_compare_non_negative_int(a: Nat, b: Nat) -> Ordering { nat_compare(a, b) } @@ -63,7 +63,7 @@ pub fn semver_compare_identifier(a: Rc, b: Rc match (*b).clone() { SemVerIdentifier::SemVerNumericIdentifier { value: bv, .. } => { - semver_compare_non_negative_int(av.clone(), bv.clone()) + semver_compare_non_negative_int(av, bv) } SemVerIdentifier::SemVerAlphanumericIdentifier { label: _, .. } => Ordering::Less, }, @@ -73,7 +73,7 @@ pub fn semver_compare_identifier(a: Rc, b: Rc bl.clone()) { + if (al > bl) { Ordering::Greater } else { Ordering::Equal @@ -142,20 +142,20 @@ pub fn semver_compare(a: Rc, b: Rc) -> Ordering { Ordering::Equal => { semver_compare_pre_release(a.pre_release.clone(), b.pre_release.clone()) } - other => other.clone(), + other => other, } } - other => other.clone(), + other => other, } } - other => other.clone(), + other => other, } } pub fn semver_identifier_label(id: Rc) -> String { match (*id).clone() { - SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v.clone()), - SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s.clone(), + SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v), + SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s, } } @@ -212,7 +212,7 @@ pub fn semver_identity_compare(a: NonEmptyStr, b: NonEmptyStr) -> Ordering { if (a.clone() == b.clone()) { Ordering::Equal } else { - if (a.clone() < b.clone()) { + if (a < b) { Ordering::Less } else { Ordering::Greater diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 320be281a1c..f8b02f3de4f 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -30,13 +30,22 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub fn subtree_size_rename_marker() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c) collision fix: SizeBound's tree bound arm was named TreeSize, colliding with RankingDimension.TreeSize (std.termination) in this module's own scope once one arm name may have only one owner. Renamed to SubtreeSize — the more precise fact: a tree-descent bound measures the shrinking SUBTREE consumed per step. RankingDimension.TreeSize (the ranking-dimension taxonomy, ~12 sites in v1.complexity/induction) keeps the shared name.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeBound { CollectionSize { param: String }, ParserStreamSize { witness: String }, WorklistDrainSize { element: String }, - TreeSize { param: String }, + SubtreeSize { param: String }, ArithmeticParam { param: String }, ExplicitCountZero, ExplicitCountPositive { steps: Rc }, @@ -44,7 +53,7 @@ pub enum SizeBound { } pub fn tree_size_bound(param: String) -> Rc { - Rc::new(SizeBound::TreeSize { param: param }) + Rc::new(SizeBound::SubtreeSize { param: param }) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -107,7 +116,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { match (*pattern).clone() { CallPattern::ChildAccessorCall { accessor: a, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Descend, - bound: Rc::new(SizeBound::TreeSize { param: a.clone() }), + bound: Rc::new(SizeBound::SubtreeSize { param: a }), evidence: DescentEvidence::Strict, factor: None, }), @@ -117,9 +126,9 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::CollectionSize { param: c.clone() }), + bound: Rc::new(SizeBound::CollectionSize { param: c }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p.clone() })), + factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p })), }), CallPattern::ArithmeticSubtractCall { steps: p, @@ -127,9 +136,9 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: r.clone() }), + bound: Rc::new(SizeBound::ArithmeticParam { param: r }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p.clone() })), + factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p })), }), CallPattern::ArithmeticDivideCall { divisor: d, @@ -137,21 +146,19 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: r.clone() }), + bound: Rc::new(SizeBound::ArithmeticParam { param: r }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ProportionalShrink { - divisor: d.clone(), - })), + factor: Some(Rc::new(ShrinkFactor::ProportionalShrink { divisor: d })), }), CallPattern::ParserAdvanceCall { witness: w, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::ParserStreamSize { witness: w.clone() }), + bound: Rc::new(SizeBound::ParserStreamSize { witness: w }), evidence: DescentEvidence::Strict, factor: None, }), CallPattern::WorklistDrainCall { element: e, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::WorklistDrainSize { element: e.clone() }), + bound: Rc::new(SizeBound::WorklistDrainSize { element: e }), evidence: DescentEvidence::Strict, factor: None, }), @@ -160,7 +167,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::CollectionSize { param: oc.clone() }), + bound: Rc::new(SizeBound::CollectionSize { param: oc }), evidence: DescentEvidence::NonIncreasing, factor: None, }), @@ -175,11 +182,11 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { pub fn size_bound_param(bound: Rc) -> Option { match (*bound).clone() { - SizeBound::TreeSize { param: p, .. } => Some(p.clone()), - SizeBound::CollectionSize { param: p, .. } => Some(p.clone()), - SizeBound::ParserStreamSize { witness: w, .. } => Some(w.clone()), - SizeBound::WorklistDrainSize { element: e, .. } => Some(e.clone()), - SizeBound::ArithmeticParam { param: p, .. } => Some(p.clone()), + SizeBound::SubtreeSize { param: p, .. } => Some(p), + SizeBound::CollectionSize { param: p, .. } => Some(p), + SizeBound::ParserStreamSize { witness: w, .. } => Some(w), + SizeBound::WorklistDrainSize { element: e, .. } => Some(e), + SizeBound::ArithmeticParam { param: p, .. } => Some(p), SizeBound::ExplicitCountZero => None, SizeBound::ExplicitCountPositive { steps: _, .. } => None, SizeBound::Forever => None, @@ -202,9 +209,7 @@ pub fn forever_iteration_bound() -> i64 { pub fn constant_bound_value(bound: Rc) -> Option { match (*bound).clone() { SizeBound::ExplicitCountZero => Some(0), - SizeBound::ExplicitCountPositive { steps: s, .. } => { - Some(positive_descent_count(s.clone())) - } + SizeBound::ExplicitCountPositive { steps: s, .. } => Some(positive_descent_count(s)), SizeBound::Forever => Some(forever_iteration_bound()), _ => None, } @@ -237,7 +242,7 @@ pub fn type_iteration_dimension(type_name: String) -> Option Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { - Some(p) => algebra_profile_to_dimension(p.clone()), + Some(p) => algebra_profile_to_dimension(p), None => None, } } diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index c882f608192..2b6069dd71f 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -84,7 +84,7 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { EffectShape::ReadEffect => true, EffectShape::UpsertEffect { .. } => true, EffectShape::DeleteEffect { .. } => true, - EffectShape::CreateEffect { cause: cause, .. } => match (*cause.clone()).clone() { + EffectShape::CreateEffect { cause: cause, .. } => match (*cause).clone() { CreateCause::CreateIfAbsent { key_source: key_source, .. @@ -98,15 +98,15 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { pub fn key_source_eq(left: Rc, right: Rc) -> bool { match (*left).clone() { KeySource::PathParam { param: pa, .. } => match (*right).clone() { - KeySource::PathParam { param: pb, .. } => (pa.clone() == pb.clone()), + KeySource::PathParam { param: pb, .. } => (pa == pb), _ => false, }, KeySource::InputField { field: fa, .. } => match (*right).clone() { - KeySource::InputField { field: fb, .. } => (fa.clone() == fb.clone()), + KeySource::InputField { field: fb, .. } => (fa == fb), _ => false, }, KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { - KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), + KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa, fb), _ => false, }, } @@ -114,7 +114,7 @@ pub fn key_source_eq(left: Rc, right: Rc) -> bool { pub fn create_effect_is_dedupable(shape: Rc) -> bool { match (*shape).clone() { - EffectShape::CreateEffect { cause: cause, .. } => match (*cause.clone()).clone() { + EffectShape::CreateEffect { cause: cause, .. } => match (*cause).clone() { CreateCause::CreateIfAbsent { key_source: key_source, .. @@ -127,16 +127,12 @@ pub fn create_effect_is_dedupable(shape: Rc) -> bool { pub fn create_double_init_collapsible(a: Rc, b: Rc) -> bool { match (*a).clone() { - EffectShape::CreateEffect { cause: cause_a, .. } => match (*cause_a.clone()).clone() { + EffectShape::CreateEffect { cause: cause_a, .. } => match (*cause_a).clone() { CreateCause::CreateIfAbsent { key_source: ka, .. } => match (*b).clone() { - EffectShape::CreateEffect { cause: cause_b, .. } => { - match (*cause_b.clone()).clone() { - CreateCause::CreateIfAbsent { key_source: kb, .. } => { - key_source_eq(ka.clone(), kb.clone()) - } - CreateCause::PostAlways => false, - } - } + EffectShape::CreateEffect { cause: cause_b, .. } => match (*cause_b).clone() { + CreateCause::CreateIfAbsent { key_source: kb, .. } => key_source_eq(ka, kb), + CreateCause::PostAlways => false, + }, _ => false, }, CreateCause::PostAlways => false, @@ -171,26 +167,28 @@ impl CompositionVerdict { } pub fn compose_effects(effects: Rc>>) -> Rc { - { - let non_idempotent = Rc::new({ - let mut __result = Vec::new(); - for e in effects.iter().cloned() { - if match (*e.evidence.clone()).clone() { - IdempotencyEvidence::NonIdempotent { .. } => true, - _ => false, - } { - __result.push(e); + effects.iter().cloned().fold( + Rc::new(CompositionVerdict::IdempotentComposition), + |acc: Rc, e: Rc| match (*acc.clone()).clone() { + CompositionVerdict::BrokenBy { + first_breaker: breaker, + .. + } => acc.clone(), + CompositionVerdict::IdempotentComposition => match (*e.evidence.clone()).clone() { + IdempotencyEvidence::NonIdempotent { shape, reason, .. } => { + Rc::new(CompositionVerdict::BrokenBy { + first_breaker: e.clone(), + }) } - } - __result - }); - match non_idempotent.first().cloned() { - Some(op) => Rc::new(CompositionVerdict::BrokenBy { - first_breaker: op.clone(), - }), - None => Rc::new(CompositionVerdict::IdempotentComposition), - } - } + IdempotencyEvidence::LatticeEffect { shape: shape, .. } => { + Rc::new(CompositionVerdict::IdempotentComposition) + } + IdempotencyEvidence::IdentityEffect => { + Rc::new(CompositionVerdict::IdempotentComposition) + } + }, + }, + ) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -226,7 +224,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::DeleteEffect { - key_source: Rc::new(KeySource::PathParam { param: p.clone() }), + key_source: Rc::new(KeySource::PathParam { param: p }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -234,7 +232,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::UpsertEffect { - key_source: Rc::new(KeySource::PathParam { param: p.clone() }), + key_source: Rc::new(KeySource::PathParam { param: p }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -242,7 +240,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::UpsertEffect { - key_source: Rc::new(KeySource::PathParam { param: p.clone() }), + key_source: Rc::new(KeySource::PathParam { param: p }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -321,7 +319,7 @@ pub fn check_modifier_vs_derivation( }), } } else { - if (!declared_idempotent.clone() && derived_idempotent.clone()) { + if (!declared_idempotent.clone() && derived_idempotent) { match (*op.shape.clone()).clone() { EffectShape::CreateEffect { ref cause, .. } => { let CreateCause::CreateIfAbsent { diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index 5d20b69f286..a719554dcf6 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -151,7 +151,7 @@ pub fn dfs_finish_order( { let next_visited = v1_rt::rc_set_insert(acc.visited.clone(), node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { - Some(ns) => ns.clone(), + Some(ns) => ns, None => Rc::new(vec![]), }; let explored = neighbors.iter().cloned().fold( @@ -185,7 +185,7 @@ pub fn dfs_collect_component( let next_visited = v1_rt::rc_set_insert(acc.visited.clone(), node.clone()); let next_members = v1_rt::rc_list_push(acc.members.clone(), node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { - Some(ns) => ns.clone(), + Some(ns) => ns, None => Rc::new(vec![]), }; neighbors.iter().cloned().fold( @@ -314,9 +314,8 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> } __result }); - let nd_graph = - build_call_graph_from_proof_edges(members.clone(), non_descending.clone()); - (graph_has_multi_node_scc(members.clone(), nd_graph) == false) + let nd_graph = build_call_graph_from_proof_edges(members.clone(), non_descending); + (graph_has_multi_node_scc(members, nd_graph) == false) } } } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index 4a36b0a2aa3..4d860a887d2 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -54,11 +54,49 @@ pub fn last_path_param(template: Rc) -> Option { __result }); match params.last().cloned() { - Some(tok) => match (*tok.clone()).clone() { - UrlPathToken::ParamToken { name: n, .. } => Some(n.clone()), + Some(tok) => match (*tok).clone() { + UrlPathToken::ParamToken { name: n, .. } => Some(n), UrlPathToken::LiteralToken { .. } => None, }, None => None, } } } + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct PathParamBinding { + pub name: String, + pub value: String, +} + +pub fn path_param_value(params: Rc>>, name: String) -> String { + params.iter().cloned().fold( + "".to_string(), + |acc: String, binding: Rc| { + if (acc.clone() != "".to_string()) { + acc.clone() + } else { + if (binding.name.clone() == name.clone()) { + binding.value.clone() + } else { + acc.clone() + } + } + }, + ) +} + +pub fn render_path_template( + template: Rc, + params: Rc>>, +) -> String { + template.tokens.clone().iter().cloned().fold( + "".to_string(), + |acc: String, tok: Rc| match (*tok.clone()).clone() { + UrlPathToken::LiteralToken { text: t, .. } => v1_rt::concat(acc.clone(), t.clone()), + UrlPathToken::ParamToken { name: n, .. } => { + v1_rt::concat(acc.clone(), path_param_value(params.clone(), n.clone())) + } + }, + ) +} diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index a4a5073c4ad..9545f3dba2d 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -121,13 +121,13 @@ pub enum SubValueRelation { pub fn sub_value_to_evidence(relation: Rc) -> DescentEvidence { match (*relation).clone() { - SubValueRelation::StrictSubValue { factor: f, .. } => match (*f.clone()).clone() { + SubValueRelation::StrictSubValue { factor: f, .. } => match (*f).clone() { ShrinkFactor::UnitShrink => DescentEvidence::Strict, ShrinkFactor::ConstantShrink { steps: _, .. } => DescentEvidence::Strict, ShrinkFactor::ProportionalShrink { divisor: _, .. } => DescentEvidence::Strict, }, SubValueRelation::IteratedSubValue { field: _, .. } => DescentEvidence::Strict, - SubValueRelation::ArithmeticDescent { factor: f, .. } => match (*f.clone()).clone() { + SubValueRelation::ArithmeticDescent { factor: f, .. } => match (*f).clone() { ShrinkFactor::UnitShrink => DescentEvidence::Strict, ShrinkFactor::ConstantShrink { steps: _, .. } => DescentEvidence::Strict, ShrinkFactor::ProportionalShrink { divisor: _, .. } => DescentEvidence::Strict, @@ -148,13 +148,13 @@ pub fn shrink_factor_eq(a: Rc, b: Rc) -> bool { }, ShrinkFactor::ConstantShrink { steps: sa, .. } => match (*b).clone() { ShrinkFactor::ConstantShrink { steps: sb, .. } => { - (positive_descent_count(sa.clone()) == positive_descent_count(sb.clone())) + (positive_descent_count(sa) == positive_descent_count(sb)) } _ => false, }, ShrinkFactor::ProportionalShrink { divisor: da, .. } => match (*b).clone() { ShrinkFactor::ProportionalShrink { divisor: db, .. } => { - (proportional_divisor_to_int(da.clone()) == proportional_divisor_to_int(db.clone())) + (proportional_divisor_to_int(da) == proportional_divisor_to_int(db)) } _ => false, }, @@ -172,16 +172,11 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) field: fb, factor: fac_b, .. - } => { - (inductive_field_eq(fa.clone(), fb.clone()) - && shrink_factor_eq(fac_a.clone(), fac_b.clone())) - } + } => (inductive_field_eq(fa, fb) && shrink_factor_eq(fac_a, fac_b)), _ => false, }, SubValueRelation::IteratedSubValue { field: fa, .. } => match (*b).clone() { - SubValueRelation::IteratedSubValue { field: fb, .. } => { - inductive_field_eq(fa.clone(), fb.clone()) - } + SubValueRelation::IteratedSubValue { field: fb, .. } => inductive_field_eq(fa, fb), _ => false, }, SubValueRelation::ArithmeticDescent { @@ -193,7 +188,7 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) param: pb, factor: fac_b, .. - } => ((pa.clone() == pb.clone()) && shrink_factor_eq(fac_a.clone(), fac_b.clone())), + } => ((pa == pb) && shrink_factor_eq(fac_a, fac_b)), _ => false, }, SubValueRelation::PreservedValue => match (*b).clone() { @@ -244,7 +239,7 @@ pub fn sub_value_level(r: Rc) -> i64 { pub fn meet_sub_value(a: Rc, b: Rc) -> Rc { if sub_value_structural_eq(a.clone(), b.clone()) { - a.clone() + a } else { { let la = sub_value_level(a.clone()); @@ -255,16 +250,16 @@ pub fn meet_sub_value(a: Rc, b: Rc) -> Rc, b: Rc) -> Rc, b: Rc) -> Rc { if sub_value_structural_eq(a.clone(), b.clone()) { - a.clone() + a } else { { let la = sub_value_level(a.clone()); let lb = sub_value_level(b.clone()); if (la.clone() == 0) { - b.clone() + b } else { if (lb.clone() == 0) { - a.clone() + a } else { if ((la.clone() == 4) || (lb.clone() == 4)) { Rc::new(SubValueRelation::MixedTop) } else { - if (la.clone() == 1) { - b.clone() + if (la == 1) { + b } else { - if (lb.clone() == 1) { - a.clone() + if (lb == 1) { + a } else { - if (is_strict_style_structural(a.clone()) - && is_strict_style_structural(b.clone())) + if (is_strict_style_structural(a) && is_strict_style_structural(b)) { Rc::new(SubValueRelation::StrictAxisErased) } else { @@ -360,17 +354,17 @@ pub fn compose_sub_value_relations( _ => Rc::new(SubValueRelation::MixedTop), }, SubValueRelation::StrictSubValue { .. } => match (*arg_rel).clone() { - SubValueRelation::PreservedValue => callee_rel.clone(), + SubValueRelation::PreservedValue => callee_rel, SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::StrictSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f.clone(), + field: f, factor: Rc::new(ShrinkFactor::UnitShrink), }) } SubValueRelation::IteratedSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f.clone(), + field: f, factor: Rc::new(ShrinkFactor::UnitShrink), }) } @@ -382,17 +376,17 @@ pub fn compose_sub_value_relations( SubValueRelation::MixedTop => Rc::new(SubValueRelation::MixedTop), }, SubValueRelation::IteratedSubValue { field: _, .. } => match (*arg_rel).clone() { - SubValueRelation::PreservedValue => callee_rel.clone(), + SubValueRelation::PreservedValue => callee_rel, SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::StrictSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f.clone(), + field: f, factor: Rc::new(ShrinkFactor::UnitShrink), }) } SubValueRelation::IteratedSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f.clone(), + field: f, factor: Rc::new(ShrinkFactor::UnitShrink), }) } @@ -409,8 +403,8 @@ pub fn compose_sub_value_relations( .. } => match (*arg_rel).clone() { SubValueRelation::PreservedValue => Rc::new(SubValueRelation::ArithmeticDescent { - param: p.clone(), - factor: f.clone(), + param: p, + factor: f, }), SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::NonIncreasingValue => Rc::new(SubValueRelation::NonIncreasingValue), @@ -437,22 +431,22 @@ pub fn sub_value_to_call_pattern(relation: Rc) -> Option match (*f.clone()).clone() { + } => match (*f).clone() { ShrinkFactor::ConstantShrink { steps: steps, .. } => { Some(Rc::new(CallPattern::ArithmeticSubtractCall { - steps: steps.clone(), - ring_param: p.clone(), + steps: steps, + ring_param: p, })) } ShrinkFactor::ProportionalShrink { divisor: d, .. } => { Some(Rc::new(CallPattern::ArithmeticDivideCall { - divisor: d.clone(), - ring_param: p.clone(), + divisor: d, + ring_param: p, })) } ShrinkFactor::UnitShrink => Some(Rc::new(CallPattern::ArithmeticSubtractCall { steps: Rc::new(PositiveDescentAmount::OneStep), - ring_param: p.clone(), + ring_param: p, })), }, SubValueRelation::PreservedValue => Some(Rc::new(CallPattern::SameArgumentCall)), @@ -473,7 +467,7 @@ pub fn sub_value_to_lowering_target(relation: Rc) -> Option Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, @@ -489,9 +483,9 @@ pub fn sub_value_to_lowering_target(relation: Rc) -> Option Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: p.clone() }), + bound: Rc::new(SizeBound::ArithmeticParam { param: p }), evidence: DescentEvidence::Strict, - factor: Some(fac.clone()), + factor: Some(fac), })), SubValueRelation::PreservedValue => Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, @@ -624,9 +618,7 @@ pub fn cost_poly(param: String, degree: i64) -> Rc { Some(deg) => Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { param: param, - exponent: Rc::new(PolynomialExponent::IntegerExpPos { - degree: deg.clone(), - }), + exponent: Rc::new(PolynomialExponent::IntegerExpPos { degree: deg }), }), }), None => Rc::new(CostBound::ErrorBound), @@ -645,7 +637,7 @@ pub fn cost_root(param: String, k: i64) -> Rc { param: param, exponent: Rc::new(PolynomialExponent::FractionExp { numerator: Rc::new(PositiveDescentAmount::OneStep), - root: rw.clone(), + root: rw, }), }), }), @@ -804,7 +796,7 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { if (base.clone() == (0 - 1)) { { let half = (e.clone() / 2); - if ((half.clone() + half.clone()) == e.clone()) { + if ((half.clone() + half) == e) { Some(1) } else { Some((0 - 1)) @@ -812,9 +804,8 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { } } else { match int_pow_bounded(base.clone(), (exp.clone() - 1)) { - Some(prev) => match int_mul_checked(base.clone(), prev.clone()) - { - Some(prod) => Some(prod.clone()), + Some(prev) => match int_mul_checked(base.clone(), prev) { + Some(prod) => Some(prod), None => None, }, None => None, @@ -839,13 +830,13 @@ pub fn ceil_log(base: i64, argument: i64) -> Option { pub fn ceil_log_iter(mut base: i64, mut argument: i64, mut k: i64, mut power: i64) -> Option { loop { if (power.clone() >= argument.clone()) { - break Some(k); + break Some(k.clone()); } else { match int_mul_checked(power.clone(), base.clone()) { None => { break None; } - Some(next_power) => match int_add_checked(k, 1) { + Some(next_power) => match int_add_checked(k.clone(), 1) { None => { break None; } @@ -879,42 +870,40 @@ pub fn master_theorem(form: Rc) -> Rc { if (a.clone() < b_to_d.clone()) { match d_ok.clone() { 0 => Rc::new(CostBound::ConstantBound), - _ => cost_poly(n.clone(), d_ok.clone()), + _ => cost_poly(n, d_ok), } } else { - if (a.clone() == b_to_d.clone()) { + if (a.clone() == b_to_d) { match d_ok.clone() { - 0 => cost_log(n.clone()), - _ => match positive_descent_amount_from_positive_int( - d_ok.clone(), - ) { + 0 => cost_log(n), + _ => match positive_descent_amount_from_positive_int(d_ok) { Some(deg) => Rc::new(CostBound::ProductBound { factors: Rc::new(vec![ Rc::new(AtomicCost::PolyCost { param: n.clone(), exponent: Rc::new( PolynomialExponent::IntegerExpPos { - degree: deg.clone(), + degree: deg, }, ), }), - Rc::new(AtomicCost::LogCost { param: n.clone() }), + Rc::new(AtomicCost::LogCost { param: n }), ]), }), None => Rc::new(CostBound::ErrorBound), }, } } else { - match proportional_divisor_from_int_at_least_two(b.clone()) { + match proportional_divisor_from_int_at_least_two(b) { Some(base_w) => { - match positive_descent_amount_from_positive_int(a.clone()) { + match positive_descent_amount_from_positive_int(a) { Some(arg_w) => Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { - param: n.clone(), + param: n, exponent: Rc::new( PolynomialExponent::LogBasedExp { - base: base_w.clone(), - argument: arg_w.clone(), + base: base_w, + argument: arg_w, }, ), }), @@ -975,7 +964,7 @@ pub fn derive_bound( master_theorem(Rc::new(RecurrenceForm { param: param, branches: branches.clone(), - divisor: proportional_divisor_to_int(d.clone()), + divisor: proportional_divisor_to_int(d), work_exponent: work_exponent.clone(), })) } diff --git a/src/v1/stage0/src/std_integer.rs b/src/v1/stage0/src/std_integer.rs index a17979ff245..63ad6def75c 100644 --- a/src/v1/stage0/src/std_integer.rs +++ b/src/v1/stage0/src/std_integer.rs @@ -13,20 +13,30 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Int8 = - crate::std_machine_constraints::Compose>; +pub type Int8 = crate::std_machine_constraints::Compose< + Int>, + crate::std_machine_constraints::MachineWidth<()>, +>; -pub type Int16 = - crate::std_machine_constraints::Compose>; +pub type Int16 = crate::std_machine_constraints::Compose< + Int>, + crate::std_machine_constraints::MachineWidth<()>, +>; -pub type Int32 = - crate::std_machine_constraints::Compose>; +pub type Int32 = crate::std_machine_constraints::Compose< + Int>, + crate::std_machine_constraints::MachineWidth<()>, +>; -pub type Int64 = - crate::std_machine_constraints::Compose>; +pub type Int64 = crate::std_machine_constraints::Compose< + Int>, + crate::std_machine_constraints::MachineWidth<()>, +>; -pub type Int128 = - crate::std_machine_constraints::Compose>; +pub type Int128 = crate::std_machine_constraints::Compose< + Int>, + crate::std_machine_constraints::MachineWidth<()>, +>; pub type UInt8 = crate::std_machine_constraints::Compose>; @@ -45,10 +55,10 @@ pub type UInt128 = pub type Int = i64; -pub type UInt = i64; +pub type UInt = Rc>; pub type IntPlatform = crate::std_machine_constraints::Compose< - i64, + Int>, crate::std_machine_constraints::MachineWidth, >; @@ -57,6 +67,6 @@ pub type UIntPlatform = crate::std_machine_constraints::Compose< crate::std_machine_constraints::MachineWidth, >; -pub type NonNegativeInt = i64; +pub type NonNegativeInt = Rc>; -pub type PositiveInt = Nat; +pub type PositiveInt = Rc>; diff --git a/src/v1/stage0/src/std_logic.rs b/src/v1/stage0/src/std_logic.rs index d0355224cf0..8a3af0e174a 100644 --- a/src/v1/stage0/src/std_logic.rs +++ b/src/v1/stage0/src/std_logic.rs @@ -40,8 +40,3 @@ pub fn classical_or(a: Classical, b: Classical) -> Classical { Classical::False => b, } } - -#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct True; -#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct False; diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index 86ab6826f9d..0ff93e2c780 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -86,15 +86,15 @@ pub fn scale_exponent(s: Scale) -> i64 { } } -pub fn gibibyte_scale_factor_bytes() -> Nat { +pub fn gibibyte_scale_factor_bytes() -> Rc> { 1073741824 } -pub fn kibi_factor() -> Nat { +pub fn kibi_factor() -> Rc> { 1024 } -pub fn memory_scale_factor_bytes(s: Scale) -> Option { +pub fn memory_scale_factor_bytes(s: Scale) -> Rc> { match s { Scale::One => Some(1), Scale::Kibi => Some(kibi_factor()), @@ -127,10 +127,10 @@ pub fn measure_count(m: Rc>) -> M { } pub fn measure_scale_fraction_floor( - m: Rc>, - num: Nat, - den: Nat, -) -> Rc> { + m: Rc>>>, + num: Rc>, + den: Rc>, +) -> Rc>>> { Rc::new(Measure { count: if (den.clone() == 0) { den.clone() @@ -142,24 +142,24 @@ pub fn measure_scale_fraction_floor( } pub fn measure_fit_count_floor( - capacity: Rc>, - each: Rc>, -) -> Nat { + capacity: Rc>>>, + each: Rc>>>, +) -> Rc> { { let each_count = each.count.clone(); if (each_count.clone() == 0) { - each_count.clone() + each_count } else { - (capacity.count.clone() / each_count.clone()) + (capacity.count.clone() / each_count) } } } pub fn measure_scale_fraction_ceil( - m: Rc>, - num: Nat, - den: Nat, -) -> Rc> { + m: Rc>>>, + num: Rc>, + den: Rc>, +) -> Rc>>> { Rc::new(Measure { count: if (den.clone() == 0) { (m.count.clone() * num) @@ -171,40 +171,58 @@ pub fn measure_scale_fraction_ceil( } pub fn measure_add( - a: Rc>, - b: Rc>, -) -> Rc> { + a: Rc>>>, + b: Rc>>>, +) -> Rc>>> { Rc::new(Measure { count: (a.count.clone() + b.count.clone()), _phantom: std::marker::PhantomData, }) } -pub fn measure_le(a: Rc>, b: Rc>) -> bool { +pub fn measure_le( + a: Rc>>>, + b: Rc>>>, +) -> bool { (a.count.clone() <= b.count.clone()) } -pub fn time_measure(count: Nat) -> Rc> { +pub fn time_measure( + count: Rc>, +) -> Rc>>> { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub type ByteSize = Rc>; +pub type ByteSize = Rc>>>; -pub type Kibibyte = Rc>; +pub type Kibibyte = Rc>>>; -pub type Gibibyte = Rc>; +pub type Mebibyte = Rc>>>; -pub fn gibibyte(count: Nat) -> Gibibyte { +pub type Gibibyte = Rc>>>; + +pub fn mebibyte(count: Rc>) -> Mebibyte { + Rc::new(Measure { + count: count, + _phantom: std::marker::PhantomData, + }) +} + +pub fn mebibyte_count(m: Mebibyte) -> Rc> { + measure_count(m) +} + +pub fn gibibyte(count: Rc>) -> Gibibyte { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn gibibyte_count(g: Gibibyte) -> Nat { +pub fn gibibyte_count(g: Gibibyte) -> Rc> { measure_count(g) } @@ -212,30 +230,34 @@ pub fn gibibyte_to_byte_size(g: Gibibyte) -> ByteSize { byte_size((gibibyte_count(g) * gibibyte_scale_factor_bytes())) } -pub type BitWidth = Rc>; +pub type BitWidth = Rc>>>; -pub fn bits_per_byte() -> Nat { +pub fn bits_per_byte() -> Rc> { 8 } -pub type Hertz = Rc>; +pub type Hertz = Rc>>>; -pub type HardwareThreadCount = Rc>; +pub type HardwareThreadCount = + Rc>>>; -pub type Watt = Rc>; +pub type Millicore = Rc>>>; + +pub type Watt = Rc>>>; pub type Celsius = Rc>; -pub type RevolutionsPerMinute = Rc>; +pub type RevolutionsPerMinute = + Rc>>>; -pub fn watt(count: Nat) -> Watt { +pub fn watt(count: Rc>) -> Watt { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn watt_count(w: Watt) -> Nat { +pub fn watt_count(w: Watt) -> Rc> { measure_count(w) } @@ -250,138 +272,150 @@ pub fn celsius_count(c: Celsius) -> i64 { measure_count(c) } -pub fn rpm(count: Nat) -> RevolutionsPerMinute { +pub fn rpm(count: Rc>) -> RevolutionsPerMinute { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn rpm_count(r: RevolutionsPerMinute) -> Nat { +pub fn rpm_count(r: RevolutionsPerMinute) -> Rc> { measure_count(r) } -pub type MoneyAmount = Rc>; +pub type MoneyAmount = + Rc>>>; pub type MoneyAmountMicro = MoneyAmount<()>; -pub fn money_amount_micro(count: Nat) -> MoneyAmountMicro { +pub fn money_amount_micro(count: Rc>) -> MoneyAmountMicro { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn money_amount_micro_count(m: MoneyAmountMicro) -> Nat { +pub fn money_amount_micro_count(m: MoneyAmountMicro) -> Rc> { measure_count(m) } -pub fn byte_size(count: Nat) -> ByteSize { +pub fn byte_size(count: Rc>) -> ByteSize { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn byte_size_count(b: ByteSize) -> Nat { +pub fn byte_size_count(b: ByteSize) -> Rc> { measure_count(b) } -pub fn bit_width(count: Nat) -> BitWidth { +pub fn bit_width(count: Rc>) -> BitWidth { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn bit_width_count(b: BitWidth) -> Nat { +pub fn bit_width_count(b: BitWidth) -> Rc> { measure_count(b) } -pub fn hertz(count: Nat) -> Hertz { +pub fn hertz(count: Rc>) -> Hertz { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn hertz_count(h: Hertz) -> Nat { +pub fn hertz_count(h: Hertz) -> Rc> { measure_count(h) } -pub fn hardware_thread_count(count: Nat) -> HardwareThreadCount { +pub fn hardware_thread_count(count: Rc>) -> HardwareThreadCount { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn hardware_thread_count_value(t: HardwareThreadCount) -> Nat { +pub fn hardware_thread_count_value(t: HardwareThreadCount) -> Rc> { measure_count(t) } -pub type Bandwidth = Rc>; +pub fn millicore(count: Rc>) -> Millicore { + Rc::new(Measure { + count: count, + _phantom: std::marker::PhantomData, + }) +} + +pub fn millicore_count(m: Millicore) -> Rc> { + measure_count(m) +} + +pub type Bandwidth = Rc>>>; -pub fn bandwidth(count: Nat) -> Bandwidth { +pub fn bandwidth(count: Rc>) -> Bandwidth { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn bandwidth_count(b: Bandwidth) -> Nat { +pub fn bandwidth_count(b: Bandwidth) -> Rc> { measure_count(b) } -pub type Nanosecond = Rc>; +pub type Nanosecond = Rc>>>; -pub fn nanosecond(count: Nat) -> Nanosecond { +pub fn nanosecond(count: Rc>) -> Nanosecond { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn nanosecond_count(n: Nanosecond) -> Nat { +pub fn nanosecond_count(n: Nanosecond) -> Rc> { measure_count(n) } -pub type Microsecond = Rc>; +pub type Microsecond = Rc>>>; -pub fn microsecond(count: Nat) -> Microsecond { +pub fn microsecond(count: Rc>) -> Microsecond { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn microsecond_count(m: Microsecond) -> Nat { +pub fn microsecond_count(m: Microsecond) -> Rc> { measure_count(m) } -pub type Second = Rc>; +pub type Second = Rc>>>; -pub fn second(count: Nat) -> Second { +pub fn second(count: Rc>) -> Second { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn second_count(s: Second) -> Nat { +pub fn second_count(s: Second) -> Rc> { measure_count(s) } -pub type Percent = Rc>; +pub type Percent = Rc>>>; -pub fn percent(count: Nat) -> Percent { +pub fn percent(count: Rc>) -> Percent { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn percent_count(p: Percent) -> Nat { +pub fn percent_count(p: Percent) -> Rc> { measure_count(p) } diff --git a/src/v1/stage0/src/std_nat.rs b/src/v1/stage0/src/std_nat.rs index 2a9dd06c755..c0107cd4739 100644 --- a/src/v1/stage0/src/std_nat.rs +++ b/src/v1/stage0/src/std_nat.rs @@ -29,16 +29,16 @@ pub fn nat_compare(a: Nat, b: Nat) -> Ordering { pub fn nat_max(a: Nat, b: Nat) -> Nat { if (a.clone() > b.clone()) { - a.clone() + a } else { - b.clone() + b } } pub fn nat_min(a: Nat, b: Nat) -> Nat { if (a.clone() < b.clone()) { - a.clone() + a } else { - b.clone() + b } } diff --git a/src/v1/stage0/src/std_realization_schedule.rs b/src/v1/stage0/src/std_realization_schedule.rs index bd2ca24e794..a8f034d228c 100644 --- a/src/v1/stage0/src/std_realization_schedule.rs +++ b/src/v1/stage0/src/std_realization_schedule.rs @@ -36,8 +36,8 @@ pub enum CostBasis { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CostAccount { pub time: Rc>, - pub space: Box, - pub power: Box, + pub space: ByteSize, + pub power: Watt, pub basis: CostBasis, pub _phantom: std::marker::PhantomData, } @@ -45,24 +45,28 @@ pub struct CostAccount { pub fn cost_account_predicted_zero() -> Rc> { Rc::new(CostAccount { time: time_measure(0), - space: Box::new(byte_size(0)), - power: Box::new(watt(0)), + space: byte_size(0), + power: watt(0), basis: CostBasis::Predicted, _phantom: std::marker::PhantomData, }) } -pub fn cost_account_measured(time: Rc>) -> Rc> { +pub fn cost_account_measured( + time: Rc>>>, +) -> Rc> { Rc::new(CostAccount { time: time, - space: Box::new(byte_size(0)), - power: Box::new(watt(0)), + space: byte_size(0), + power: watt(0), basis: CostBasis::Measured, _phantom: std::marker::PhantomData, }) } -pub fn cost_account_time_count(account: Rc>) -> Nat { +pub fn cost_account_time_count( + account: Rc>, +) -> Rc> { measure_count(account.time.clone()) } @@ -79,7 +83,7 @@ pub struct ScheduleWitnessEntry { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RunnableMemoryPeak { - pub predicted_peak: Box, + pub predicted_peak: ByteSize, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -108,10 +112,12 @@ pub fn runnable_memory_negligible() -> Rc { Rc::new(RunnableMemoryClass::RunnableMemoryNegligible) } -pub fn runnable_memory_substantial(predicted_peak: ByteSize) -> Rc { +pub fn runnable_memory_substantial( + predicted_peak: Rc>, +) -> Rc { Rc::new(RunnableMemoryClass::RunnableMemorySubstantial { peak: Rc::new(RunnableMemoryPeak { - predicted_peak: Box::new(predicted_peak), + predicted_peak: predicted_peak, }), }) } @@ -128,8 +134,8 @@ pub fn runnable_memory_class_eq( RunnableMemoryClass::RunnableMemorySubstantial { peak: lp, .. } => match (*right).clone() { RunnableMemoryClass::RunnableMemoryNegligible => false, RunnableMemoryClass::RunnableMemorySubstantial { peak: rp, .. } => { - (byte_size_count((*lp.predicted_peak).clone()) - == byte_size_count((*rp.predicted_peak).clone())) + (byte_size_count(lp.predicted_peak.clone()) + == byte_size_count(rp.predicted_peak.clone())) } }, } @@ -143,13 +149,13 @@ pub fn runnable_memory_substantial_sum( let left_count = match (*left).clone() { RunnableMemoryClass::RunnableMemoryNegligible => 0, RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { - byte_size_count((*p.predicted_peak).clone()) + byte_size_count(p.predicted_peak.clone()) } }; let right_count = match (*right).clone() { RunnableMemoryClass::RunnableMemoryNegligible => 0, RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { - byte_size_count((*p.predicted_peak).clone()) + byte_size_count(p.predicted_peak.clone()) } }; runnable_memory_substantial(byte_size((left_count + right_count))) @@ -196,19 +202,17 @@ pub fn runnable_heavy_whole_tree_resolve(profile: Rc) - profile.heavy_whole_tree_resolve.clone() } -pub fn runnable_predicted_space(profile: Rc) -> ByteSize { +pub fn runnable_predicted_space(profile: Rc) -> Rc> { match (*profile.memory.clone()).clone() { RunnableMemoryClass::RunnableMemoryNegligible => byte_size(0), - RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { - (*p.predicted_peak).clone() - } + RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => p.predicted_peak.clone(), } } pub fn runnable_profile(r: Rc) -> Rc { match (*r).clone() { - Runnable::RunnableSingleClaim { profile: p, .. } => p.clone(), - Runnable::RunnableDiscoveryBatch { profile: p, .. } => p.clone(), + Runnable::RunnableSingleClaim { profile: p, .. } => p, + Runnable::RunnableDiscoveryBatch { profile: p, .. } => p, Runnable::RunnableKernelWorkload { fused_op_count: _, .. } => runnable_resource_profile_negligible(), @@ -219,7 +223,7 @@ pub fn runnable_forbids_corpus_co_residence(r: Rc) -> bool { match (*r).clone() { Runnable::RunnableDiscoveryBatch { .. } => false, Runnable::RunnableSingleClaim { profile: p, .. } => { - runnable_excludes_corpus_co_residence(p.clone()) + runnable_excludes_corpus_co_residence(p) } Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -265,14 +269,14 @@ pub type Schedule = Rc>>>>; pub struct RealizationPlan { pub target: ContentHash, pub objective: Rc, - pub schedule: Box, + pub schedule: Schedule, pub total: Rc>, pub _phantom: std::marker::PhantomData, } pub fn runnable_step_label(r: Rc) -> String { match (*r).clone() { - Runnable::RunnableSingleClaim { function: f, .. } => f.clone(), + Runnable::RunnableSingleClaim { function: f, .. } => f, Runnable::RunnableDiscoveryBatch { .. } => "__discovery_corpus__".to_string(), Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -335,7 +339,7 @@ pub fn schedule_lens_violation_diagnostic( ScheduleLensViolation::CompileGateNotFirst { expected: expected, .. } => Rc::new(LensVerdictDiagnostic { - reason: ("schedule_lens_compile_gate_not_first:".to_string() + &expected.clone()), + reason: ("schedule_lens_compile_gate_not_first:".to_string() + &expected), at: at, }), ScheduleLensViolation::CorpusBeforeCompile => Rc::new(LensVerdictDiagnostic { @@ -354,7 +358,7 @@ pub fn schedule_lens_verdict_for_ci_floor( plan: Rc>, compile_gate_fn: String, ) -> Rc { - if (((*plan.schedule).clone().len() as i64) == 0) { + if ((plan.schedule.clone().len() as i64) == 0) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic( Rc::new(ScheduleLensViolation::EmptySchedule), @@ -362,7 +366,7 @@ pub fn schedule_lens_verdict_for_ci_floor( ), }) } else { - if (((*plan.schedule).clone().len() as i64) < 2) { + if ((plan.schedule.clone().len() as i64) < 2) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic( Rc::new(ScheduleLensViolation::SingleBatchOnly), @@ -371,7 +375,7 @@ pub fn schedule_lens_verdict_for_ci_floor( }) } else { { - let batch0 = (*plan.schedule).clone().first().cloned(); + let batch0 = plan.schedule.clone().first().cloned(); if ((batch0.clone().expect("fail-closed: Optional receiver for method count (empty Optional at runtime)").len() as i64) != 1) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::CompileGateNotFirst { @@ -386,13 +390,13 @@ pub fn schedule_lens_verdict_for_ci_floor( }), compile_gate_fn.clone()), }) } else { - if schedule_batch_contains_label(batch0.clone().expect("fail-closed: an optional value flowed into non-optional parameter 0 of schedule_batch_contains_label (empty Optional at runtime)"), "__discovery_corpus__".to_string()) { + if schedule_batch_contains_label(batch0.expect("fail-closed: an optional value flowed into non-optional parameter 0 of schedule_batch_contains_label (empty Optional at runtime)"), "__discovery_corpus__".to_string()) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::CorpusBeforeCompile), compile_gate_fn.clone()), }) } else { { - let batch1 = (*plan.schedule).clone().get(1 as usize).cloned(); + let batch1 = plan.schedule.clone().get(1 as usize).cloned(); if ((batch1.expect("fail-closed: Optional receiver for method count (empty Optional at runtime)").len() as i64) < 2) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::SingleBatchOnly), compile_gate_fn.clone()), @@ -413,7 +417,7 @@ pub fn schedule_generates_same_batch_count( left: Rc>, right: Rc>, ) -> bool { - (((*left.schedule).clone().len() as i64) == ((*right.schedule).clone().len() as i64)) + ((left.schedule.clone().len() as i64) == (right.schedule.clone().len() as i64)) } pub fn schedule_witness_entry_eq(a: Rc, b: Rc) -> bool { @@ -488,10 +492,7 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { function: rf, profile: rp, .. - } => { - (((le.clone() == re.clone()) && (lf.clone() == rf.clone())) - && runnable_resource_profile_eq(lp.clone(), rp.clone())) - } + } => (((le == re) && (lf == rf)) && runnable_resource_profile_eq(lp, rp)), Runnable::RunnableDiscoveryBatch { .. } => false, Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -520,14 +521,13 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { profile: rp, .. } => { - (((((((string_list_eq(lsr.clone(), rsr.clone()) - && string_list_eq(lsd.clone(), rsd.clone())) - && schedule_witness_entry_list_eq(lex.clone(), rex.clone())) - && (lskip.clone() == rskip.clone())) - && string_list_eq(lex2.clone(), rex2.clone())) - && string_list_eq(lsc.clone(), rsc.clone())) - && (lwc.clone() == rwc.clone())) - && runnable_resource_profile_eq(lp.clone(), rp.clone())) + (((((((string_list_eq(lsr, rsr) && string_list_eq(lsd, rsd)) + && schedule_witness_entry_list_eq(lex, rex)) + && (lskip == rskip)) + && string_list_eq(lex2, rex2)) + && string_list_eq(lsc, rsc)) + && (lwc == rwc)) + && runnable_resource_profile_eq(lp, rp)) } Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -542,7 +542,7 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { Runnable::RunnableKernelWorkload { fused_op_count: rcount, .. - } => (lleft.clone() == rcount.clone()), + } => (lleft == rcount), }, } } @@ -602,7 +602,7 @@ pub fn schedule_generates_identical_schedule( plan: Rc>, schedule: Schedule, ) -> bool { - schedule_eq((*plan.schedule).clone(), schedule) + schedule_eq(plan.schedule.clone(), schedule) } #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index f2b75710075..05f4d44696b 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -92,8 +92,8 @@ pub fn optional_evidence_meet( match a.clone() { None => b, Some(va) => match b { - None => a.clone(), - Some(vb) => Some(descent_evidence_lattice_meet(va.clone(), vb.clone())), + None => a, + Some(vb) => Some(descent_evidence_lattice_meet(va, vb)), }, } } @@ -107,7 +107,7 @@ pub fn map_evidence_merge_at( Some(existing) => v1_rt::rc_map_insert( base.clone(), key.clone(), - descent_evidence_lattice_meet(existing.clone(), new_val), + descent_evidence_lattice_meet(existing, new_val), ), None => v1_rt::rc_map_insert(base.clone(), key.clone(), new_val), } @@ -155,7 +155,7 @@ pub fn positive_descent_count(steps: Rc) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*steps).clone() { PositiveDescentAmount::OneStep => 1, PositiveDescentAmount::AdditionalStep { previous: p, .. } => { - (1 + positive_descent_count(p.clone())) + (1 + positive_descent_count(p)) } }) } @@ -179,7 +179,7 @@ pub fn proportional_divisor_to_int(d: Rc) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*d).clone() { ProportionalDivisor::DivideByTwo => 2, ProportionalDivisor::StrictlyLarger { inner: p, .. } => { - (1 + proportional_divisor_to_int(p.clone())) + (1 + proportional_divisor_to_int(p)) } }) } @@ -201,7 +201,7 @@ pub fn positive_descent_amount_from_positive_int(k: i64) -> Option Some(Rc::new(PositiveDescentAmount::AdditionalStep { - previous: prev.clone(), + previous: prev, })), None => None, } @@ -223,9 +223,9 @@ pub fn proportional_divisor_from_int_at_least_two(k: i64) -> Option Some(Rc::new(ProportionalDivisor::StrictlyLarger { - inner: prev.clone(), - })), + Some(prev) => { + Some(Rc::new(ProportionalDivisor::StrictlyLarger { inner: prev })) + } None => None, } } diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index 59d65be8eb6..c2c3e8b303d 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -73,7 +73,7 @@ pub fn container_param_names_for(kind_name: String) -> Rc> { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { - Some(p) => algebra_type_param_names(p.clone()), + Some(p) => algebra_type_param_names(p), None => Rc::new(vec![]), } } @@ -113,7 +113,7 @@ pub fn container_param_name(kind_name: String, index: i64) -> Option { .first() .cloned() { - Some(name) => Some(name.clone()), + Some(name) => Some(name), None => None, } } diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 0a95131a9f2..d1404a95858 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -94,7 +94,7 @@ pub fn plan_artifacts(rule: Rc) -> Rc { PartitionRule::Explicit { artifacts: arts, .. } => Rc::new(ArtifactPlan { - artifacts: arts.clone(), + artifacts: arts, boundaries: Rc::new(vec![]), }), } diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index 6c8e64335a0..c74e5868aab 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -98,7 +98,7 @@ pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) pub fn render_cast(expr_str: String, type_str: String, target: RenderTarget) -> String { { let syntax = match target_cast_syntax(target) { - Some(s) => s.clone(), + Some(s) => s, None => Rc::new(CastSyntax { template: "{expr}".to_string(), cast_rules: Rc::new(vec![]), @@ -129,7 +129,7 @@ pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option String { match lookup_checkpoint(target, dag_name.clone()) { Some(cp) => cp.target_type.clone(), - None => dag_name.clone(), + None => dag_name, } } @@ -143,7 +143,7 @@ pub fn is_copy(target: RenderTarget, dag_name: String) -> Option { pub fn literal_suffix(target: RenderTarget, dag_name: String) -> Option { match lookup_checkpoint(target, dag_name) { Some(cp) => match cp.literal_suffix.clone() { - Some(s) => Some(s.clone()), + Some(s) => Some(s), None => Some("".to_string()), }, None => None, @@ -166,7 +166,7 @@ pub fn lookup_inhabitant(target: RenderTarget, algebra: String) -> Option Option { match container_template_algebra(container_name) { - Some(algebra) => match lookup_inhabitant(target, algebra.clone()) { + Some(algebra) => match lookup_inhabitant(target, algebra) { Some(inh) => Some(inh.template.clone()), None => None, }, @@ -240,7 +240,7 @@ pub fn checkpoint_tests(target: RenderTarget) -> Rc>> ), assertions: Rc::new({ let mut __result = Vec::new(); - for cp in cps.clone().iter().cloned() { + for cp in cps.iter().cloned() { __result.push(Rc::new(CoercionAssertion::CheckpointAssertion { target: target.clone(), dag_name: cp.dag_name.clone(), @@ -289,7 +289,7 @@ pub fn inhabitant_tests(target: RenderTarget) -> Rc>> v1_rt::concat("coercion_".to_string(), label), "_inhabitant_resolves_containers".to_string(), ), - assertions: assertions.clone(), + assertions: assertions, })]) } } @@ -321,7 +321,7 @@ pub fn copy_tests() -> Rc>> { } else { Rc::new(vec![Rc::new(CoercionTestEntry { test_name: "coercion_is_copy_from_checkpoint".to_string(), - assertions: copy_assertions.clone(), + assertions: copy_assertions, })]) } } @@ -401,7 +401,7 @@ pub fn template_application_tests() -> Rc>> { } else { Rc::new(vec![Rc::new(CoercionTestEntry { test_name: "coercion_template_application".to_string(), - assertions: assertions.clone(), + assertions: assertions, })]) } } diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 1c1e8ecd469..ab1d86445e7 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -135,7 +135,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> if { let mut __found = false; for item in m.items.clone().iter().cloned() { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { __found = true; break; } @@ -156,7 +156,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> for item in Rc::new({ let mut __result = Vec::new(); for item in m.items.clone().iter().cloned() { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { __result.push(item); } } @@ -167,10 +167,10 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - m.type_env.clone().source_indices.clone(), + (*m.type_env).clone().source_indices.clone(), item.clone(), ), - body: item.body.clone().clone().unwrap(), + body: (*item.body).clone().clone().unwrap(), params: item.params.clone(), span: item.span.clone(), is_tail_recursive: (item.is_self_recursive.clone() @@ -200,7 +200,7 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc) -> Rc>) -> String { pub fn json_optional_string(value: Option) -> String { match value { - Some(inner) => json_quote(inner.clone()), + Some(inner) => json_quote(inner), None => "null".to_string(), } } @@ -400,7 +400,7 @@ pub fn dag_emit_check_optional_ref_target( key_to_id: Rc>, ) -> Rc>> { match value { - Some(inner) => dag_emit_check_ref_target(inner.clone(), key_to_id), + Some(inner) => dag_emit_check_ref_target(inner, key_to_id), None => Rc::new(vec![]), } } @@ -410,9 +410,7 @@ pub fn dag_emit_check_inferred_ref_target( key_to_id: Rc>, ) -> Rc>> { match value.as_deref().cloned() { - Some(InferredNode::Resolved { node: n, .. }) => { - dag_emit_check_ref_target(n.clone(), key_to_id) - } + Some(InferredNode::Resolved { node: n, .. }) => dag_emit_check_ref_target(n, key_to_id), _ => Rc::new(vec![]), } } @@ -477,9 +475,12 @@ pub fn dag_emit_check_node_refs( __result }), ), - dag_emit_check_optional_ref_target(node.body.clone(), key_to_id.clone()), + dag_emit_check_optional_ref_target((*node.body).clone(), key_to_id.clone()), + ), + dag_emit_check_optional_ref_target( + (*node.transport).clone(), + key_to_id.clone(), ), - dag_emit_check_optional_ref_target(node.transport.clone(), key_to_id.clone()), ), Rc::new({ let mut __result = Vec::new(); @@ -493,9 +494,9 @@ pub fn dag_emit_check_node_refs( __result }), ), - dag_emit_check_optional_ref_target(node.type_annotation.clone(), key_to_id.clone()), + dag_emit_check_optional_ref_target((*node.type_annotation).clone(), key_to_id.clone()), ), - dag_emit_check_inferred_ref_target(node.inferred.clone(), key_to_id.clone()), + dag_emit_check_inferred_ref_target((*node.inferred).clone(), key_to_id.clone()), ) } @@ -543,7 +544,7 @@ pub fn dag_graph_source_indices(typed: Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) }, ) } @@ -551,7 +552,7 @@ pub fn dag_graph_source_indices(typed: Rc) -> Rc, key_to_id: Rc>) -> String { match v1_rt::map_get(&key_to_id, dag_node_key(node)) { Some(id) => v1_rt::concat( - v1_rt::concat("{\"$ref\": ".to_string(), json_quote(id.clone())), + v1_rt::concat("{\"$ref\": ".to_string(), json_quote(id)), "}".to_string(), ), None => "{\"$ref\": null}".to_string(), @@ -563,7 +564,7 @@ pub fn json_optional_node_ref( key_to_id: Rc>, ) -> String { match value { - Some(inner) => serialize_node_ref(inner.clone(), key_to_id), + Some(inner) => serialize_node_ref(inner, key_to_id), None => "null".to_string(), } } @@ -573,14 +574,14 @@ pub fn json_optional_inferred_node_ref( key_to_id: Rc>, ) -> String { match value { - Some(inner) => serialize_inferred_node_ref(inner.clone(), key_to_id), + Some(inner) => serialize_inferred_node_ref(inner, key_to_id), None => "null".to_string(), } } pub fn json_optional_span(value: Option>) -> String { match value { - Some(inner) => serialize_span(inner.clone()), + Some(inner) => serialize_span(inner), None => "null".to_string(), } } @@ -750,28 +751,28 @@ pub fn serialize_literal(value: Rc) -> String { LiteralValue::LitStr { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitStr\", \"value\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), "}".to_string(), ), LiteralValue::LitInt { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitInt\", \"value\": ".to_string(), - (inner.clone()).to_string(), + (inner).to_string(), ), "}".to_string(), ), LiteralValue::LitFloat { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitFloat\", \"value\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), "}".to_string(), ), LiteralValue::LitBool { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitBool\", \"value\": ".to_string(), - json_bool(inner.clone()), + json_bool(inner), ), "}".to_string(), ), @@ -779,7 +780,7 @@ pub fn serialize_literal(value: Rc) -> String { LiteralValue::LitSymbol { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitSymbol\", \"value\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), "}".to_string(), ), @@ -819,14 +820,14 @@ pub fn serialize_match_pattern( MatchPattern::Bind { name: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Bind\", \"name\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), "}".to_string(), ), MatchPattern::LitPattern { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitPattern\", \"value\": ".to_string(), - serialize_literal(inner.clone()), + serialize_literal(inner), ), "}".to_string(), ), @@ -842,17 +843,17 @@ pub fn serialize_match_pattern( v1_rt::concat( v1_rt::concat( "{\"kind\": \"VariantPattern\", \"name\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), ", \"parent_enum\": ".to_string(), ), - json_optional_string(parent_enum.clone()), + json_optional_string(parent_enum), ), ", \"field_bindings\": ".to_string(), ), json_list(Rc::new({ let mut __result = Vec::new(); - for fb in field_bindings.clone().iter().cloned() { + for fb in field_bindings.iter().cloned() { __result.push(serialize_field_binding(fb.clone(), source_indices.clone())); } __result @@ -939,14 +940,14 @@ pub fn serialize_string_part( StringPart::Text { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Text\", \"value\": ".to_string(), - json_quote(inner.clone()), + json_quote(inner), ), "}".to_string(), ), StringPart::Interpolation { expr: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Interpolation\", \"expr\": ".to_string(), - serialize_node_ref(inner.clone(), key_to_id), + serialize_node_ref(inner, key_to_id), ), "}".to_string(), ), @@ -958,7 +959,7 @@ pub fn serialize_call_semantics(value: Option) -> String { Some(inner) => v1_rt::concat( v1_rt::concat( "{\"kind\": ".to_string(), - json_quote(call_semantics_name(inner.clone())), + json_quote(call_semantics_name(inner)), ), "}".to_string(), ), @@ -980,7 +981,7 @@ pub fn serialize_method_semantics( fold_accumulator_type, .. }) => { - let mn = authored_name_at(source_indices.clone(), method_def.clone()); + let mn = authored_name_at(source_indices, method_def); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -990,7 +991,7 @@ pub fn serialize_method_semantics( ), ", \"fold_accumulator_type\": ".to_string(), ), - json_optional_node_ref(fold_accumulator_type.clone(), key_to_id.clone()), + json_optional_node_ref(fold_accumulator_type, key_to_id), ), "}".to_string(), ) @@ -1004,13 +1005,13 @@ pub fn serialize_method_semantics( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ServiceMethodSemantics\", \"service_name\": ".to_string(), - json_quote(service_name.clone()), + json_quote(service_name), ), ", \"op_params\": ".to_string(), ), json_list(Rc::new({ let mut __result = Vec::new(); - for p in op_params.clone().iter().cloned() { + for p in op_params.iter().cloned() { __result.push(serialize_param( p.clone(), source_indices.clone(), @@ -1070,7 +1071,7 @@ pub fn serialize_positive_descent_amount(steps: Rc) -> St PositiveDescentAmount::AdditionalStep { previous: p, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"AdditionalStep\", \"previous\": ".to_string(), - serialize_positive_descent_amount(p.clone()), + serialize_positive_descent_amount(p), ), "}".to_string(), ), @@ -1083,7 +1084,7 @@ pub fn serialize_proportional_divisor(d: Rc) -> String { ProportionalDivisor::StrictlyLarger { inner: i, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"StrictlyLarger\", \"inner\": ".to_string(), - serialize_proportional_divisor(i.clone()), + serialize_proportional_divisor(i), ), "}".to_string(), ), @@ -1096,14 +1097,14 @@ pub fn serialize_shrink_factor(factor: Rc) -> String { ShrinkFactor::ConstantShrink { steps: s, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ConstantShrink\", \"steps\": ".to_string(), - serialize_positive_descent_amount(s.clone()), + serialize_positive_descent_amount(s), ), "}".to_string(), ), ShrinkFactor::ProportionalShrink { divisor: d, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ProportionalShrink\", \"divisor\": ".to_string(), - serialize_proportional_divisor(d.clone()), + serialize_proportional_divisor(d), ), "}".to_string(), ), @@ -1121,18 +1122,18 @@ pub fn serialize_sub_value_relation(rel: Rc) -> String { v1_rt::concat( v1_rt::concat( "{\"_variant\": \"StrictSubValue\", \"field\": ".to_string(), - serialize_inductive_field(f.clone()), + serialize_inductive_field(f), ), ", \"factor\": ".to_string(), ), - serialize_shrink_factor(fac.clone()), + serialize_shrink_factor(fac), ), "}".to_string(), ), SubValueRelation::IteratedSubValue { field: f, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"IteratedSubValue\", \"field\": ".to_string(), - serialize_inductive_field(f.clone()), + serialize_inductive_field(f), ), "}".to_string(), ), @@ -1145,11 +1146,11 @@ pub fn serialize_sub_value_relation(rel: Rc) -> String { v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ArithmeticDescent\", \"param\": ".to_string(), - json_quote(p.clone()), + json_quote(p), ), ", \"factor\": ".to_string(), ), - serialize_shrink_factor(fac.clone()), + serialize_shrink_factor(fac), ), "}".to_string(), ), @@ -1167,7 +1168,7 @@ pub fn serialize_descent_evidence(de: Option>>>) -> match de { Some(evidence) => json_list(Rc::new({ let mut __result = Vec::new(); - for rel in evidence.clone().iter().cloned() { + for rel in evidence.iter().cloned() { __result.push(serialize_sub_value_relation(rel.clone())); } __result @@ -1189,7 +1190,7 @@ pub fn serialize_expr_data( ExprData::ExprLiteral { value: value, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprLiteral\", \"value\": ".to_string(), - serialize_literal(value.clone()), + serialize_literal(value), ), "}".to_string(), ), @@ -1198,11 +1199,11 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprError\", \"error_kind\": ".to_string(), - json_quote(expr_error_kind_name(kind.clone())), + json_quote(expr_error_kind_name(kind)), ), ", \"message\": ".to_string(), ), - json_quote(message.clone()), + json_quote(message), ), "}".to_string(), ), @@ -1218,20 +1219,20 @@ pub fn serialize_expr_data( ), ", \"binding_kind\": ".to_string(), ), - match binding_kind.clone() { + match binding_kind { Some(inner) => v1_rt::concat( v1_rt::concat( v1_rt::concat( "{\"kind\": ".to_string(), json_quote(var_binding_kind_name(inner.clone())), ), - match (*inner.clone()).clone() { + match (*inner).clone() { VarBindingKind::VariantValueBinding { parent_enum: parent_enum, .. } => v1_rt::concat( ", \"parent_enum\": ".to_string(), - json_quote(parent_enum.clone()), + json_quote(parent_enum), ), _ => "".to_string(), }, @@ -1258,8 +1259,8 @@ pub fn serialize_expr_data( ), ", \"summary\": ".to_string(), ), - match summary.clone() { - Some(inner) => serialize_field_summary(inner.clone()), + match summary { + Some(inner) => serialize_field_summary(inner), None => "null".to_string(), }, ), @@ -1295,11 +1296,11 @@ pub fn serialize_expr_data( ), ", \"call_semantics\": ".to_string(), ), - serialize_call_semantics(call_semantics.clone()), + serialize_call_semantics(call_semantics), ), ", \"descent_evidence\": ".to_string(), ), - serialize_descent_evidence(de.clone()), + serialize_descent_evidence(de), ), ", \"children\": ".to_string(), ), @@ -1331,7 +1332,7 @@ pub fn serialize_expr_data( ", \"method_semantics\": ".to_string(), ), serialize_method_semantics( - method_semantics.clone(), + method_semantics, source_indices.clone(), key_to_id.clone(), ), @@ -1360,12 +1361,12 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprBinOp\", \"op\": ".to_string(), - json_quote(bin_op_name(op.clone())), + json_quote(bin_op_name(op)), ), ", \"algebra_field\": ".to_string(), ), - match af.clone() { - Some(f) => json_quote(algebra_field_kind_name(f.clone())), + match af { + Some(f) => json_quote(algebra_field_kind_name(f)), None => "null".to_string(), }, ), @@ -1386,7 +1387,7 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprUnaryOp\", \"op\": ".to_string(), - json_quote(unary_op_name(op.clone())), + json_quote(unary_op_name(op)), ), ", \"children\": ".to_string(), ), @@ -1463,7 +1464,7 @@ pub fn serialize_expr_data( ), ", \"parent_enum\": ".to_string(), ), - json_optional_string(parent_enum.clone()), + json_optional_string(parent_enum), ), ", \"children\": ".to_string(), ), @@ -1656,7 +1657,7 @@ pub fn serialize_inferred_node_ref( InferredNode::Resolved { node: node, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Resolved\", \"node\": ".to_string(), - serialize_node_ref(node.clone(), key_to_id), + serialize_node_ref(node, key_to_id), ), "}".to_string(), ), @@ -1665,18 +1666,18 @@ pub fn serialize_inferred_node_ref( v1_rt::concat( v1_rt::concat( "{\"kind\": \"CompilerError\", \"message\": ".to_string(), - json_quote(message.clone()), + json_quote(message), ), ", \"span\": ".to_string(), ), - serialize_span(span.clone()), + serialize_span(span), ), "}".to_string(), ), InferredNode::TypeVariable { id: id, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"TypeVariable\", \"id\": ".to_string(), - json_quote(id.clone()), + json_quote(id), ), "}".to_string(), ), @@ -1807,7 +1808,7 @@ pub fn serialize_param( pub fn is_import_statement_node(n: Rc) -> bool { (import_is_all(n.clone()) - || (((((n.children.clone().len() as i64) > 0) && (n.body.clone() == None)) + || (((((n.children.clone().len() as i64) > 0) && ((*n.body).clone() == None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && ((n.params.clone().len() as i64) == 0))) } @@ -1855,7 +1856,7 @@ pub fn serialize_module_imports_json( } { json_list(Rc::new({ let mut __result = Vec::new(); - for imp in imports.clone().iter().cloned() { + for imp in imports.iter().cloned() { __result.push(serialize_import_node(imp.clone(), source_indices.clone())); } __result @@ -1877,7 +1878,7 @@ pub fn serialize_node_record( Connective::Disj => json_quote(connective_name(Connective::Disj)), Connective::NoConnective => "null".to_string(), Connective::Arrow => json_quote(connective_name(Connective::Arrow)), -}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref(node.inferred.clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref(node.body.clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref(node.transport.clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref(node.type_annotation.clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) +}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref((*node.inferred).clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref((*node.body).clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref((*node.transport).clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref((*node.type_annotation).clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) } pub fn serialize_typed_module( @@ -1891,7 +1892,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref(module.module.clone(), key_to_id.clone()), + serialize_node_ref((*module.module).clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2005,12 +2006,11 @@ pub fn emit_dag_artifact(typed: Rc) -> Rc { if ((ref_errors.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: ref_errors.clone(), + diagnostics: ref_errors, }); } let source_indices = dag_graph_source_indices(typed.clone()); - let nodes_json = - serialize_dag_nodes_table(order.clone(), source_indices, key_to_id.clone()); + let nodes_json = serialize_dag_nodes_table(order, source_indices, key_to_id.clone()); let modules_json = Rc::new({ let mut __result = Vec::new(); for m in typed.modules.clone().iter().cloned() { @@ -2142,9 +2142,7 @@ pub fn emittable_graph(resolved: Rc) -> Option Some(Rc::new(EmittableGraph { - graph: typed.clone(), - })), + Some(typed) => Some(Rc::new(EmittableGraph { graph: typed })), None => None, } } @@ -2173,7 +2171,7 @@ pub fn emit_from_artifact_plan( if ((boundary_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: boundary_diags.clone(), + diagnostics: boundary_diags, }); } let results = Rc::new({ @@ -2192,7 +2190,7 @@ pub fn emit_from_artifact_plan( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in results.clone().iter().cloned() { + for r in results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2234,14 +2232,14 @@ pub fn front_end_sources(sources: Rc>>) -> Rc empty_intern_table(), |t: Rc, p: Rc| pre_intern_tokens(p.tokens.clone(), t), ); - let parsed = prepared.clone().iter().cloned().fold( + let parsed = prepared.iter().cloned().fold( Rc::new(FrontendAccum { parse_results: Rc::new(vec![]), newline_indices: Rc::new(vec![]), intern_table: intern_table, }), |acc: Rc, p: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/compile.dag:37753:acc"); { let parsed = parse_with_table( p.tokens.clone(), @@ -2271,9 +2269,9 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let parse_diagnostics = collect_diagnostics(parse_results.clone()); let modules = Rc::new({ let mut __result = Vec::new(); - for p in parse_results.clone().iter().cloned() { + for p in parse_results.iter().cloned() { __result.extend( - (*match p.module.clone() { + (*match (*p.module).clone() { Some(m) => Rc::new(vec![m.clone()]), None => Rc::new(vec![]), }) @@ -2293,7 +2291,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc Rc::new(FrontendResult { graph: Some(graph.clone()), diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), - newline_indices: newline_indices.clone(), + newline_indices: newline_indices, intern_table: parsed.intern_table.clone(), }) } @@ -2358,7 +2356,7 @@ pub fn compile_to_resolved_with_options( source_indices: v1_rt::rc_empty_map::>(), complexity: empty_complexity_report(), ownership: Rc::new(vec![]), - newline_indices: newline_indices.clone(), + newline_indices: newline_indices, }), Some(graph) => { let source_indices = newline_indices.clone().iter().cloned().fold( @@ -2367,7 +2365,7 @@ pub fn compile_to_resolved_with_options( v1_rt::rc_map_insert(acc, index.file.clone(), index.clone()) }, ); - let norm = normalize_graph(graph.clone(), source_indices.clone()); + let norm = normalize_graph(graph, source_indices.clone()); let norm_diags = norm.diagnostics.clone(); let typed = reconcile( norm.graph.clone(), @@ -2389,7 +2387,7 @@ pub fn compile_to_resolved_with_options( let ownership = extract_ownership_proofs(typed.clone()); let ownership_diags = ownership_diagnostics(ownership.clone()); Rc::new(ResolvedPipelineResult { - graph: Some(typed.clone()), + graph: Some(typed), diagnostics: v1_rt::concat( v1_rt::concat( v1_rt::concat(frontend.diagnostics.clone(), norm_diags), @@ -2397,10 +2395,10 @@ pub fn compile_to_resolved_with_options( ), ownership_diags, ), - source_indices: source_indices.clone(), - complexity: complexity.clone(), - ownership: ownership.clone(), - newline_indices: newline_indices.clone(), + source_indices: source_indices, + complexity: complexity, + ownership: ownership, + newline_indices: newline_indices, }) } } @@ -2428,14 +2426,14 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - m.module.clone(), + (*m.module).clone(), )); } __result }), target, ); - let emit_result = emit_from_artifact_plan(emittable.clone(), artifact_plan.clone()); + let emit_result = emit_from_artifact_plan(emittable, artifact_plan.clone()); let emit_files = emit_result.files.clone(); let emit_diags = emit_result.diagnostics.clone(); let emit_errors = Rc::new({ @@ -2454,10 +2452,10 @@ pub fn emit_resolved_for_target( }; Rc::new(PipelineResult { files: final_files, - diagnostics: v1_rt::concat(resolved.diagnostics.clone(), emit_diags.clone()), + diagnostics: v1_rt::concat(resolved.diagnostics.clone(), emit_diags), complexity: resolved.complexity.clone(), ownership: resolved.ownership.clone(), - artifact_plan: artifact_plan.clone(), + artifact_plan: artifact_plan, newline_indices: resolved.newline_indices.clone(), }) } diff --git a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs index b812888d2d5..985933310a1 100644 --- a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs +++ b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs @@ -135,14 +135,14 @@ pub fn render_coercion_test_rust(entry: Rc) -> String { pub fn first_or_empty(items: Rc>) -> String { match items.first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => "".to_string(), } } pub fn second_or_empty(items: Rc>) -> String { match items.get(1 as usize).cloned() { - Some(v) => v.clone(), + Some(v) => v, None => "".to_string(), } } @@ -161,15 +161,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(coerce_primitive_type(".to_string(), - render_target_rust_enum(t.clone()), + render_target_rust_enum(t), ), ", \"".to_string(), ), - name.clone(), + name, ), "\".into()), \"".to_string(), ), - expected.clone(), + expected, ), "\");\n".to_string(), ), @@ -185,15 +185,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(coerce_container_template(".to_string(), - render_target_rust_enum(t.clone()), + render_target_rust_enum(t), ), ", \"".to_string(), ), - name.clone(), + name, ), "\".into()), Some(\"".to_string(), ), - expected.clone(), + expected, ), "\".to_string()));\n".to_string(), ), @@ -209,15 +209,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(is_copy(".to_string(), - render_target_rust_enum(t.clone()), + render_target_rust_enum(t), ), ", \"".to_string(), ), - name.clone(), + name, ), "\".into()), Some(".to_string(), ), - if expected.clone() { + if expected { "true".to_string() } else { "false".to_string() @@ -233,7 +233,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { } => { if ((arg_list.clone().len() as i64) == 1) { { - let arg0 = first_or_empty(arg_list.clone()); + let arg0 = first_or_empty(arg_list); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -242,7 +242,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( " assert_eq!(apply_inhabitant_template1(\"" .to_string(), - tmpl.clone(), + tmpl, ), "\".into(), \"".to_string(), ), @@ -250,7 +250,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { ), "\".into()), \"".to_string(), ), - expected.clone(), + expected, ), "\");\n".to_string(), ) @@ -259,8 +259,8 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { if ((arg_list.clone().len() as i64) == 2) { { let arg0 = first_or_empty(arg_list.clone()); - let arg1 = second_or_empty(arg_list.clone()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" assert_eq!(apply_inhabitant_template2(\"".to_string(), tmpl.clone()), "\".into(), \"".to_string()), arg0), "\".into(), \"".to_string()), arg1), "\".into()), \"".to_string()), expected.clone()), "\");\n".to_string()) + let arg1 = second_or_empty(arg_list); + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" assert_eq!(apply_inhabitant_template2(\"".to_string(), tmpl), "\".into(), \"".to_string()), arg0), "\".into(), \"".to_string()), arg1), "\".into()), \"".to_string()), expected), "\");\n".to_string()) } } else { "".to_string() diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 368276eb3bc..5b2d0e1894e 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -328,7 +328,7 @@ pub fn method_size_effect( match method_semantics.as_deref().cloned() { Some(MethodSemantics::AlgebraMethodSemantics { size_effect: se, .. - }) => se.clone(), + }) => se, _ => None, } } @@ -340,7 +340,7 @@ pub fn method_callback_element_position( Some(MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - }) => match at.clone() { + }) => match at { Some(template) => template.callback_element_position.clone(), None => None, }, @@ -356,7 +356,7 @@ pub fn iteration_element_name( { let params = lambda_param_names_at(lambda, si); match method_callback_element_position(method_semantics) { - Some(pos) => params.get(pos.clone() as usize).cloned(), + Some(pos) => params.get(pos as usize).cloned(), None => None, } } @@ -433,7 +433,7 @@ pub fn parser_state_base_var( Some(base) => match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => Some(expr_var_name_at(base.clone(), si)), + } => Some(expr_var_name_at(base, si)), _ => None, }, None => None, @@ -449,29 +449,24 @@ pub fn parser_result_state_progress( result_name: String, ) -> DescentEvidence { match (*source).clone() { - ParserResultSource::ParserResultAdvance { input, .. } => { - strict_after_parser_witness(input.clone()) - } - ParserResultSource::ParserResultExpect { input, .. } => { - strict_after_parser_witness(input.clone()) - } + ParserResultSource::ParserResultAdvance { input, .. } => strict_after_parser_witness(input), + ParserResultSource::ParserResultExpect { input, .. } => strict_after_parser_witness(input), ParserResultSource::ParserResultEat { input, .. } => { if set_has(consumed_true_set, result_name) { - strict_after_parser_witness(input.clone()) + strict_after_parser_witness(input) } else { - input.clone() + input } } ParserResultSource::ParserResultCall { input, callee, .. } => { - if (set_has(consumed_true_set, result_name) - || set_has(parser_always_advancing, callee.clone())) + if (set_has(consumed_true_set, result_name) || set_has(parser_always_advancing, callee)) { - strict_after_parser_witness(input.clone()) + strict_after_parser_witness(input) } else { - input.clone() + input } } - ParserResultSource::ParserResultDirectState { input: p, .. } => p.clone(), + ParserResultSource::ParserResultDirectState { input: p, .. } => p, ParserResultSource::ParserResultOpaque => DescentEvidence::DescentUnknown, } } @@ -535,8 +530,8 @@ pub fn parser_state_expr_progress( if (name.clone() == state_param.name.clone()) { DescentEvidence::NonIncreasing } else { - match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { - Some(progress) => progress.clone(), + match v1_rt::map_get(&env.state_aliases.clone(), name) { + Some(progress) => progress, None => DescentEvidence::DescentUnknown, } } @@ -547,10 +542,10 @@ pub fn parser_state_expr_progress( Some(result_name) => { match v1_rt::map_get(&env.result_sources.clone(), result_name.clone()) { Some(source) => parser_result_state_progress( - source.clone(), + source, parser_always_advancing.clone(), consumed_true_set.clone(), - result_name.clone(), + result_name, ), None => DescentEvidence::DescentUnknown, } @@ -564,7 +559,7 @@ pub fn parser_state_expr_progress( ExprData::ExprCall { .. } => { match parser_passthrough_state_expr(expr.clone(), si.clone()) { Some(state_expr) => parser_state_expr_progress( - state_expr.clone(), + state_expr, state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -577,9 +572,7 @@ pub fn parser_state_expr_progress( ExprData::ExprIf => { let cond = if_condition(expr.clone()); let then_consumed = match parser_progress_flag_var(cond, si.clone()) { - Some(name) => { - v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) - } + Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), None => consumed_true_set.clone(), }; let then_progress = parser_state_expr_progress( @@ -592,7 +585,7 @@ pub fn parser_state_expr_progress( ); let else_progress = match if_else_branch(expr.clone()) { Some(eb) => parser_state_expr_progress( - eb.clone(), + eb, state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -615,7 +608,7 @@ pub fn parser_state_expr_progress( ); match let_body(expr.clone()) { Some(body) => parser_state_expr_progress( - body.clone(), + body, state_param.clone(), next_env, parser_always_advancing.clone(), @@ -641,8 +634,8 @@ pub fn parser_state_expr_progress( __result }); match arm_progresses.clone().first().cloned() { - Some(initial) => arm_progresses.clone().iter().cloned().fold( - initial.clone(), + Some(initial) => arm_progresses.iter().cloned().fold( + initial, |acc: DescentEvidence, p: DescentEvidence| { descent_evidence_lattice_meet(acc, p.clone()) }, @@ -683,7 +676,7 @@ pub fn parser_block_state_progress( .collect::>(), ); let final_env = leading.iter().cloned().fold( - env.clone(), + env, |acc_env: Rc, stmt: Rc| match (*stmt.expr_data.clone()) .clone() { @@ -703,7 +696,7 @@ pub fn parser_block_state_progress( }, ); parser_state_expr_progress( - last_stmt.clone(), + last_stmt, state_param.clone(), final_env, parser_always_advancing.clone(), @@ -727,7 +720,7 @@ pub fn parser_result_source_for_expr( let input_progress = match parser_state_arg_expr(expr.clone(), state_param.clone(), si.clone()) { Some(state_expr) => parser_state_expr_progress( - state_expr.clone(), + state_expr, state_param.clone(), env, parser_always_advancing, @@ -739,21 +732,21 @@ pub fn parser_result_source_for_expr( match (*parser_result_witness(expr.clone(), si.clone())).clone() { ParserResultWitness::ParserWitnessAdvance => { Rc::new(ParserResultSource::ParserResultAdvance { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessExpect => { Rc::new(ParserResultSource::ParserResultExpect { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessEat => { Rc::new(ParserResultSource::ParserResultEat { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessCall { callee: callee, .. } => { - match (*callee.clone()).clone() { + match (*callee).clone() { ParserCallIdentity::ParserCallHelper { helper: _, .. } => { Rc::new(ParserResultSource::ParserResultOpaque) } @@ -763,8 +756,8 @@ pub fn parser_result_source_for_expr( Rc::new(ParserResultSource::ParserResultOpaque) } _ => Rc::new(ParserResultSource::ParserResultCall { - input: input_progress.clone(), - callee: name.clone(), + input: input_progress, + callee: name, }), } } @@ -786,9 +779,7 @@ pub fn parser_result_source_for_expr( ); match progress.clone() { DescentEvidence::DescentUnknown => Rc::new(ParserResultSource::ParserResultOpaque), - _ => Rc::new(ParserResultSource::ParserResultDirectState { - input: progress.clone(), - }), + _ => Rc::new(ParserResultSource::ParserResultDirectState { input: progress }), } } } @@ -846,7 +837,7 @@ pub fn parser_call_edge_progress( match parser_state_arg_expr(call_node.clone(), state_param.clone(), si.clone()) { Some(state_expr) => { let input_progress = parser_state_expr_progress( - state_expr.clone(), + state_expr, state_param.clone(), env, parser_always_advancing.clone(), @@ -1015,10 +1006,8 @@ pub fn collect_parser_progress_edges( consumed_true_set.clone(), si.clone(), ); - let then_consumed = match parser_progress_flag_var(cond.clone(), si.clone()) { - Some(name) => { - v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) - } + let then_consumed = match parser_progress_flag_var(cond, si.clone()) { + Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), None => consumed_true_set.clone(), }; let then_edges = collect_parser_progress_edges( @@ -1034,7 +1023,7 @@ pub fn collect_parser_progress_edges( let else_edges = match if_else_branch(body.clone()) { Some(eb) => collect_parser_progress_edges( caller.clone(), - eb.clone(), + eb, state_param.clone(), scc_name_set.clone(), env.clone(), @@ -1060,7 +1049,7 @@ pub fn collect_parser_progress_edges( ); let next_env = parser_env_with_binding( let_binding_name_at(body.clone(), si.clone()), - value_expr.clone(), + value_expr, env.clone(), state_param.clone(), parser_always_advancing.clone(), @@ -1070,7 +1059,7 @@ pub fn collect_parser_progress_edges( let body_edges = match let_body(body.clone()) { Some(b) => collect_parser_progress_edges( caller.clone(), - b.clone(), + b, state_param.clone(), scc_name_set.clone(), next_env, @@ -1178,7 +1167,7 @@ pub fn parser_record_field_value( pub fn parser_expr_is_none(expr: Rc) -> bool { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -1211,7 +1200,7 @@ pub fn parser_success_progress( expr_var_name_at(expr.clone(), si.clone()), ) { Some(source) => parser_result_state_progress( - source.clone(), + source, parser_always_advancing.clone(), consumed_true_set.clone(), expr_var_name_at(expr.clone(), si.clone()), @@ -1234,14 +1223,14 @@ pub fn parser_success_progress( ExprData::ExprRecordLit { parent_enum: _, .. } => { match parser_record_field_value(expr.clone(), "err".to_string(), si.clone()) { Some(err_expr) => { - if parser_expr_is_none(err_expr.clone()) { + if parser_expr_is_none(err_expr) { match parser_record_field_value( expr.clone(), "state".to_string(), si.clone(), ) { Some(state_expr) => parser_state_expr_progress( - state_expr.clone(), + state_expr, state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -1260,9 +1249,7 @@ pub fn parser_success_progress( ExprData::ExprIf => { let cond = if_condition(expr.clone()); let then_consumed = match parser_progress_flag_var(cond, si.clone()) { - Some(name) => { - v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) - } + Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), None => consumed_true_set.clone(), }; let then_progress = parser_success_progress( @@ -1275,7 +1262,7 @@ pub fn parser_success_progress( ); let else_progress = match if_else_branch(expr.clone()) { Some(eb) => parser_success_progress( - eb.clone(), + eb, state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -1298,9 +1285,9 @@ pub fn parser_success_progress( ); match let_body(expr.clone()) { Some(body) => parser_success_progress( - body.clone(), + body, state_param.clone(), - next_env.clone(), + next_env, parser_always_advancing.clone(), consumed_true_set.clone(), si.clone(), @@ -1347,7 +1334,7 @@ pub fn parser_success_progress( ); match expr.children.clone().last().cloned() { Some(last_stmt) => parser_success_progress( - last_stmt.clone(), + last_stmt, state_param.clone(), acc.env.clone(), parser_always_advancing.clone(), @@ -1372,7 +1359,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1393,8 +1380,8 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - entry.body.clone(), - state_param.clone(), + (*entry.body).clone(), + state_param, empty_parser_progress_env(), proven.clone(), v1_rt::rc_empty_map::(), @@ -1426,7 +1413,7 @@ pub fn infer_parser_always_advancing_members_worklist( ); if set_has(proven.clone(), name.clone()) { { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } @@ -1444,7 +1431,8 @@ pub fn infer_parser_always_advancing_members_worklist( None => Rc::new(vec![]), }; { - let __tco_0 = deduplicate(v1_rt::concat(rest, callers)); + let __tco_0 = + deduplicate(v1_rt::concat(rest.clone(), callers.clone())); let __tco_1 = v1_rt::rc_map_insert(proven, name.clone(), true); queue = __tco_0; proven = __tco_1; @@ -1452,14 +1440,14 @@ pub fn infer_parser_always_advancing_members_worklist( } } else { { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } } } None => { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } @@ -1618,7 +1606,7 @@ pub fn same_progress_subgraph_has_cycle( { let same_cross_edges = Rc::new({ let mut __result = Vec::new(); - for edge in same_edges.clone().iter().cloned() { + for edge in same_edges.iter().cloned() { if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } @@ -1671,7 +1659,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -1723,7 +1711,7 @@ pub fn classify_parser_scc_recursion_pattern( __all }; if (all_known - && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) { Some(lower_call_pattern(Rc::new( CallPattern::ParserAdvanceCall { @@ -1856,7 +1844,7 @@ pub fn max_path_self_calls_with_cont( ); let else_calls = match if_else_branch(body.clone()) { Some(eb) => max_path_self_calls_with_cont( - eb.clone(), + eb, func_name.clone(), continue_calls.clone(), si.clone(), @@ -1864,9 +1852,9 @@ pub fn max_path_self_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls.clone() + then_calls } else { - else_calls.clone() + else_calls }; (cond_calls + branch_max) } @@ -1887,7 +1875,7 @@ pub fn max_path_self_calls_with_cont( ); let body_calls = match let_body(body.clone()) { Some(b) => max_path_self_calls_with_cont( - b.clone(), + b, func_name.clone(), continue_calls.clone(), si.clone(), @@ -1972,12 +1960,12 @@ pub fn max_path_self_calls_block( continue_calls: i64, si: Rc>>, ) -> i64 { - v1_rt::reverse(stmts).iter().cloned().fold( - continue_calls.clone(), - |acc: i64, stmt: Rc| { + v1_rt::reverse(stmts) + .iter() + .cloned() + .fold(continue_calls, |acc: i64, stmt: Rc| { max_path_self_calls_with_cont(stmt.clone(), func_name.clone(), acc, si.clone()) - }, - ) + }) } pub fn count_target_calls( @@ -2083,7 +2071,7 @@ pub fn max_path_target_calls_with_cont( ); let else_calls = match if_else_branch(body.clone()) { Some(eb) => max_path_target_calls_with_cont( - eb.clone(), + eb, target_set.clone(), continue_calls.clone(), si.clone(), @@ -2091,9 +2079,9 @@ pub fn max_path_target_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls.clone() + then_calls } else { - else_calls.clone() + else_calls }; (cond_calls + branch_max) } @@ -2114,7 +2102,7 @@ pub fn max_path_target_calls_with_cont( ); let body_calls = match let_body(body.clone()) { Some(b) => max_path_target_calls_with_cont( - b.clone(), + b, target_set.clone(), continue_calls.clone(), si.clone(), @@ -2207,7 +2195,11 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), + recursive_measure_param_names( + (*entry.body).clone(), + entry.params.clone(), + si.clone(), + ), ), None => acc.clone(), }, @@ -2228,11 +2220,10 @@ pub fn target_call_has_arithmetic_descent( } else { match v1_rt::map_get(&func_index, callee.clone()) { Some(callee_entry) => { - let callee_measure_params = - match v1_rt::map_get(&scc_measure_params, callee.clone()) { - Some(params) => params.clone(), - None => v1_rt::rc_empty_map::(), - }; + let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee) { + Some(params) => params, + None => v1_rt::rc_empty_map::(), + }; { let mut __found = false; for pair in Rc::new( @@ -2368,7 +2359,7 @@ pub fn expr_descending_witness_source( } => { break v1_rt::map_get( &descending_witness_names, - expr_var_name_at(expr.clone(), si), + expr_var_name_at(expr.clone(), si.clone()), ); } ExprData::ExprBinOp { op, .. } => match op.clone() { @@ -2403,9 +2394,9 @@ pub fn condition_param_names( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(expr.clone(), si.clone()); + let name = expr_var_name_at(expr.clone(), si); match v1_rt::map_get(¶m_set, name.clone()) { - Some(_) => seed_string_map(name.clone(), name.clone()), + Some(_) => seed_string_map(name.clone(), name), None => v1_rt::rc_empty_map::(), } } @@ -2446,9 +2437,7 @@ pub fn recursive_measure_param_names( si.clone(), ); let else_names = match if_else_branch(body.clone()) { - Some(eb) => { - recursive_measure_param_names(eb.clone(), params.clone(), si.clone()) - } + Some(eb) => recursive_measure_param_names(eb, params.clone(), si.clone()), None => v1_rt::rc_empty_map::(), }; v1_rt::rc_map_merge( @@ -2478,7 +2467,7 @@ pub fn recursive_measure_param_names( v1_rt::rc_map_merge(scrut_names, arm_names) } ExprData::ExprLet => match let_body(body.clone()) { - Some(b) => recursive_measure_param_names(b.clone(), params.clone(), si.clone()), + Some(b) => recursive_measure_param_names(b, params.clone(), si.clone()), None => v1_rt::rc_empty_map::(), }, ExprData::ExprBlock => body.children.clone().iter().cloned().fold( @@ -2510,7 +2499,7 @@ pub fn recursive_param_name_for_arg( si: Rc>>, ) -> Option { match arg_name_at(arg_node, si.clone()) { - Some(name) => Some(name.clone()), + Some(name) => Some(name), None => Rc::new({ let mut __result = Vec::new(); for pair in Rc::new({ @@ -2546,7 +2535,7 @@ pub fn recursive_param_name_for_arg( pub fn is_descending_expr(expr: Rc) -> bool { match (*expr.expr_data.clone()).clone() { - ExprData::ExprBinOp { op, .. } => match op.clone() { + ExprData::ExprBinOp { op, .. } => match op { BinOp::Sub => match (*binop_left(expr.clone()).expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. @@ -2660,18 +2649,18 @@ pub fn is_children_of_param( ExprData::ExprFieldAccess { .. } => { let base = field_access_base(expr.clone()); let field = field_access_field_at(expr.clone(), si.clone()); - break (is_children_list_field(field) + break (is_children_list_field(field.clone()) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name.clone()), _ => false, }); } ExprData::ExprVar { binding_kind: _, .. } => { - break set_has(vars, expr_var_name_at(expr.clone(), si.clone())); + break set_has(vars.clone(), expr_var_name_at(expr.clone(), si.clone())); } ExprData::ExprMethodCall { method_semantics: ms, @@ -2709,14 +2698,14 @@ pub fn is_structural_children( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(base.clone(), si.clone())), + } => set_has(vars.clone(), expr_var_name_at(base, si.clone())), _ => false, }) } ExprData::ExprMethodCall { method_semantics: ms, .. - } => match method_size_effect(ms.clone()) { + } => match method_size_effect(ms) { Some(CollectionSizeEffect::ShrinkEffect) => is_structural_children( method_receiver(expr.clone()), param_name.clone(), @@ -2749,7 +2738,7 @@ pub fn is_child_descent_expr( ExprData::ExprMethodCall { method_semantics: ms, .. - } => match method_size_effect(ms.clone()) { + } => match method_size_effect(ms) { Some(CollectionSizeEffect::ProjectionEffect) => is_children_of_param( method_receiver(expr.clone()), param_name.clone(), @@ -2778,8 +2767,8 @@ pub fn is_tree_size_preserving_wrapper( pub fn wrapper_inner_arg(expr: Rc) -> Rc { match expr.children.clone().first().cloned() { - Some(arg_node) => arg_value(arg_node.clone()), - None => expr.clone(), + Some(arg_node) => arg_value(arg_node), + None => expr, } } @@ -2795,8 +2784,8 @@ pub fn is_sub_value_extractor(expr: Rc, si: Rc) -> Rc { match expr.children.clone().first().cloned() { - Some(arg_node) => arg_value(arg_node.clone()), - None => expr.clone(), + Some(arg_node) => arg_value(arg_node), + None => expr, } } @@ -2810,7 +2799,7 @@ pub fn is_list_shrink_expr( method_semantics: ms, .. } => { - let is_shrink = match method_size_effect(ms.clone()) { + let is_shrink = match method_size_effect(ms) { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }; @@ -2822,17 +2811,15 @@ pub fn is_list_shrink_expr( _ => false, }) && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => { - match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { - unreachable!() - }; - (n.clone() > 0) - } - _ => false, + Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { + unreachable!() + }; + (n > 0) } - } + _ => false, + }, None => false, }) } @@ -2846,23 +2833,21 @@ pub fn is_generalized_shrink(expr: Rc, si: Rc { - let is_shrink = match method_size_effect(ms.clone()) { + let is_shrink = match method_size_effect(ms) { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }; (is_shrink && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => { - match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { - unreachable!() - }; - (n.clone() > 0) - } - _ => false, + Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { + unreachable!() + }; + (n > 0) } - } + _ => false, + }, None => false, }) } @@ -2896,9 +2881,7 @@ pub fn is_tokens_consuming_call( ) -> bool { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => match consuming_tokens_arg(expr.clone(), si.clone()) { - Some(tokens_arg) => { - is_tokens_input_expr(tokens_arg.clone(), param_name, vars, si.clone()) - } + Some(tokens_arg) => is_tokens_input_expr(tokens_arg, param_name, vars, si.clone()), None => false, }, _ => false, @@ -2940,11 +2923,12 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); + break ((vname.clone() == param_name.clone()) + || set_has(vars.clone(), vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field == param_name.clone()) { + if (field.clone() == param_name.clone()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2954,7 +2938,7 @@ pub fn is_tokens_input_expr( } => { let bname = expr_var_name_at(base.clone(), si.clone()); break ((bname.clone() == param_name.clone()) - || set_has(vars, bname.clone())); + || set_has(vars.clone(), bname.clone())); } _ => { break false; @@ -3063,7 +3047,7 @@ pub fn expr_contains_descent( si.clone(), ) && match if_else_branch(expr.clone()) { Some(eb) => expr_contains_descent( - eb.clone(), + eb, param_name.clone(), vars.clone(), check_child.clone(), @@ -3075,7 +3059,7 @@ pub fn expr_contains_descent( } ExprData::ExprBlock => match expr.children.clone().last().cloned() { Some(last_stmt) => expr_contains_descent( - last_stmt.clone(), + last_stmt, param_name.clone(), vars.clone(), check_child.clone(), @@ -3095,9 +3079,9 @@ pub fn expr_contains_descent( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3107,7 +3091,7 @@ pub fn expr_contains_descent( .. } => { let receiver = method_receiver(expr.clone()); - match method_size_effect(ms.clone()) { + match method_size_effect(ms) { Some(CollectionSizeEffect::ShrinkEffect) => expr_contains_descent( receiver, param_name.clone(), @@ -3151,11 +3135,11 @@ pub fn collect_field_binding_names( || match (*field_binding_pattern(fb)).clone() { MatchPattern::Bind { name: binding_name, .. - } => v1_rt::rc_map_insert(vars, binding_name.clone(), true), + } => v1_rt::rc_map_insert(vars, binding_name, true), MatchPattern::VariantPattern { field_bindings: nested, .. - } => nested.clone().iter().cloned().fold( + } => nested.iter().cloned().fold( vars, |inner: Rc>, nested_fb: Rc| { collect_field_binding_names(nested_fb.clone(), inner) @@ -3189,8 +3173,8 @@ pub fn is_if_option_descent( Some(eb) => match (*eb.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(eb.clone(), si.clone()) == "none".to_string()), - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + } => (expr_var_name_at(eb, si.clone()) == "none".to_string()), + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -3390,7 +3374,7 @@ pub fn collect_descent_vars( } _ => false, }; - ((inner_is_descent.clone() || inner_is_var.clone()) || inner_is_param) + ((inner_is_descent || inner_is_var) || inner_is_param) } } else { false @@ -3404,9 +3388,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3432,10 +3416,7 @@ pub fn collect_descent_vars( || match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has( - vars.clone(), - expr_var_name_at(inner.clone(), si.clone()), - ), + } => set_has(vars.clone(), expr_var_name_at(inner, si.clone())), _ => false, }) } @@ -3445,12 +3426,7 @@ pub fn collect_descent_vars( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call( - val.clone(), - param_name.clone(), - vars.clone(), - si.clone(), - )); + && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); let val_is_descent = ((((((((is_direct_descent || is_descent_var) || is_option_descent) || is_match_descent) @@ -3470,7 +3446,7 @@ pub fn collect_descent_vars( }; match let_body(body.clone()) { Some(b) => collect_descent_vars( - b.clone(), + b, param_name.clone(), next_vars, check_child.clone(), @@ -3494,9 +3470,8 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -3558,7 +3533,7 @@ pub fn collect_descent_vars( ); let else_vars = match if_else_branch(body.clone()) { Some(eb) => collect_descent_vars( - eb.clone(), + eb, param_name.clone(), vars.clone(), check_child.clone(), @@ -3584,7 +3559,7 @@ pub fn collect_descent_vars( ), ExprData::ExprReturn => match body.children.clone().first().cloned() { Some(inner) => collect_descent_vars( - inner.clone(), + inner, param_name.clone(), vars.clone(), check_child.clone(), @@ -3666,15 +3641,15 @@ pub fn all_self_calls_descend_inc( let is_children_list = match (*val.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(val.clone()); - let field = field_access_field_at(val.clone(), si.clone()); + let field = field_access_field_at(val, si.clone()); (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3692,10 +3667,10 @@ pub fn all_self_calls_descend_inc( }; let body_ok = match let_body(body.clone()) { Some(b) => all_self_calls_descend_inc( - b.clone(), + b, func_name.clone(), param_name.clone(), - next_vars.clone(), + next_vars, check_child.clone(), check_list.clone(), si.clone(), @@ -3727,9 +3702,8 @@ pub fn all_self_calls_descend_inc( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -3805,7 +3779,7 @@ pub fn all_self_calls_descend_inc( ); let else_ok = match if_else_branch(body.clone()) { Some(eb) => all_self_calls_descend_inc( - eb.clone(), + eb, func_name.clone(), param_name.clone(), vars.clone(), @@ -3921,7 +3895,7 @@ pub fn all_self_calls_descend_inc( if (is_iter && is_struct) { { let recv_ok = all_self_calls_descend_inc( - receiver.clone(), + receiver, func_name.clone(), param_name.clone(), vars.clone(), @@ -4060,16 +4034,16 @@ pub fn matches_on_sub_value_field( ) -> bool { match unwrap_to_match(body) { Some(m) => { - let scrut = match_scrutinee(m.clone()); + let scrut = match_scrutinee(m); match (*scrut.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(scrut.clone()); - let field = field_access_field_at(scrut.clone(), si.clone()); + let field = field_access_field_at(scrut, si.clone()); (is_sub_value_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => (expr_var_name_at(base, si.clone()) == param_name), _ => false, }) } @@ -4150,13 +4124,13 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left.clone(), si) == param_name) + ((expr_var_name_at(left, si) == param_name) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { unreachable!() }; - (n.clone() > 0) + (n > 0) } _ => false, }) @@ -4205,7 +4179,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4237,7 +4211,7 @@ pub fn classify_self_call_evidence( DescentEvidence::NonIncreasing => { DescentEvidence::Strict } - _ => inner_ev.clone(), + _ => inner_ev, } } } else { @@ -4247,7 +4221,7 @@ pub fn classify_self_call_evidence( si.clone(), ) { Some(inner) => classify_self_call_evidence( - inner.clone(), + inner, param_name.clone(), descent_vars.clone(), check_child.clone(), @@ -4268,9 +4242,9 @@ pub fn classify_self_call_evidence( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname == param_name.clone())) { DescentEvidence::Strict } else { @@ -4483,7 +4457,7 @@ pub fn collect_evidence_incremental( } _ => false, }; - ((inner_d.clone() || inner_v.clone()) || inner_p) + ((inner_d || inner_v) || inner_p) } } else { false @@ -4497,9 +4471,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -4525,10 +4499,7 @@ pub fn collect_evidence_incremental( || match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has( - vars.clone(), - expr_var_name_at(inner.clone(), si.clone()), - ), + } => set_has(vars.clone(), expr_var_name_at(inner, si.clone())), _ => false, }) } @@ -4538,12 +4509,7 @@ pub fn collect_evidence_incremental( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call( - val.clone(), - param_name.clone(), - vars.clone(), - si.clone(), - )); + && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); let next_vars = if ((((((((is_direct || is_var) || is_option) || is_match_descent) || is_wrapped) @@ -4562,10 +4528,10 @@ pub fn collect_evidence_incremental( }; let body_ev = match let_body(body.clone()) { Some(b) => collect_evidence_incremental( - b.clone(), + b, func_name.clone(), param_name.clone(), - next_vars.clone(), + next_vars, check_child.clone(), check_list.clone(), branching_only.clone(), @@ -4599,9 +4565,8 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -4698,7 +4663,7 @@ pub fn collect_evidence_incremental( None } else { collect_evidence_incremental( - then_branch.clone(), + then_branch, func_name.clone(), param_name.clone(), vars.clone(), @@ -4711,9 +4676,9 @@ pub fn collect_evidence_incremental( let else_ev = if (branching_only.clone() && (else_path == 0)) { None } else { - match else_opt.clone() { + match else_opt { Some(eb) => collect_evidence_incremental( - eb.clone(), + eb, func_name.clone(), param_name.clone(), vars.clone(), @@ -4826,7 +4791,7 @@ pub fn collect_evidence_incremental( if (is_iter && is_struct) { { let recv_ev = collect_evidence_incremental( - receiver.clone(), + receiver, func_name.clone(), param_name.clone(), vars.clone(), @@ -5054,7 +5019,7 @@ pub fn construct_termination_proof( } }); let single_dim_proof = match structural_proof.clone() { - Some(_) => structural_proof.clone(), + Some(_) => structural_proof, None => match parser_state_param(params.clone(), si.clone()) { Some(state_param) => { let self_set = seed_bool_map(func_name.clone()); @@ -5070,7 +5035,7 @@ pub fn construct_termination_proof( ); if (((edges.clone().len() as i64) > 0) && { let mut __all = true; - for edge in edges.clone().iter().cloned() { + for edge in edges.iter().cloned() { if !(edge.progress.clone() == DescentEvidence::Strict) { __all = false; break; @@ -5091,7 +5056,7 @@ pub fn construct_termination_proof( }, }; match single_dim_proof.clone() { - Some(_) => single_dim_proof.clone(), + Some(_) => single_dim_proof, None => { let self_set = seed_bool_map(func_name.clone()); let func_entry = Rc::new(FuncEntry { @@ -5105,7 +5070,7 @@ pub fn construct_termination_proof( construct_scc_termination_proof( Rc::new(vec![func_name.clone()]), func_index, - self_set.clone(), + self_set, si.clone(), ) } @@ -5209,29 +5174,27 @@ pub fn construct_branching_termination_proof( pub fn proof_to_call_pattern(proof: Rc) -> Rc { match proof.dimensions.clone().first().cloned() { - Some(dim) => match (*dim.clone()).clone() { + Some(dim) => match (*dim).clone() { RankingDimension::TreeSize { param: p, .. } => { - Rc::new(CallPattern::ChildAccessorCall { - accessor: p.clone(), - }) + Rc::new(CallPattern::ChildAccessorCall { accessor: p }) } RankingDimension::ListLength { param: p, .. } => { Rc::new(CallPattern::CollectionShrinkCall { amount: Rc::new(PositiveDescentAmount::OneStep), - collection: p.clone(), + collection: p, }) } RankingDimension::ArithmeticValue { param: p, .. } => { Rc::new(CallPattern::ArithmeticSubtractCall { steps: Rc::new(PositiveDescentAmount::OneStep), - ring_param: p.clone(), + ring_param: p, }) } RankingDimension::TokenPosition { param: p, .. } => { - Rc::new(CallPattern::ParserAdvanceCall { witness: p.clone() }) + Rc::new(CallPattern::ParserAdvanceCall { witness: p }) } RankingDimension::SetCardinality { param: p, .. } => { - Rc::new(CallPattern::WorklistDrainCall { element: p.clone() }) + Rc::new(CallPattern::WorklistDrainCall { element: p }) } }, None => Rc::new(CallPattern::SameArgumentCall), @@ -5250,7 +5213,7 @@ pub fn classify_recursion_pattern( if (path_calls.clone() == 0) { { let outer = match params.clone().first().cloned() { - Some(p0) => param_node_name_at(p0.clone(), si.clone()), + Some(p0) => param_node_name_at(p0, si.clone()), None => "_fold_body".to_string(), }; lower_call_pattern(Rc::new(CallPattern::FoldBodyCall { @@ -5333,7 +5296,7 @@ pub fn classify_recursion_pattern( let first_call = if all_calls_arithmetic_only { Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.clone().iter().cloned() { + for call_ev in all_evidence.iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5382,10 +5345,10 @@ pub fn classify_recursion_pattern( __result }); match tree_rels.clone().first().cloned() { - Some(_) => tree_rels.clone().first().cloned(), + Some(_) => tree_rels.first().cloned(), None => Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.clone().iter().cloned() { + for call_ev in all_evidence.iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5410,9 +5373,7 @@ pub fn classify_recursion_pattern( }; let is_arithmetic_branching = match first_call.clone() { Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::ArithmeticDescent { .. } => { - (path_calls.clone() > 1) - } + SubValueRelation::ArithmeticDescent { .. } => (path_calls > 1), _ => false, }, None => false, @@ -5420,9 +5381,9 @@ pub fn classify_recursion_pattern( if is_arithmetic_branching { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } else { - match first_call.clone() { - Some(rel) => match sub_value_to_lowering_target(rel.clone()) { - Some(target) => target.clone(), + match first_call { + Some(rel) => match sub_value_to_lowering_target(rel) { + Some(target) => target, None => { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } @@ -5501,16 +5462,16 @@ pub fn classify_recursion_pattern( } None => false, }; - match proof.clone() { + match proof { Some(p) => { - if ((path_calls.clone() == 1) || proof_safe_for_branching.clone()) { - lower_call_pattern(proof_to_call_pattern(p.clone())) + if ((path_calls == 1) || proof_safe_for_branching) { + lower_call_pattern(proof_to_call_pattern(p)) } else { if branching_proof_safe { - match branching_proof.clone() { - Some(bp) => lower_call_pattern(proof_to_call_pattern( - bp.clone(), - )), + match branching_proof { + Some(bp) => { + lower_call_pattern(proof_to_call_pattern(bp)) + } None => lower_call_pattern(Rc::new( CallPattern::SameArgumentCall, )), @@ -5521,13 +5482,11 @@ pub fn classify_recursion_pattern( } } None => { - if (path_calls.clone() > 1) { - match branching_proof.clone() { + if (path_calls > 1) { + match branching_proof { Some(bp) => { if branching_proof_safe { - lower_call_pattern(proof_to_call_pattern( - bp.clone(), - )) + lower_call_pattern(proof_to_call_pattern(bp)) } else { lower_call_pattern(Rc::new( CallPattern::SameArgumentCall, @@ -5559,10 +5518,10 @@ pub fn bounded_recursive_cost( let p = size_bound_param(target.bound.clone()); match p { Some(v) => { - let var = v1_rt::concat("n_".to_string(), v.clone()); + let var = v1_rt::concat("n_".to_string(), v); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), + upper: Rc::new(SizeExpr::SizeVar { name: var }), body: simplify_cost(per_iter), }) } @@ -5582,10 +5541,10 @@ pub fn bounded_scc_cost( let p = size_bound_param(target.bound.clone()); match p { Some(v) => { - let var = v1_rt::concat("n_".to_string(), v.clone()); + let var = v1_rt::concat("n_".to_string(), v); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), + upper: Rc::new(SizeExpr::SizeVar { name: var }), body: simplify_cost(per_iter), }) } @@ -5593,7 +5552,7 @@ pub fn bounded_scc_cost( reason: v1_rt::concat( "same-argument mutual recursion in ".to_string(), match members.first().cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "scc".to_string(), }, ), @@ -5607,21 +5566,21 @@ pub fn is_unknown_cost(expr: Rc) -> bool { CostExpr::CostUnknown { reason: _, .. } => true, CostExpr::CostAdd { left: l, right: r, .. - } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), + } => (is_unknown_cost(l) || is_unknown_cost(r)), CostExpr::CostMul { left: l, right: r, .. - } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), + } => (is_unknown_cost(l) || is_unknown_cost(r)), CostExpr::CostMax { left: l, right: r, .. - } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), - CostExpr::CostSum { body: bd, .. } => is_unknown_cost(bd.clone()), + } => (is_unknown_cost(l) || is_unknown_cost(r)), + CostExpr::CostSum { body: bd, .. } => is_unknown_cost(bd), _ => false, }) } pub fn extract_unknown_reason(mut expr: Rc) -> String { loop { - match (*expr).clone() { + match (*expr.clone()).clone() { CostExpr::CostUnknown { reason: r, .. } => { break r.clone(); } @@ -5701,7 +5660,7 @@ pub fn collect_local_call_edges_in_expr( if set_has(local_func_set.clone(), callee.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: callee.clone(), + callee: callee, })]) } else { Rc::new(vec![]) @@ -5753,7 +5712,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), local_func_set.clone(), si.clone(), )) @@ -5791,7 +5750,7 @@ pub fn build_call_graph( pub fn scc_label(members: Rc>) -> String { match members.first().cloned() { - Some(name) => name.clone(), + Some(name) => name, None => "scc".to_string(), } } @@ -5822,7 +5781,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5848,14 +5807,14 @@ pub fn classify_scc_call_progress( ); match inner_progress.clone() { DescentEvidence::NonIncreasing => DescentEvidence::Strict, - _ => inner_progress.clone(), + _ => inner_progress, } } } else { if is_list_passthrough_call(arg_expr.clone(), si.clone()) { match list_passthrough_inner_arg(arg_expr.clone(), si.clone()) { Some(inner) => classify_scc_call_progress( - inner.clone(), + inner, param_name.clone(), descent_vars.clone(), si.clone(), @@ -5874,9 +5833,9 @@ pub fn classify_scc_call_progress( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname == param_name.clone())) { DescentEvidence::Strict } else { @@ -5946,7 +5905,7 @@ pub fn collect_scc_child_edges( { let callee_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { - Some(p) => p.clone(), + Some(p) => p, None => v1_rt::rc_empty_map::(), }; let progress = body.children.clone().iter().cloned().fold( @@ -5983,7 +5942,7 @@ pub fn collect_scc_child_edges( ); Rc::new(vec![Rc::new(ParserProgressEdge { caller: caller.clone(), - callee: callee.clone(), + callee: callee, progress: progress, })]) } @@ -6028,7 +5987,7 @@ pub fn collect_scc_child_edges( if (is_iter && is_struct) { { let recv_edges = collect_scc_child_edges( - receiver.clone(), + receiver, caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6225,7 +6184,7 @@ pub fn collect_scc_child_edges( } _ => false, }; - ((inner_d.clone() || inner_v.clone()) || inner_p) + ((inner_d || inner_v) || inner_p) } } else { false @@ -6239,9 +6198,9 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(descent_vars.clone(), bname.clone())) + || set_has(descent_vars.clone(), bname)) } _ => false, }) @@ -6269,7 +6228,7 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => set_has( descent_vars.clone(), - expr_var_name_at(inner.clone(), si.clone()), + expr_var_name_at(inner, si.clone()), ), _ => false, }) @@ -6281,7 +6240,7 @@ pub fn collect_scc_child_edges( }; let is_consuming_helper = (check_list.clone() && is_tokens_consuming_call( - val.clone(), + val, param_name.clone(), descent_vars.clone(), si.clone(), @@ -6304,10 +6263,10 @@ pub fn collect_scc_child_edges( }; let body_edges = match let_body(body.clone()) { Some(b) => collect_scc_child_edges( - b.clone(), + b, caller.clone(), param_name.clone(), - next_vars.clone(), + next_vars, target_set.clone(), check_child.clone(), check_list.clone(), @@ -6415,7 +6374,7 @@ pub fn collect_scc_child_edges( ); let else_edges = match else_opt { Some(eb) => collect_scc_child_edges( - eb.clone(), + eb, caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6474,7 +6433,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - entry.body.clone(), + (*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6482,7 +6441,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - entry.body.clone(), + (*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6516,7 +6475,7 @@ pub fn is_scc_container_child_descent( }); let unknown_edge_count = count_unknown_progress_edges(edges.clone()); (((unknown_edge_count == 0) && ((edges.clone().len() as i64) > 0)) - && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) } } @@ -6575,8 +6534,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6628,9 +6587,9 @@ pub fn pick_best_param_edges( candidate: Rc>, ) -> Rc> { if (count_known_in_edge_map(candidate.clone()) > count_known_in_edge_map(current.clone())) { - candidate.clone() + candidate } else { - current.clone() + current } } @@ -6650,15 +6609,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6732,8 +6691,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6781,7 +6740,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6836,7 +6795,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6875,7 +6834,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - entry.body.clone(), + (*entry.body).clone(), name.clone(), si.clone(), ); @@ -6941,20 +6900,17 @@ pub fn construct_scc_termination_proof( let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { param: if (cx_l2_param.clone() != "".to_string()) { - cx_l2_param.clone() + cx_l2_param } else { "scc".to_string() }, })]), }); if ((cx_l2_all_known && ((cx_l2_edges.clone().len() as i64) > 0)) - && (proof_has_non_descending_cycle( - cx_l2_proof.clone(), - members.clone(), - cx_l2_edges.clone(), - ) == false)) + && (proof_has_non_descending_cycle(cx_l2_proof.clone(), members.clone(), cx_l2_edges) + == false)) { - Some(cx_l2_proof.clone()) + Some(cx_l2_proof) } else { { let tree_edges = collect_scc_proof_edges_for_dim( @@ -6987,10 +6943,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tree_proof.clone(), members.clone(), - tree_edges.clone(), + tree_edges, ) == false)) { - Some(tree_proof.clone()) + Some(tree_proof) } else { { let list_edges = collect_scc_proof_edges_for_dim( @@ -7023,10 +6979,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( list_proof.clone(), members.clone(), - list_edges.clone(), + list_edges, ) == false)) { - Some(list_proof.clone()) + Some(list_proof) } else { { let parser_edges = collect_scc_parser_proof_edges( @@ -7059,10 +7015,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( parser_proof.clone(), members.clone(), - parser_edges.clone(), + parser_edges, ) == false)) { - Some(parser_proof.clone()) + Some(parser_proof) } else { { let lex_edges = collect_scc_independent_dim_edges( @@ -7102,10 +7058,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( lex_proof.clone(), members.clone(), - lex_edges.clone(), + lex_edges, ) == false)) { - Some(lex_proof.clone()) + Some(lex_proof) } else { { let tree_parser_edges = @@ -7156,10 +7112,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tp_proof.clone(), members.clone(), - tree_parser_edges.clone(), + tree_parser_edges, ) == false)) { - Some(tp_proof.clone()) + Some(tp_proof) } else { None } @@ -7195,7 +7151,7 @@ pub fn classify_scc_recursion_pattern( si.clone(), ); match proof { - Some(p) => lower_call_pattern(proof_to_call_pattern(p.clone())), + Some(p) => lower_call_pattern(proof_to_call_pattern(p)), None => { let scc_measure_params = build_scc_measure_params(members.clone(), func_index.clone(), si.clone()); @@ -7204,7 +7160,7 @@ pub fn classify_scc_recursion_pattern( func_index.clone(), si.clone(), ) { - Some(parser_target) => parser_target.clone(), + Some(parser_target) => parser_target, None => { let all_arithmetic = { let mut __all = true; @@ -7212,12 +7168,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7235,18 +7191,15 @@ pub fn classify_scc_recursion_pattern( if all_arithmetic { { let ring_param = match members.clone().first().cloned() { - Some(m0) => { - match v1_rt::map_get(&scc_measure_params, m0.clone()) { - Some(pmap) => match Rc::new(v1_rt::map_keys(&pmap)) - .first() - .cloned() - { - Some(k) => k.clone(), + Some(m0) => match v1_rt::map_get(&scc_measure_params, m0) { + Some(pmap) => { + match Rc::new(v1_rt::map_keys(&pmap)).first().cloned() { + Some(k) => k, None => "_scc_arithmetic".to_string(), - }, - None => "_scc_arithmetic".to_string(), + } } - } + None => "_scc_arithmetic".to_string(), + }, None => "_scc_arithmetic".to_string(), }; lower_call_pattern(Rc::new(CallPattern::ArithmeticSubtractCall { @@ -7359,9 +7312,9 @@ pub fn build_scc_index( ); Rc::new(SccResult { index: result.index.clone(), - topo_order: topo_order.clone(), + topo_order: topo_order, processing_order: finish.order.clone(), - call_graph: graph.clone(), + call_graph: graph, }) } } @@ -7370,9 +7323,9 @@ pub fn cost_seq(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a.clone(), + CostExpr::CostConst { value: 0, .. } => a, _ => Rc::new(CostExpr::CostAdd { - left: a.clone(), + left: a, right: b.clone(), }), }, @@ -7383,9 +7336,9 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a.clone(), + CostExpr::CostConst { value: 0, .. } => a, _ => Rc::new(CostExpr::CostMax { - left: a.clone(), + left: a, right: b.clone(), }), }, @@ -7434,7 +7387,7 @@ pub fn method_preserves_collection_size(method_semantics: Option match se.clone() { + } => match se { Some(CollectionSizeEffect::ShrinkEffect) => true, Some(CollectionSizeEffect::IdentityEffect) => true, _ => false, @@ -7452,12 +7405,12 @@ pub fn receiver_size_var( match (*recv.expr_data.clone()).clone() { ExprData::ExprVar { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: expr_var_name_at(recv.clone(), si), + collection: expr_var_name_at(recv.clone(), si.clone()), }); } ExprData::ExprFieldAccess { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: field_access_field_at(recv.clone(), si), + collection: field_access_field_at(recv.clone(), si.clone()), }); } ExprData::ExprMethodCall { @@ -7470,7 +7423,7 @@ pub fn receiver_size_var( }; if method_preserves_collection_size(method_semantics.clone()) { { - let __tco_0 = inner_recv; + let __tco_0 = inner_recv.clone(); recv = __tco_0; continue; } @@ -7491,8 +7444,8 @@ pub fn receiver_size_var( pub fn size_binder_name(size: Rc) -> String { match (*size).clone() { - SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c.clone()), - SizeExpr::SizeVar { name: n, .. } => n.clone(), + SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c), + SizeExpr::SizeVar { name: n, .. } => n, _ => "_i".to_string(), } } @@ -7514,7 +7467,7 @@ pub fn resolve_lambda_arg( .first() .cloned(); match f_arg { - Some(fa) => Some(arg_value(fa.clone())), + Some(fa) => Some(arg_value(fa)), None => Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { @@ -7543,19 +7496,19 @@ pub fn resolve_callback_cost( let fn_ref = expr_var_name_at(la.clone(), si.clone()); match v1_rt::map_get(&func_index, fn_ref.clone()) { Some(_) => get_or_compute_summary( - fn_ref.clone(), + fn_ref, func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), ), None => cost_of_expr( - la.clone(), + la, func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7563,10 +7516,10 @@ pub fn resolve_callback_cost( } } _ => cost_of_expr( - la.clone(), + la, func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7579,7 +7532,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -7612,7 +7565,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - body_result.summary.clone().work.clone(), + (*body_result.summary.clone().work).clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7631,22 +7584,22 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: body_result.table.clone(), + table: (*body_result.table).clone(), }) } CostShape::ShapeSortBody => { let lambda_arg = resolve_lambda_arg(mc_args, si.clone()); let key_result = match lambda_arg { Some(la) => cost_of_expr( - la.clone(), + la, func_index, scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7658,14 +7611,14 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { base: 2, argument: size.clone(), }); - let per_comparison = key_result.summary.clone().work.clone(); + let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, @@ -7680,12 +7633,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: key_result.table.clone(), + table: (*key_result.table).clone(), }) } CostShape::ShapeLinearScan => { @@ -7708,28 +7661,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -7768,29 +7721,29 @@ pub fn empty_complexity_report() -> Rc { pub fn simplify_cost(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr.clone(), + CostExpr::CostConst { value: _, .. } => expr, CostExpr::CostAdd { left: l, right: r, .. } => { - let sl = simplify_cost(l.clone()); - let sr = simplify_cost(r.clone()); + let sl = simplify_cost(l); + let sr = simplify_cost(r); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr.clone(), + CostExpr::CostConst { value: 0, .. } => sr, CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), - CostExpr::CostConst { value: b, .. } => Rc::new(CostExpr::CostConst { - value: (a.clone() + b.clone()), - }), + CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: b, .. } => { + Rc::new(CostExpr::CostConst { value: (a + b) }) + } _ => Rc::new(CostExpr::CostAdd { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, _ => Rc::new(CostExpr::CostAdd { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7799,21 +7752,21 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostMul { left: l, right: r, .. } => { - let sl = simplify_cost(l.clone()); - let sr = simplify_cost(r.clone()); + let sl = simplify_cost(l); + let sr = simplify_cost(r); let simplified = match (*sl.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sr.clone(), + CostExpr::CostConst { value: 1, .. } => sr, _ => match (*sr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sl.clone(), + CostExpr::CostConst { value: 1, .. } => sl, _ => Rc::new(CostExpr::CostMul { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7822,29 +7775,29 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostMax { left: l, right: r, .. } => { - let sl = simplify_cost(l.clone()); - let sr = simplify_cost(r.clone()); + let sl = simplify_cost(l); + let sr = simplify_cost(r); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr.clone(), + CostExpr::CostConst { value: 0, .. } => sr, CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, CostExpr::CostConst { value: b, .. } => { - if (a.clone() > b.clone()) { - sl.clone() + if (a > b) { + sl } else { - sr.clone() + sr } } _ => Rc::new(CostExpr::CostMax { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, _ => Rc::new(CostExpr::CostMax { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7856,15 +7809,15 @@ pub fn simplify_cost(expr: Rc) -> Rc { body: bd, .. } => { - let sbd = simplify_cost(bd.clone()); + let sbd = simplify_cost(bd); match (*sbd.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } _ => Rc::new(CostExpr::CostSum { - binder: b.clone(), - upper: u.clone(), - body: sbd.clone(), + binder: b, + upper: u, + body: sbd, }), } } @@ -7873,11 +7826,11 @@ pub fn simplify_cost(expr: Rc) -> Rc { argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b.clone(), - argument: a.clone(), + base: b, + argument: a, }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -7885,25 +7838,25 @@ pub fn simplify_cost(expr: Rc) -> Rc { pub fn format_size(size: Rc) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - v1_rt::concat(v1_rt::concat("|".to_string(), c.clone()), "|".to_string()) + v1_rt::concat(v1_rt::concat("|".to_string(), c), "|".to_string()) } - SizeExpr::SizeVar { name: n, .. } => n.clone(), - SizeExpr::SizeConst { value: v, .. } => (v.clone()).to_string(), + SizeExpr::SizeVar { name: n, .. } => n, + SizeExpr::SizeConst { value: v, .. } => (v).to_string(), SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( - v1_rt::concat(format_size(l.clone()), " + ".to_string()), - format_size(r.clone()), + v1_rt::concat(format_size(l), " + ".to_string()), + format_size(r), ), SizeExpr::SizeMax { left: l, right: r, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("max(".to_string(), format_size(l.clone())), + v1_rt::concat("max(".to_string(), format_size(l)), ", ".to_string(), ), - format_size(r.clone()), + format_size(r), ), ")".to_string(), ), @@ -7914,7 +7867,7 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { CostExpr::CostConst { value: v, .. } => { - if (v.clone() <= 0) { + if (v <= 0) { Rc::new(CostExpr::CostConst { value: 0 }) } else { Rc::new(CostExpr::CostConst { value: 1 }) @@ -7923,26 +7876,26 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostAdd { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l.clone()); - let nr = normalize_asymptotic(r.clone()); + let nl = normalize_asymptotic(l); + let nr = normalize_asymptotic(r); if (nl.clone() == nr.clone()) { - nl.clone() + nl } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr.clone(), + CostExpr::CostConst { value: 0, .. } => nr, CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr.clone(), + _ => nr, }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostAdd { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -7951,26 +7904,26 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostMax { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l.clone()); - let nr = normalize_asymptotic(r.clone()); + let nl = normalize_asymptotic(l); + let nr = normalize_asymptotic(r); if (nl.clone() == nr.clone()) { - nl.clone() + nl } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr.clone(), + CostExpr::CostConst { value: 0, .. } => nr, CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr.clone(), + _ => nr, }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostMax { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -7979,21 +7932,21 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostMul { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l.clone()); - let nr = normalize_asymptotic(r.clone()); + let nl = normalize_asymptotic(l); + let nr = normalize_asymptotic(r); match (*nl.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nr.clone(), + CostExpr::CostConst { value: _, .. } => nr, _ => match (*nr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostMul { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -8004,17 +7957,17 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { body: bd, .. } => { - let nbd = normalize_asymptotic(bd.clone()); + let nbd = normalize_asymptotic(bd); match (*nbd.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } _ => match (*u.clone()).clone() { - SizeExpr::SizeConst { value: _, .. } => nbd.clone(), + SizeExpr::SizeConst { value: _, .. } => nbd, _ => Rc::new(CostExpr::CostSum { - binder: b.clone(), - upper: u.clone(), - body: nbd.clone(), + binder: b, + upper: u, + body: nbd, }), }, } @@ -8024,11 +7977,11 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b.clone(), - argument: a.clone(), + base: b, + argument: a, }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -8036,25 +7989,24 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { pub fn format_cost_class(expr: Rc) -> String { match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "O(1)".to_string(), - CostExpr::CostExtern { name: n, .. } => v1_rt::concat( - v1_rt::concat("O(extern(".to_string(), n.clone()), - "))".to_string(), - ), + CostExpr::CostExtern { name: n, .. } => { + v1_rt::concat(v1_rt::concat("O(extern(".to_string(), n), "))".to_string()) + } CostExpr::CostUnknown { reason: _, .. } => "O(?)".to_string(), CostExpr::CostSum { upper: u, body: bd, .. } => match (*bd.clone()).clone() { CostExpr::CostConst { value: _, .. } => v1_rt::concat( - v1_rt::concat("O(".to_string(), format_size(u.clone())), + v1_rt::concat("O(".to_string(), format_size(u)), ")".to_string(), ), _ => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), format_size(u.clone())), + v1_rt::concat("O(".to_string(), format_size(u)), " * ".to_string(), ), - format_cost_inner(bd.clone()), + format_cost_inner(bd), ), ")".to_string(), ), @@ -8064,10 +8016,10 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), format_cost_inner(l.clone())), + v1_rt::concat("O(".to_string(), format_cost_inner(l)), " + ".to_string(), ), - format_cost_inner(r.clone()), + format_cost_inner(r), ), ")".to_string(), ), @@ -8076,10 +8028,10 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), parenthesize_additive_cost(l.clone())), + v1_rt::concat("O(".to_string(), parenthesize_additive_cost(l)), " * ".to_string(), ), - parenthesize_additive_cost(r.clone()), + parenthesize_additive_cost(r), ), ")".to_string(), ), @@ -8088,15 +8040,15 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(max(".to_string(), format_cost_inner(l.clone())), + v1_rt::concat("O(max(".to_string(), format_cost_inner(l)), ", ".to_string(), ), - format_cost_inner(r.clone()), + format_cost_inner(r), ), "))".to_string(), ), CostExpr::CostLog { argument: a, .. } => v1_rt::concat( - v1_rt::concat("O(log ".to_string(), format_size(a.clone())), + v1_rt::concat("O(log ".to_string(), format_size(a)), ")".to_string(), ), } @@ -8108,34 +8060,34 @@ pub fn format_cost_inner(expr: Rc) -> String { CostExpr::CostSum { upper: u, body: bd, .. } => match (*bd.clone()).clone() { - CostExpr::CostConst { value: _, .. } => format_size(u.clone()), + CostExpr::CostConst { value: _, .. } => format_size(u), _ => v1_rt::concat( - v1_rt::concat(format_size(u.clone()), " * ".to_string()), - format_cost_inner(bd.clone()), + v1_rt::concat(format_size(u), " * ".to_string()), + format_cost_inner(bd), ), }, CostExpr::CostAdd { left: l, right: r, .. } => v1_rt::concat( - v1_rt::concat(format_cost_inner(l.clone()), " + ".to_string()), - format_cost_inner(r.clone()), + v1_rt::concat(format_cost_inner(l), " + ".to_string()), + format_cost_inner(r), ), CostExpr::CostMul { left: l, right: r, .. } => { let left_str = match (*l.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( - v1_rt::concat("(".to_string(), format_cost_inner(l.clone())), + v1_rt::concat("(".to_string(), format_cost_inner(l)), ")".to_string(), ), - _ => format_cost_inner(l.clone()), + _ => format_cost_inner(l), }; let right_str = match (*r.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( - v1_rt::concat("(".to_string(), format_cost_inner(r.clone())), + v1_rt::concat("(".to_string(), format_cost_inner(r)), ")".to_string(), ), - _ => format_cost_inner(r.clone()), + _ => format_cost_inner(r), }; v1_rt::concat(v1_rt::concat(left_str, " * ".to_string()), right_str) } @@ -8144,20 +8096,17 @@ pub fn format_cost_inner(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("max(".to_string(), format_cost_inner(l.clone())), + v1_rt::concat("max(".to_string(), format_cost_inner(l)), ", ".to_string(), ), - format_cost_inner(r.clone()), + format_cost_inner(r), ), ")".to_string(), ), - CostExpr::CostLog { argument: a, .. } => { - v1_rt::concat("log ".to_string(), format_size(a.clone())) + CostExpr::CostLog { argument: a, .. } => v1_rt::concat("log ".to_string(), format_size(a)), + CostExpr::CostExtern { name: n, .. } => { + v1_rt::concat(v1_rt::concat("extern(".to_string(), n), ")".to_string()) } - CostExpr::CostExtern { name: n, .. } => v1_rt::concat( - v1_rt::concat("extern(".to_string(), n.clone()), - ")".to_string(), - ), CostExpr::CostUnknown { reason: _, .. } => "?".to_string(), }) } @@ -8235,11 +8184,11 @@ pub fn build_legend(size_names: Rc>) -> Rc { }) } else { if ((unique.clone().len() as i64) == 1) { - match unique.clone().first().cloned() { + match unique.first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( v1_rt::rc_empty_map::(), - name.clone(), + name, "n".to_string(), ), suffix: "".to_string(), @@ -8251,7 +8200,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { } } else { { - let indexed = unique.clone().iter().cloned().fold( + let indexed = unique.iter().cloned().fold( Rc::new(Legend { substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), @@ -8299,31 +8248,27 @@ pub fn build_legend(size_names: Rc>) -> Rc { pub fn substitute_size(size: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*size.clone()).clone() { - SizeExpr::SizeLen { collection: c, .. } => match v1_rt::map_get(&legend, c.clone()) { - Some(short) => Rc::new(SizeExpr::SizeVar { - name: short.clone(), - }), - None => size.clone(), + SizeExpr::SizeLen { collection: c, .. } => match v1_rt::map_get(&legend, c) { + Some(short) => Rc::new(SizeExpr::SizeVar { name: short }), + None => size, }, - SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n.clone()) { - Some(short) => Rc::new(SizeExpr::SizeVar { - name: short.clone(), - }), - None => size.clone(), + SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n) { + Some(short) => Rc::new(SizeExpr::SizeVar { name: short }), + None => size, }, SizeExpr::SizeAdd { left: l, right: r, .. } => Rc::new(SizeExpr::SizeAdd { - left: substitute_size(l.clone(), legend.clone()), - right: substitute_size(r.clone(), legend.clone()), + left: substitute_size(l, legend.clone()), + right: substitute_size(r, legend.clone()), }), SizeExpr::SizeMax { left: l, right: r, .. } => Rc::new(SizeExpr::SizeMax { - left: substitute_size(l.clone(), legend.clone()), - right: substitute_size(r.clone(), legend.clone()), + left: substitute_size(l, legend.clone()), + right: substitute_size(r, legend.clone()), }), - SizeExpr::SizeConst { value: _, .. } => size.clone(), + SizeExpr::SizeConst { value: _, .. } => size, } }) } @@ -8331,24 +8276,24 @@ pub fn substitute_size(size: Rc, legend: Rc>) pub fn substitute_cost(expr: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr.clone(), + CostExpr::CostConst { value: _, .. } => expr, CostExpr::CostAdd { left: l, right: r, .. } => Rc::new(CostExpr::CostAdd { - left: substitute_cost(l.clone(), legend.clone()), - right: substitute_cost(r.clone(), legend.clone()), + left: substitute_cost(l, legend.clone()), + right: substitute_cost(r, legend.clone()), }), CostExpr::CostMul { left: l, right: r, .. } => Rc::new(CostExpr::CostMul { - left: substitute_cost(l.clone(), legend.clone()), - right: substitute_cost(r.clone(), legend.clone()), + left: substitute_cost(l, legend.clone()), + right: substitute_cost(r, legend.clone()), }), CostExpr::CostMax { left: l, right: r, .. } => Rc::new(CostExpr::CostMax { - left: substitute_cost(l.clone(), legend.clone()), - right: substitute_cost(r.clone(), legend.clone()), + left: substitute_cost(l, legend.clone()), + right: substitute_cost(r, legend.clone()), }), CostExpr::CostSum { binder: b, @@ -8356,20 +8301,20 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) body: bd, .. } => Rc::new(CostExpr::CostSum { - binder: b.clone(), - upper: substitute_size(u.clone(), legend.clone()), - body: substitute_cost(bd.clone(), legend.clone()), + binder: b, + upper: substitute_size(u, legend.clone()), + body: substitute_cost(bd, legend.clone()), }), CostExpr::CostLog { base: b, argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b.clone(), - argument: substitute_size(a.clone(), legend.clone()), + base: b, + argument: substitute_size(a, legend.clone()), }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -8379,7 +8324,7 @@ pub fn classify_complexity(expr: Rc) -> String { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); let legend = build_legend(size_names); - let substituted = substitute_cost(normalized.clone(), legend.substitution.clone()); + let substituted = substitute_cost(normalized, legend.substitution.clone()); v1_rt::concat(format_cost_class(substituted), legend.suffix.clone()) } } @@ -8390,27 +8335,27 @@ pub fn collect_size_vars_from_size(size: Rc) -> Rc> { if (c.clone() == "__expr".to_string()) { Rc::new(vec![]) } else { - Rc::new(vec![c.clone()]) + Rc::new(vec![c]) } } SizeExpr::SizeVar { name: n, .. } => { if (n.clone() == "__k".to_string()) { Rc::new(vec![]) } else { - Rc::new(vec![n.clone()]) + Rc::new(vec![n]) } } SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( - collect_size_vars_from_size(l.clone()), - collect_size_vars_from_size(r.clone()), + collect_size_vars_from_size(l), + collect_size_vars_from_size(r), ), SizeExpr::SizeMax { left: l, right: r, .. } => v1_rt::concat( - collect_size_vars_from_size(l.clone()), - collect_size_vars_from_size(r.clone()), + collect_size_vars_from_size(l), + collect_size_vars_from_size(r), ), _ => Rc::new(vec![]), }) @@ -8420,20 +8365,17 @@ pub fn collect_size_vars(expr: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*expr).clone() { CostExpr::CostSum { upper: u, body: bd, .. - } => v1_rt::concat( - collect_size_vars_from_size(u.clone()), - collect_size_vars(bd.clone()), - ), + } => v1_rt::concat(collect_size_vars_from_size(u), collect_size_vars(bd)), CostExpr::CostAdd { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), + } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), CostExpr::CostMul { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), + } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), CostExpr::CostMax { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), - CostExpr::CostLog { argument: a, .. } => collect_size_vars_from_size(a.clone()), + } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), + CostExpr::CostLog { argument: a, .. } => collect_size_vars_from_size(a), _ => Rc::new(vec![]), }) } @@ -8553,7 +8495,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - lr.table.clone(), + (*lr.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8561,30 +8503,30 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - lr.summary.clone().work.clone(), + (*lr.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().work.clone(), + (*rr.summary.clone().work).clone(), ), ), span: cost_seq( - lr.summary.clone().span.clone(), + (*lr.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().span.clone(), + (*rr.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: rr.table.clone(), + table: (*rr.table).clone(), }) } ExprData::ExprCall { .. } => { let fname = expr_call_func_at(texpr.clone(), si.clone()); let callee_result = match v1_rt::map_get(&func_index, fname.clone()) { Some(entry) => get_or_compute_summary( - fname.clone(), + fname, func_index.clone(), scc_index.clone(), table, @@ -8610,14 +8552,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: callee_result.table.clone(), + table: (*callee_result.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8625,34 +8567,34 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - args_result.summary.clone().work.clone(), - callee_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), + (*callee_result.summary.clone().work).clone(), ), span: cost_seq( - args_result.summary.clone().span.clone(), - callee_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), + (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } ExprData::ExprMethodCall { @@ -8670,7 +8612,7 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(recv.clone(), si.clone()); + let size = receiver_size_var(recv, si.clone()); let binder = size_binder_name(size.clone()); let method_cost_result = if (ms.clone() == None) { None @@ -8682,13 +8624,13 @@ pub fn cost_of_expr( .. } => { let pc = node_is_collection(resolved_type(texpr.clone()), si.clone()); - match cs.clone() { + match cs { Some(shape) => Some(cost_of_method_by_shape( - shape.clone(), + shape, pc, recv_r.clone(), mc_args.clone(), - size.clone(), + size, binder, func_index.clone(), scc_index.clone(), @@ -8699,17 +8641,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), })), } } @@ -8717,9 +8659,9 @@ pub fn cost_of_expr( } }; match method_cost_result { - Some(result) => result.clone(), + Some(result) => result, _ => { - let args_result = mc_args.clone().iter().cloned().fold( + let args_result = mc_args.iter().cloned().fold( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), @@ -8727,14 +8669,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8742,40 +8684,40 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), ), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } } @@ -8801,7 +8743,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: s_r.table.clone(), + table: (*s_r.table).clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8810,7 +8752,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - acc.result.clone().table.clone(), + (*(*acc.result).clone().table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8819,21 +8761,21 @@ pub fn cost_of_expr( result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*(*acc.result).clone().summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*(*acc.result).clone().summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: ar.table.clone(), + table: (*ar.table).clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![ar.summary.clone().work.clone()]), + Rc::new(vec![(*ar.summary.clone().work).clone()]), ), }) }, @@ -8841,30 +8783,36 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - s_r.summary.clone().work.clone(), + (*s_r.summary.clone().work).clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - s_r.summary.clone().span.clone(), - Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), + (*s_r.summary.clone().span).clone(), + Rc::new(vec![ + (*(*arms_accum.result).clone().summary.clone().span).clone() + ]), ), - output_size: arms_accum - .result + output_size: (*arms_accum.result) .clone() .summary .clone() .output_size .clone(), - certainty: arms_accum.result.clone().summary.clone().certainty.clone(), + certainty: (*arms_accum.result) + .clone() + .summary + .clone() + .certainty + .clone(), }), - table: arms_accum.result.clone().table.clone(), + table: (*(*arms_accum.result).clone().table).clone(), }) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); let t = if_then_branch(texpr.clone()); let c_r = cost_of_expr( - c.clone(), + c, func_index.clone(), scc_index.clone(), table, @@ -8876,7 +8824,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8884,17 +8832,17 @@ pub fn cost_of_expr( let e_result = match if_else_branch(texpr.clone()) { Some(eb) => { let er = cost_of_expr( - eb.clone(), + eb, func_index.clone(), scc_index.clone(), - t_r.table.clone(), + (*t_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: er.table.clone(), + table: (*er.table).clone(), }) } None => Rc::new(SummaryResult { @@ -8904,29 +8852,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: t_r.table.clone(), + table: (*t_r.table).clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - c_r.summary.clone().work.clone(), + (*c_r.summary.clone().work).clone(), Rc::new(vec![ - t_r.summary.clone().work.clone(), - e_result.summary.clone().work.clone(), + (*t_r.summary.clone().work).clone(), + (*e_result.summary.clone().work).clone(), ]), ), span: cost_conditional( - c_r.summary.clone().span.clone(), + (*c_r.summary.clone().span).clone(), Rc::new(vec![ - t_r.summary.clone().span.clone(), - e_result.summary.clone().span.clone(), + (*t_r.summary.clone().span).clone(), + (*e_result.summary.clone().span).clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: e_result.table.clone(), + table: (*e_result.table).clone(), }) } ExprData::ExprLet => { @@ -8943,10 +8891,10 @@ pub fn cost_of_expr( match let_body(texpr.clone()) { Some(b) => { let b_r = cost_of_expr( - b.clone(), + b, func_index.clone(), scc_index.clone(), - v_r.table.clone(), + (*v_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8954,20 +8902,20 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - v_r.summary.clone().work.clone(), - b_r.summary.clone().work.clone(), + (*v_r.summary.clone().work).clone(), + (*b_r.summary.clone().work).clone(), ), span: cost_seq( - v_r.summary.clone().span.clone(), - b_r.summary.clone().span.clone(), + (*v_r.summary.clone().span).clone(), + (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: b_r.table.clone(), + table: (*b_r.table).clone(), }) } - None => v_r.clone(), + None => v_r, } } ExprData::ExprBlock => texpr.children.clone().iter().cloned().fold( @@ -8985,7 +8933,7 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8993,17 +8941,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - sr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*sr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - sr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: sr.table.clone(), + table: (*sr.table).clone(), }) }, ), @@ -9023,22 +8971,22 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(c.clone(), si.clone()); + let size = receiver_size_var(c, si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = cost_loop(binder, size, (*bd_r.summary.clone().work).clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*c_r.summary.clone().span).clone(), loop_work), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: bd_r.table.clone(), + table: (*bd_r.table).clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9056,7 +9004,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9064,17 +9012,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9093,7 +9041,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9101,17 +9049,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9147,7 +9095,7 @@ pub fn get_or_compute_summary( ) -> Rc { match lookup_summary(table.clone(), func_name.clone()) { Some(cached) => Rc::new(SummaryResult { - summary: cached.clone(), + summary: cached, table: table.clone(), }), None => match v1_rt::map_get(&func_index, func_name.clone()) { @@ -9169,7 +9117,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - entry.body.clone(), + (*entry.body).clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9182,19 +9130,19 @@ pub fn get_or_compute_summary( None => Rc::new(vec![]), }; let is_scc = ((scc_members.clone().len() as i64) > 1); - let bounded = match target.clone() { + let bounded = match target { Some(t) => { if is_scc { Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), scc_members.clone(), ), span: bounded_scc_cost( - t.clone(), - result.summary.clone().span.clone(), - scc_members.clone(), + t, + (*result.summary.clone().span).clone(), + scc_members, ), output_size: result.summary.clone().output_size.clone(), certainty: Certainty::Conservative, @@ -9203,12 +9151,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), func_name.clone(), ), span: bounded_recursive_cost( - t.clone(), - result.summary.clone().span.clone(), + t, + (*result.summary.clone().span).clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9219,15 +9167,18 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost(bounded.work.clone()), - span: simplify_cost(bounded.span.clone()), + work: simplify_cost((*bounded.work).clone()), + span: simplify_cost((*bounded.span).clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = - cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); + let final_table = cache_summary( + (*result.table).clone(), + func_name.clone(), + simplified.clone(), + ); Rc::new(SummaryResult { - summary: simplified.clone(), + summary: simplified, table: final_table, }) } @@ -9292,8 +9243,8 @@ pub fn collect_call_evidence( } => { let callee = expr_call_func_at(body.clone(), si.clone()); let own = if (v1_rt::map_get(&target_set, callee) != None) { - match de.clone() { - Some(evidence) => Rc::new(vec![evidence.clone()]), + match de { + Some(evidence) => Rc::new(vec![evidence]), None => Rc::new(vec![]), } } else { @@ -9451,18 +9402,17 @@ pub fn max_path_descending( } => { let callee = expr_call_func_at(body.clone(), si.clone()); let own = if (callee == fn_name.clone()) { - match de.clone() { - Some(evidence) => { - match evidence.clone().get(param_index.clone() as usize).cloned() { - Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::StrictSubValue { .. } => 1, - SubValueRelation::IteratedSubValue { field: _, .. } => 1, - SubValueRelation::ArithmeticDescent { .. } => 1, - _ => 0, - }, - None => 0, - } - } + match de { + Some(evidence) => match evidence.get(param_index.clone() as usize).cloned() + { + Some(rel) => match (*rel).clone() { + SubValueRelation::StrictSubValue { .. } => 1, + SubValueRelation::IteratedSubValue { field: _, .. } => 1, + SubValueRelation::ArithmeticDescent { .. } => 1, + _ => 0, + }, + None => 0, + }, None => 0, } } else { @@ -9498,18 +9448,15 @@ pub fn max_path_descending( ); let else_branch = if_else_branch(body.clone()); let else_count = match else_branch { - Some(eb) => max_path_descending( - eb.clone(), - fn_name.clone(), - param_index.clone(), - si.clone(), - ), + Some(eb) => { + max_path_descending(eb, fn_name.clone(), param_index.clone(), si.clone()) + } None => 0, }; let branch_max = if (then_count.clone() > else_count.clone()) { - then_count.clone() + then_count } else { - else_count.clone() + else_count }; (cond_count + branch_max) } @@ -9591,7 +9538,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9620,7 +9567,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - entry.body.clone(), + (*entry.body).clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9720,12 +9667,13 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) + if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) + > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9798,12 +9746,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity(sr.summary.clone().work.clone()); + let class_str = classify_complexity((*sr.summary.clone().work).clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9811,12 +9759,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { + let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason(sr.summary.clone().work.clone()), + reason: extract_unknown_reason((*sr.summary.clone().work).clone()), span: entry.span.clone(), })]), ) @@ -9845,7 +9793,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - sr.table.clone(), + (*sr.table).clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), @@ -9880,7 +9828,7 @@ pub fn build_complexity_report( None => acc.clone(), }, ); - let structural_bounds = analyze_structural_bounds(func_entries.clone(), si.clone()); + let structural_bounds = analyze_structural_bounds(func_entries.clone(), si); Rc::new(ComplexityReport { function_classes: result.classes.clone(), violations: result.violations.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index e7c5382b4eb..5f3d818a392 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -294,8 +294,8 @@ pub fn emit_simple_expr( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => emit_literal(v.clone(), target.clone()), - ExprData::ExprError { message, .. } => emit_error_expr(message.clone(), target.clone()), + ExprData::ExprLiteral { value: v, .. } => emit_literal(v, target.clone()), + ExprData::ExprError { message, .. } => emit_error_expr(message, target.clone()), ExprData::ExprVar { binding_kind: _, .. } => emit_ident( @@ -307,13 +307,13 @@ pub fn emit_simple_expr( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { - Some(svc_name) => service_var_name(svc_name.clone()), + Some(svc_name) => service_var_name(svc_name), None => v1_rt::concat( v1_rt::concat( - emit_simple_expr(b.clone(), target.clone(), source_indices.clone()), + emit_simple_expr(b, target.clone(), source_indices.clone()), ".".to_string(), ), - emit_ident(f.clone(), target.clone()), + emit_ident(f, target.clone()), ), } } else { @@ -321,7 +321,7 @@ pub fn emit_simple_expr( let base_is_fn = match (*b.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. - } => match bk.clone().as_deref().cloned() { + } => match bk.as_deref().cloned() { Some(VarBindingKind::MatchBoundBinding) => false, Some(VarBindingKind::VariantValueBinding { parent_enum: _, @@ -331,8 +331,7 @@ pub fn emit_simple_expr( }, _ => false, }; - let base_str = - emit_simple_expr(b.clone(), target.clone(), source_indices.clone()); + let base_str = emit_simple_expr(b, target.clone(), source_indices.clone()); let base_call = if base_is_fn.clone() { v1_rt::concat(base_str, "()".to_string()) } else { @@ -340,9 +339,9 @@ pub fn emit_simple_expr( }; let field_str = v1_rt::concat( v1_rt::concat(base_call, ".".to_string()), - emit_ident(f.clone(), target.clone()), + emit_ident(f, target.clone()), ); - let needs_clone = (base_is_fn.clone() + let needs_clone = (base_is_fn && match target.clone() { RenderTarget::Rust => true, _ => false, @@ -506,7 +505,7 @@ pub fn emit_simple_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.clone().iter().cloned() { + for p in fmt_parts.iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -524,7 +523,7 @@ pub fn emit_simple_string_interp( apply_type_template1(interp.plain_template.clone(), fmt_str) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); apply_type_template2(interp.format_template.clone(), fmt_str, args_str) } } @@ -594,13 +593,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: typed_module.type_env.clone(), - func_env: typed_module.func_env.clone(), + type_env: (*typed_module.type_env).clone(), + func_env: (*typed_module.func_env).clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -620,7 +619,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc, name: String, ) -> Option> { - lookup_func_sig(scope.func_env.clone(), name) + lookup_func_sig((*scope.func_env).clone(), name) } pub fn typed_named_arg_matches( @@ -672,7 +671,10 @@ pub fn order_typed_call_args( let has_unnamed = { let mut __found = false; for arg in args.clone().iter().cloned() { - if (arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()) == None) + if (arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) == None) { __found = true; break; @@ -691,7 +693,7 @@ pub fn order_typed_call_args( |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -707,7 +709,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), true, ) @@ -721,7 +723,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -739,7 +741,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -767,12 +769,12 @@ pub fn has_nested_records_node( loop { let is_product = (n.connective.clone() == Connective::Conj); let is_coproduct = (n.connective.clone() == Connective::Disj); - if is_product { + if is_product.clone() { break true; } else { - if is_coproduct { + if is_coproduct.clone() { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { + if is_optional.clone() { { let __tco_0 = with_required_cardinality(n); n = __tco_0; @@ -783,7 +785,7 @@ pub fn has_nested_records_node( } } else { let is_map = node_is_keyed_collection(n.clone(), source_indices.clone()); - if is_map { + if is_map.clone() { match n.children.clone().get(1 as usize).cloned() { Some(val_child) => { let __tco_0 = child_type_node(val_child.clone()); @@ -821,19 +823,19 @@ pub fn emit_data_value_json( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*value.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { LiteralValue::LitStr { value: s, .. } => v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), + v1_rt::concat("\"".to_string(), escape_json_string(s)), "\"".to_string(), ), LiteralValue::LitSymbol { value: s, .. } => v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), + v1_rt::concat("\"".to_string(), escape_json_string(s)), "\"".to_string(), ), - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), - LiteralValue::LitFloat { value: f, .. } => f.clone(), + LiteralValue::LitInt { value: i, .. } => (i).to_string(), + LiteralValue::LitFloat { value: f, .. } => f, LiteralValue::LitBool { value: b, .. } => { - if b.clone() { + if b { "true".to_string() } else { "false".to_string() @@ -887,7 +889,7 @@ pub fn emit_data_value_json( } => v1_rt::concat( v1_rt::concat( "\"".to_string(), - escape_json_string(expr_var_name_at(value.clone(), source_indices.clone())), + escape_json_string(expr_var_name_at(value.clone(), source_indices)), ), "\"".to_string(), ), @@ -896,7 +898,7 @@ pub fn emit_data_value_json( .. } => v1_rt::concat( "-".to_string(), - emit_data_value_json(unaryop_operand(value.clone()), source_indices.clone()), + emit_data_value_json(unaryop_operand(value.clone()), source_indices), ), _ => "\"compile_error!(unsupported mock expression)\"".to_string(), } @@ -912,13 +914,13 @@ pub fn to_camel(name: String) -> String { .collect::>(), ); if ((parts.clone().len() as i64) == 0) { - name.clone() + name } else { { let first_part = match parts.clone().first().cloned() { Some(p) => Rc::new({ let mut __result = Vec::new(); - for c in Rc::new(p.clone().chars().map(|c| c as i64).collect::>()) + for c in Rc::new(p.chars().map(|c| c as i64).collect::>()) .iter() .cloned() { @@ -935,7 +937,6 @@ pub fn to_camel(name: String) -> String { let mut __result = Vec::new(); for pair in Rc::new( parts - .clone() .iter() .cloned() .enumerate() @@ -991,7 +992,7 @@ pub fn test_file_path(module_name: String, target: RenderTarget) -> String { { let conventions = test_conventions_for_target(target.clone()); let file_dir = match conventions.file_dir.clone() { - Some(dir) => dir.clone(), + Some(dir) => dir, None => "".to_string(), }; let filename = module_to_filename(module_name); @@ -1020,7 +1021,7 @@ pub fn reserved_prefix(target: RenderTarget) -> String { .clone()) .clone() { - ReservedWordStrategy::PrefixEscape { prefix: prefix, .. } => prefix.clone(), + ReservedWordStrategy::PrefixEscape { prefix: prefix, .. } => prefix, _ => "".to_string(), } } @@ -1033,7 +1034,7 @@ pub fn reserved_suffix(target: RenderTarget) -> String { .clone()) .clone() { - ReservedWordStrategy::SuffixEscape { suffix: suffix, .. } => suffix.clone(), + ReservedWordStrategy::SuffixEscape { suffix: suffix, .. } => suffix, _ => "".to_string(), } } @@ -1090,7 +1091,7 @@ pub fn apply_escape_pairs(s: String, pairs: Rc>>) -> String { pairs .iter() .cloned() - .fold(s.clone(), |acc: String, pair: Rc| { + .fold(s, |acc: String, pair: Rc| { Rc::new( acc.split(&pair.from.clone()) .map(|s| s.to_string()) @@ -1119,14 +1120,14 @@ pub fn is_null_coalesce(op: BinOp) -> bool { pub fn rust_literal_for_pattern(value: Rc) -> String { match (*value).clone() { - LiteralValue::LitStr { value: s, .. } => emit_string_literal(s.clone(), "".to_string()), + LiteralValue::LitStr { value: s, .. } => emit_string_literal(s, "".to_string()), LiteralValue::LitSymbol { value: s, .. } => { - emit_string_literal(s.clone(), ".to_string()".to_string()) + emit_string_literal(s, ".to_string()".to_string()) } - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), - LiteralValue::LitFloat { value: f, .. } => f.clone(), + LiteralValue::LitInt { value: i, .. } => (i).to_string(), + LiteralValue::LitFloat { value: f, .. } => f, LiteralValue::LitBool { value: b, .. } => { - if b.clone() { + if b { emit_keyword("true".to_string(), RenderTarget::Rust) } else { emit_keyword("false".to_string(), RenderTarget::Rust) @@ -1144,18 +1145,18 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> String { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "String".to_string()) { - Some(sfx) => sfx.clone(), + Some(sfx) => sfx, None => emit_error_expr( "missing TypeCheckpoint for String literal suffix".to_string(), target.clone(), ), }; - emit_string_literal(s.clone(), suffix) + emit_string_literal(s, suffix) } - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), - LiteralValue::LitFloat { value: f, .. } => f.clone(), + LiteralValue::LitInt { value: i, .. } => (i).to_string(), + LiteralValue::LitFloat { value: f, .. } => f, LiteralValue::LitBool { value: b, .. } => { - if b.clone() { + if b { emit_keyword("true".to_string(), target.clone()) } else { emit_keyword("false".to_string(), target.clone()) @@ -1164,16 +1165,16 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> String { LiteralValue::LitNull => emit_keyword("null".to_string(), target.clone()), LiteralValue::LitSymbol { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "Symbol".to_string()) { - Some(sfx) => sfx.clone(), + Some(sfx) => sfx, None => match literal_suffix(target.clone(), "String".to_string()) { - Some(sfx) => sfx.clone(), + Some(sfx) => sfx, None => emit_error_expr( "missing TypeCheckpoint for Symbol literal suffix".to_string(), target.clone(), ), }, }; - emit_string_literal(s.clone(), suffix) + emit_string_literal(s, suffix) } } } @@ -1184,7 +1185,7 @@ pub fn emit_bin_op_symbol( algebra_field: Option, ) -> String { match binop_symbol(target.clone(), op, algebra_field) { - Some(sym) => sym.clone(), + Some(sym) => sym, None => emit_error_expr( "missing OperatorSpec for BinOp in target language".to_string(), target.clone(), @@ -1197,7 +1198,7 @@ pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> Stri apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { - Some(template) => apply_type_template1(template.clone(), inner), + Some(template) => apply_type_template1(template, inner), None => { let spec = language_spec(target.clone()); v1_rt::concat( @@ -1214,7 +1215,7 @@ pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> Stri pub fn emit_map_type(key_type: String, val_type: String, target: RenderTarget) -> String { match coerce_container_template(target, "map".to_string()) { - Some(template) => apply_type_template2(template.clone(), key_type, val_type), + Some(template) => apply_type_template2(template, key_type, val_type), None => v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1238,15 +1239,15 @@ pub fn emit_node_type( pub fn named_type_vars_in_inferred(inferred: Option>) -> Rc> { match inferred.as_deref().cloned() { - Some(InferredNode::TypeVariable { id: var_id, .. }) => Rc::new(vec![var_id.clone()]), - Some(InferredNode::Resolved { node: rt, .. }) => named_type_vars_in_node(rt.clone()), + Some(InferredNode::TypeVariable { id: var_id, .. }) => Rc::new(vec![var_id]), + Some(InferredNode::Resolved { node: rt, .. }) => named_type_vars_in_node(rt), _ => Rc::new(vec![]), } } pub fn named_type_vars_in_node(n: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_vars = named_type_vars_in_inferred(n.inferred.clone()); + let self_vars = named_type_vars_in_inferred((*n.inferred).clone()); let child_vars = Rc::new({ let mut __result = Vec::new(); for ch in n.children.clone().iter().cloned() { @@ -1297,7 +1298,7 @@ pub fn render_named_type_base( } else { Rc::new(vec![]) }; - let param_names = v1_rt::concat(explicit_params.clone(), inferred_params); + let param_names = v1_rt::concat(explicit_params, inferred_params); if ((param_names.clone().len() as i64) == 0) { base } else { @@ -1306,7 +1307,7 @@ pub fn render_named_type_base( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, spec.type_arg_open.clone()), - param_names.clone().join(&", ".to_string()), + param_names.join(&", ".to_string()), ), spec.type_arg_close.clone(), ) @@ -1323,13 +1324,13 @@ pub fn render_node_type( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); - let n_is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let n_is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; @@ -1337,16 +1338,16 @@ pub fn render_node_type( && ((n.children.clone().len() as i64) == 0)) { { - let is_named_type_var = match n.inferred.clone().as_deref().cloned() { + let is_named_type_var = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) + ((tn.clone() != "".to_string()) && (tn.clone() == var_id)) } _ => false, }; - if (n_is_type_var.clone() && is_named_type_var) { + if (n_is_type_var && is_named_type_var) { return coerce_primitive_type(target.clone(), tn.clone()); } - let label = if n_is_error.clone() { + let label = if n_is_error { "CompilerError".to_string() } else { "TypeVariable".to_string() @@ -1376,9 +1377,9 @@ pub fn render_node_type( __result }); let param_str = param_strs.clone().join(&repr.param_separator.clone()); - let ret_str = match n.inferred.clone().as_deref().cloned() { + let ret_str = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_node_type( - rt.clone(), + rt, target.clone(), shared_types.clone(), source_indices.clone(), @@ -1388,9 +1389,9 @@ pub fn render_node_type( let spec = language_spec(target.clone()); let result = match spec.callable_type_template.clone() { Some(t) => v1_rt::replace( - v1_rt::replace(t.clone(), "{params}".to_string(), param_str), + v1_rt::replace(t, "{params}".to_string(), param_str), "{return}".to_string(), - ret_str.clone(), + ret_str, ), None => { if (ret_str.clone() == "".to_string()) { @@ -1413,7 +1414,7 @@ pub fn render_node_type( param_str, ), "{return}".to_string(), - ret_str.clone(), + ret_str, ) } } @@ -1460,7 +1461,7 @@ pub fn render_node_type( } if is_conj { { - if (n.type_annotation.clone() != None) { + if ((*n.type_annotation).clone() != None) { { let refined_str = match n.children.clone().first().cloned() { Some(base) => render_node_type( @@ -1481,7 +1482,7 @@ pub fn render_node_type( { let first_child = match n.children.clone().first().cloned() { Some(c) => { - if (c.inferred.clone() != None) { + if ((*c.inferred).clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1501,7 +1502,7 @@ pub fn render_node_type( }; let second_child = match n.children.clone().get(1 as usize).cloned() { Some(c) => { - if (c.inferred.clone() != None) { + if ((*c.inferred).clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1538,7 +1539,7 @@ pub fn render_node_type( let base = if (snake.clone() == "map".to_string()) { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { - emit_container(snake.clone(), "_".to_string(), target.clone()) + emit_container(snake, "_".to_string(), target.clone()) }; let conj_container_str = if shared.clone() { wrap_shared_type(target.clone(), base.clone()) @@ -1589,7 +1590,7 @@ pub fn render_node_type( None => false, }; let param_count = (n.params.clone().len() as i64); - let base = if bare_is_map.clone() { + let base = if bare_is_map { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { if bare_is_collection { @@ -1599,7 +1600,7 @@ pub fn render_node_type( { let inner = match n.params.clone().first().cloned() { Some(p) => render_node_type( - param_node_type_expr(p.clone()), + param_node_type_expr(p), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1609,7 +1610,7 @@ pub fn render_node_type( emit_container(to_snake(tn.clone()), inner, target.clone()) } } else { - if (param_count.clone() > 0) { + if (param_count > 0) { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1630,7 +1631,7 @@ pub fn render_node_type( coerce_primitive_type(target.clone(), tn.clone()), spec.type_arg_open.clone(), ), - param_strs.clone().join(&", ".to_string()), + param_strs.join(&", ".to_string()), ), spec.type_arg_close.clone(), ) @@ -1658,7 +1659,7 @@ pub fn render_node_type( { let k = match n.children.clone().first().cloned() { Some(kn) => render_node_type( - child_type_node(kn.clone()), + child_type_node(kn), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1667,7 +1668,7 @@ pub fn render_node_type( }; let v = match n.children.clone().get(1 as usize).cloned() { Some(vn) => render_node_type( - child_type_node(vn.clone()), + child_type_node(vn), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1687,7 +1688,7 @@ pub fn render_node_type( { let child_str = match n.children.clone().first().cloned() { Some(child) => render_node_type( - child_type_node(child.clone()), + child_type_node(child), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1736,20 +1737,20 @@ pub fn render_node_type( return multi_tuple_str; } } - let type_base = coerce_primitive_type(target.clone(), tn.clone()); - let args_joined = child_strs.clone().join(&", ".to_string()); + let type_base = coerce_primitive_type(target.clone(), tn); + let args_joined = child_strs.join(&", ".to_string()); let spec = language_spec(target.clone()); let base = v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_base.clone(), spec.type_arg_open.clone()), + v1_rt::concat(type_base, spec.type_arg_open.clone()), args_joined, ), spec.type_arg_close.clone(), ); - if shared.clone() { - wrap_shared_type(target.clone(), base.clone()) + if shared { + wrap_shared_type(target.clone(), base) } else { - base.clone() + base } }) } @@ -1762,9 +1763,7 @@ pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> Strin if ((parts.clone().len() as i64) == 2) { match parts.clone().first().cloned() { Some(p0) => match parts.clone().get(1 as usize).cloned() { - Some(p1) => { - apply_type_template2(ts.pair_template.clone(), p0.clone(), p1.clone()) - } + Some(p1) => apply_type_template2(ts.pair_template.clone(), p0, p1), None => apply_type_template1( ts.multi_template.clone(), parts.clone().join(&ts.separator.clone()), @@ -1810,16 +1809,16 @@ pub fn has_service_items(typed: Rc) -> bool { } pub fn service_fallback_transport(item: Rc) -> Rc { - if (item.transport.clone() == None) { + if ((*item.transport).clone() == None) { local_transport_node(item.span.clone()) } else { - item.transport.clone().clone().unwrap() + (*item.transport).clone().clone().unwrap() } } pub fn effective_operation_transport(op_node: Rc, fallback: Rc) -> Rc { - match op_node.transport.clone() { - Some(op_transport) => op_transport.clone(), + match (*op_node.transport).clone() { + Some(op_transport) => op_transport, None => fallback, } } @@ -1834,9 +1833,9 @@ pub fn service_has_rest( let from_ops = { let mut __found = false; for op in op_children.iter().cloned() { - if if (op.transport.clone() != None) { + if if ((*op.transport).clone() != None) { is_rest_transport( - op.transport.clone().clone().unwrap(), + (*op.transport).clone().clone().unwrap(), source_indices.clone(), ) } else { @@ -1858,8 +1857,8 @@ pub fn service_has_shell(fallback_transport: Rc, op_children: Rc) -> } else { result.clone() }; - result.clone() + result } } @@ -2042,7 +2041,7 @@ pub fn service_field_ctors(fs: ServiceFieldSet, t: Rc) -> } else { result.clone() }; - result.clone() + result } } @@ -2094,15 +2093,12 @@ pub fn emit_unified_operation_method( let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); let all_params = if (sp.clone() == "".to_string()) { - params_str.clone() + params_str } else { if (params_str.clone() == "".to_string()) { - sp.clone() + sp } else { - v1_rt::concat( - v1_rt::concat(sp.clone(), ", ".to_string()), - params_str.clone(), - ) + v1_rt::concat(v1_rt::concat(sp, ", ".to_string()), params_str) } }; let receiver_str = service_receiver_str(spec.clone(), service_name); @@ -2116,12 +2112,7 @@ pub fn emit_unified_operation_method( _ => emit_ident(op_text.clone(), target.clone()), }; let eff_transport = effective_operation_transport(op_node.clone(), fallback_transport); - let body = render_transport_body( - eff_transport, - op_text.clone(), - si.clone(), - (method_depth.clone() + 1), - ); + let body = render_transport_body(eff_transport, op_text, si, (method_depth.clone() + 1)); let sig = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -2151,7 +2142,7 @@ pub fn emit_unified_operation_method( v1_rt::concat( v1_rt::concat( v1_rt::concat(sig, spec.block_syntax.clone().block_open.clone()), - make_indent((method_depth.clone() + 1)), + make_indent((method_depth + 1)), ), body, ) @@ -2165,7 +2156,7 @@ pub fn emit_unified_operation_method( ), "\n".to_string(), ), - make_indent(method_depth.clone()), + make_indent(method_depth), ), spec.block_syntax.clone().block_close.clone(), ) @@ -2196,7 +2187,7 @@ pub fn emit_unified_service_def( ); let methods = Rc::new({ let mut __result = Vec::new(); - for op_node in op_children.clone().iter().cloned() { + for op_node in op_children.iter().cloned() { __result.push(emit_unified_operation_method( safe_name.clone(), transport.clone(), @@ -2222,7 +2213,7 @@ pub fn emit_unified_service_def( spec.items.clone().struct_keyword.clone(), " ".to_string(), ), - safe_name.clone(), + safe_name, ), ":\n".to_string(), ), @@ -2541,12 +2532,15 @@ pub fn emit_shared_tco_expr( mut emit_default_return: impl Fn(Rc) -> String + Clone, ) -> String { loop { - let si = frame.scope.clone().type_env.clone().source_indices.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + let si = (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(); + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { + if (expr_call_func_at((*frame.expr).clone(), si.clone()) == fn_name.clone()) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: frame.expr.clone().children.clone(), + args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2555,10 +2549,10 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value(frame.expr.clone()); + let inner = return_value((*frame.expr).clone()); { let __tco_0 = Rc::new(TcoFrame { - expr: inner, + expr: inner.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), }); @@ -2621,7 +2615,11 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); + let val_str = recurse_expr( + (*frame.expr).clone(), + frame.scope.clone(), + frame.depth.clone(), + ); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2635,15 +2633,18 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = recurse_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2670,11 +2671,11 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2685,7 +2686,7 @@ pub fn shared_tco_if( match e { Some(eb) => { let else_str = - recurse_tco(eb.clone(), frame.scope.clone(), (frame.depth.clone() + 1)); + recurse_tco(eb, frame.scope.clone(), (frame.depth.clone() + 1)); if syntax.significant_whitespace.clone() { v1_rt::concat( v1_rt::concat( @@ -2795,26 +2796,29 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( frame.scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { Some(b) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), - recurse_tco(b.clone(), next_scope, frame.depth.clone()), + recurse_tco(b, next_scope, frame.depth.clone()), ), None => let_line, } @@ -2832,21 +2836,19 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { { let init_state = emit_init_stmts(ss.clone(), frame.scope.clone(), frame.depth.clone()); - let last_str = match ss.clone().last().cloned() { - Some(last_expr) => recurse_tco( - last_expr.clone(), - init_state.scope.clone(), - frame.depth.clone(), - ), + let last_str = match ss.last().cloned() { + Some(last_expr) => { + recurse_tco(last_expr, init_state.scope.clone(), frame.depth.clone()) + } None => spec.tco.clone().break_return.clone(), }; if ((init_state.text.clone().len() as i64) == 0) { @@ -2936,7 +2938,10 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - input.scope.clone().type_env.clone().source_indices.clone(), + (*input.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) }, |frame| { @@ -3111,7 +3116,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3211,10 +3216,10 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), @@ -3229,12 +3234,12 @@ pub fn emit_unified_tco_match( scrut_str, arm_list, frame.depth.clone(), - fn_name.clone(), - params.clone(), + fn_name, + params, registry.clone(), frame.scope.clone(), render_pattern.clone(), - render_init_stmts.clone(), + render_init_stmts, ), _ => { let arm_strs = Rc::new({ @@ -3359,8 +3364,8 @@ pub fn emit_unified_tco_match_arm( emit_match_arm_line( arm.clone(), target.clone(), - case_depth.clone(), - body_depth.clone(), + case_depth, + body_depth, body_str, guard_str, render_pattern.clone(), @@ -3442,7 +3447,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -3467,15 +3472,15 @@ pub fn emit_unified_typed_func_body( v1_rt::concat(prefix, emit_let_binding(n.clone(), val_str, target.clone())); let next_scope = extend_scope( scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { Some(bd) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_unified_typed_func_body( - bd.clone(), + bd, target.clone(), registry.clone(), next_scope, @@ -3503,13 +3508,13 @@ pub fn emit_unified_typed_func_body( registry.clone(), |pat| emit_unified_pattern(pat.clone(), target.clone(), si.clone()), ); - let last_stmt = ss.clone().last().cloned(); + let last_stmt = ss.last().cloned(); let last_str = match last_stmt { Some(s) => v1_rt::concat( v1_rt::concat( v1_rt::concat(prefix, "return ".to_string()), emit_unified_typed_expr( - s.clone(), + s, target.clone(), registry.clone(), init_state.scope.clone(), @@ -3612,9 +3617,7 @@ pub fn is_tco_candidate( source_indices.clone(), ); let else_cand = match if_else_branch(texpr.clone()) { - Some(e) => { - is_tco_candidate(e.clone(), func_name.clone(), source_indices.clone()) - } + Some(e) => is_tco_candidate(e, func_name.clone(), source_indices.clone()), None => false, }; (then_cand || else_cand) @@ -3634,7 +3637,7 @@ pub fn is_tco_candidate( __found } ExprData::ExprLet => match let_body(texpr.clone()) { - Some(b) => is_tco_candidate(b.clone(), func_name.clone(), source_indices.clone()), + Some(b) => is_tco_candidate(b, func_name.clone(), source_indices.clone()), None => false, }, ExprData::ExprBlock => { @@ -3794,7 +3797,7 @@ pub fn escape_emoji_codepoints_inner( }; { let __tco_0 = (pos + 1); - let __tco_1 = next_acc; + let __tco_1 = next_acc.clone(); pos = __tco_0; acc = __tco_1; continue; @@ -3848,24 +3851,22 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { }; if is_reserved { match (*spec.reserved_words.clone().strategy.clone()).clone() { - ReservedWordStrategy::PrefixEscape { prefix: p, .. } => { - v1_rt::concat(p.clone(), sanitized.clone()) - } + ReservedWordStrategy::PrefixEscape { prefix: p, .. } => v1_rt::concat(p, sanitized), ReservedWordStrategy::SuffixEscape { suffix: s, .. } => emit_suffix_escape_ident( - sanitized.clone(), - s.clone(), + sanitized, + s, spec.reserved_words.clone().keywords.clone(), ), - ReservedWordStrategy::NoEscape => sanitized.clone(), + ReservedWordStrategy::NoEscape => sanitized, } } else { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => emit_suffix_escape_ident( - sanitized.clone(), - s.clone(), + sanitized, + s, spec.reserved_words.clone().keywords.clone(), ), - _ => sanitized.clone(), + _ => sanitized, } } } @@ -3878,7 +3879,7 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { VisibilitySpec::CaseVisibility { export_case: ec, .. } => { - let result = apply_naming_case(name, ec.clone()); + let result = apply_naming_case(name, ec); let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { @@ -3893,26 +3894,26 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => { emit_suffix_escape_ident( - result.clone(), - s.clone(), + result, + s, spec.reserved_words.clone().keywords.clone(), ) } ReservedWordStrategy::PrefixEscape { prefix: p, .. } => { - v1_rt::concat(p.clone(), result.clone()) + v1_rt::concat(p, result) } - ReservedWordStrategy::NoEscape => result.clone(), + ReservedWordStrategy::NoEscape => result, } } else { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => { emit_suffix_escape_ident( - result.clone(), - s.clone(), + result, + s, spec.reserved_words.clone().keywords.clone(), ) } - _ => result.clone(), + _ => result, } } } @@ -3928,8 +3929,8 @@ pub fn apply_bridge_method_overrides( match v1_rt::lookup(&overrides, name.clone()) { v1_rt::Witness::Holds { value: replacement, .. - } => replacement.clone(), - v1_rt::Witness::Violates { diagnostic: _, .. } => name.clone(), + } => replacement, + v1_rt::Witness::Violates { diagnostic: _, .. } => name, } } @@ -4043,9 +4044,9 @@ pub fn emit_expr_var_shared( emit_keyword("null".to_string(), target) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n.clone(), target) + emit_keyword(n, target) } else { - emit_ident(n.clone(), target) + emit_ident(n, target) } } } @@ -4059,7 +4060,7 @@ pub fn emit_expr_field_access_shared( ) -> String { if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { - Some(svc_name) => service_var_name(svc_name.clone()), + Some(svc_name) => service_var_name(svc_name), None => emit_field(expr.clone()), } } else { @@ -4099,9 +4100,9 @@ pub fn emit_typed_cast_shared( { let expr_str = recurse(expr.clone()); let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); - let src_ty = match expr.inferred.clone().as_deref().cloned() { + let src_ty = match (*expr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { - emit_node_type(n.clone(), target.clone(), source_indices.clone()) + emit_node_type(n, target.clone(), source_indices.clone()) } _ => "".to_string(), }; @@ -4109,15 +4110,15 @@ pub fn emit_typed_cast_shared( expr_str } else { if can_cast(target.clone(), src_ty.clone(), ty_str.clone()) { - render_cast(expr_str, ty_str.clone(), target.clone()) + render_cast(expr_str, ty_str, target.clone()) } else { emit_error_expr( v1_rt::concat( v1_rt::concat( - v1_rt::concat("unsupported cast from ".to_string(), src_ty.clone()), + v1_rt::concat("unsupported cast from ".to_string(), src_ty), " to ".to_string(), ), - ty_str.clone(), + ty_str, ), target.clone(), ) @@ -4217,7 +4218,7 @@ pub fn emit_typed_index_shared( let is_map = node_is_keyed_collection(base_node.clone(), source_indices.clone()); if is_string_like( target.clone(), - authored_name_at(source_indices.clone(), base_node.clone()), + authored_name_at(source_indices.clone(), base_node), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -4254,7 +4255,7 @@ pub fn emit_typed_slice_shared( let base_node = normalize_access_type_node(resolved_type(base.clone())); if is_string_like(target.clone(), authored_name_at(source_indices, base_node)) { match spec.indexing.clone().string_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), None => emit_error_expr( "unsupported string slice for target".to_string(), target.clone(), @@ -4262,7 +4263,7 @@ pub fn emit_typed_slice_shared( } } else { match spec.indexing.clone().list_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), None => emit_error_expr("unsupported slice for target".to_string(), target.clone()), } } @@ -4292,11 +4293,9 @@ pub fn emit_shared_expr( emit_bin_op: impl Fn(Rc) -> String + Clone, ) -> String { match (*texpr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => { - wrap_result(emit_literal(v.clone(), target.clone())) - } + ExprData::ExprLiteral { value: v, .. } => wrap_result(emit_literal(v, target.clone())), ExprData::ExprError { message, .. } => { - wrap_result(emit_error_expr(message.clone(), target.clone())) + wrap_result(emit_error_expr(message, target.clone())) } ExprData::ExprVar { binding_kind: _, .. @@ -4314,14 +4313,14 @@ pub fn emit_shared_expr( ExprData::ExprBinOp { .. } => emit_bin_op(texpr.clone()), ExprData::ExprUnaryOp { op: op, .. } => { let operand = unaryop_operand(texpr.clone()); - wrap_result(emit_unary_op(op.clone(), recurse(operand), target.clone())) + wrap_result(emit_unary_op(op, recurse(operand), target.clone())) } ExprData::ExprLambda => { let body = lambda_body(texpr.clone()); let raw_body = recurse(body.clone()); let final_body = match target.clone() { RenderTarget::Go => { - if go_lambda_emits_statement_body(body.clone()) { + if go_lambda_emits_statement_body(body) { raw_body } else { v1_rt::concat("return ".to_string(), raw_body) @@ -4383,7 +4382,7 @@ pub fn emit_default_bin_op( wrap_result(emit_null_coalesce(left_str, right_str, target)) } else { { - let op_str = emit_bin_op_symbol(op.clone(), target, algebra.clone()); + let op_str = emit_bin_op_symbol(op, target, algebra); wrap_result(v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4422,16 +4421,16 @@ pub fn emit_block_stmts_shared( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } Some(stmt) => { let raw = emit_expr(stmt.clone(), scope.clone(), depth.clone()); let line = if prepend_indent.clone() { - v1_rt::concat(make_indent(depth.clone()), raw) + v1_rt::concat(make_indent(depth.clone()), raw.clone()) } else { - raw + raw.clone() }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { @@ -4442,8 +4441,8 @@ pub fn emit_block_stmts_shared( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -4466,7 +4465,7 @@ pub fn emit_init_block_stmts_shared( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -4482,22 +4481,22 @@ pub fn emit_init_block_stmts_shared( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } Some(_) => { let raw = emit_expr(stmt.clone(), scope.clone(), depth.clone()); let line = if prepend_indent.clone() { - v1_rt::concat(make_indent(depth.clone()), raw) + v1_rt::concat(make_indent(depth.clone()), raw.clone()) } else { - raw + raw.clone() }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -4531,7 +4530,7 @@ pub fn emit_typed_let_shared( ); v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), - recurse(bd.clone(), next_scope), + recurse(bd, next_scope), ) } None => let_line, @@ -4557,7 +4556,7 @@ pub fn emit_typed_if_shared( Some(eb) => match es.if_value_form.clone() { IfValueForm::IfExpression => { let then_str = recurse(then_branch.clone(), (depth.clone() + 1)); - let else_str = recurse(eb.clone(), (depth.clone() + 1)); + let else_str = recurse(eb, (depth.clone() + 1)); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4598,7 +4597,7 @@ pub fn emit_typed_if_shared( } IfValueForm::ConditionalTernary => { let then_str = recurse(then_branch.clone(), depth.clone()); - let else_str = recurse(eb.clone(), depth.clone()); + let else_str = recurse(eb, depth.clone()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4618,7 +4617,7 @@ pub fn emit_typed_if_shared( } IfValueForm::IfStatement => { let result_type = match if_result_type { - Some(rt) => emit_node_type(rt.clone(), target.clone(), source_indices), + Some(rt) => emit_node_type(rt, target.clone(), source_indices), None => emit_node_type( resolved_type(then_branch.clone()), target.clone(), @@ -4626,7 +4625,7 @@ pub fn emit_typed_if_shared( ), }; let then_str = recurse(then_branch.clone(), depth.clone()); - let else_str = recurse(eb.clone(), depth.clone()); + let else_str = recurse(eb, depth.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func() ".to_string(), result_type), " { if ".to_string()), cond_str), bs.block_open.clone()), make_indent((depth.clone() + 1))), "return ".to_string()), then_str), "\n".to_string()), make_indent(depth.clone())), bs.else_clause.clone()), make_indent((depth.clone() + 1))), "return ".to_string()), else_str), "\n".to_string()), make_indent(depth.clone())), bs.block_close.clone()), " }()".to_string()) } }, @@ -4801,7 +4800,7 @@ pub fn emit_algebra_method_template( "arg".to_string(), first_arg_str, ); - Some(apply_named_template(tmpl.clone(), bindings)) + Some(apply_named_template(tmpl, bindings)) } None => None, }, @@ -4815,7 +4814,7 @@ pub fn emit_typed_first_arg_shared( recurse: impl Fn(Rc) -> String + Clone, ) -> String { match args.first().cloned() { - Some(a) => recurse(arg_value(a.clone())), + Some(a) => recurse(arg_value(a)), None => emit_error_expr("missing method argument".to_string(), target), } } @@ -4881,7 +4880,7 @@ pub fn emit_typed_string_interp_unified( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.clone().iter().cloned() { + for p in fmt_parts.iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -4899,7 +4898,7 @@ pub fn emit_typed_string_interp_unified( apply_type_template1(interp.plain_template.clone(), fmt_str) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); apply_type_template2(interp.format_template.clone(), fmt_str, args_str) } } @@ -4987,7 +4986,7 @@ pub fn emit_typed_record_lit_unified( } Some(tn) => { if ((fields.clone().len() as i64) == 0) { - v1_rt::concat(tn.clone(), rls.named_empty.clone()) + v1_rt::concat(tn, rls.named_empty.clone()) } else { { let field_strs = Rc::new({ @@ -5011,10 +5010,7 @@ pub fn emit_typed_record_lit_unified( }); let fields_str = field_strs.join(&rls.named_field_join.clone()); v1_rt::concat( - v1_rt::concat( - v1_rt::concat(tn.clone(), rls.named_open.clone()), - fields_str, - ), + v1_rt::concat(v1_rt::concat(tn, rls.named_open.clone()), fields_str), rls.named_close.clone(), ) } @@ -5104,7 +5100,7 @@ pub fn emit_typed_call_unified( let call_str = match target.clone() { RenderTarget::Go => { if is_go_v2rt_free_function(func.clone()) { - emit_go_v2rt_free_call(func.clone(), all_args.clone()) + emit_go_v2rt_free_call(func.clone(), all_args) } else { v1_rt::concat( v1_rt::concat( @@ -5129,11 +5125,11 @@ pub fn emit_typed_call_unified( ")".to_string(), ), }; - match callee.clone() { + match callee { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects.clone() { + if has_effects { v1_rt::concat(spec.async_call_prefix.clone(), call_str) } else { call_str @@ -5170,7 +5166,7 @@ pub fn emit_algebra_method_call_unified( first_arg_str, target.clone(), ) { - Some(result) => result.clone(), + Some(result) => result, None => { let function_name = bridge_method_name_unified(method_name.clone(), target.clone()); let arg_strs = Rc::new({ @@ -5180,7 +5176,7 @@ pub fn emit_algebra_method_call_unified( } __result }); - let all_args = v1_rt::concat(Rc::new(vec![recv_str.clone()]), arg_strs); + let all_args = v1_rt::concat(Rc::new(vec![recv_str]), arg_strs); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -5245,14 +5241,14 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = scope.type_env.clone().source_indices.clone(); + let source_indices = (*scope.type_env).clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { service_name: svc_name, .. } => { - let var_name = service_var_name(svc_name.clone()); + let var_name = service_var_name(svc_name); let arg_strs = Rc::new({ let mut __result = Vec::new(); for a in args.clone().iter().cloned() { @@ -5279,7 +5275,7 @@ pub fn emit_typed_method_call_unified( ) } MethodSemantics::AlgebraMethodSemantics { method_def, .. } => { - let mn = authored_name_at(source_indices.clone(), method_def.clone()); + let mn = authored_name_at(source_indices, method_def); let first_arg_str = emit_typed_first_arg_shared(args.clone(), target.clone(), recurse.clone()); emit_algebra_method_call_unified( @@ -5301,9 +5297,9 @@ pub fn emit_typed_method_call_unified( } } else { if is_typed_service_call_receiver(receiver.clone(), source_indices.clone()) { - match extract_typed_service_name(receiver.clone(), source_indices.clone()) { + match extract_typed_service_name(receiver.clone(), source_indices) { Some(svc_name) => { - let var_name = service_var_name(svc_name.clone()); + let var_name = service_var_name(svc_name); let arg_strs = Rc::new({ let mut __result = Vec::new(); for a in args.clone().iter().cloned() { @@ -5352,23 +5348,21 @@ pub fn emit_unified_pattern( source_indices: Rc>>, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), target), - MatchPattern::LitPattern { value: v, .. } => emit_literal(v.clone(), target), + MatchPattern::Bind { name: n, .. } => emit_ident(n, target), + MatchPattern::LitPattern { value: v, .. } => emit_literal(v, target), MatchPattern::VariantPattern { name: n, parent_enum: pe, field_bindings: fbs, .. - } => { - emit_unified_variant_pattern(n.clone(), pe.clone(), fbs.clone(), target, source_indices) - } + } => emit_unified_variant_pattern(n, pe, fbs, target, source_indices), MatchPattern::Wildcard => "_".to_string(), } } pub fn go_variant_case_type(name: String, parent_enum: Option) -> String { match parent_enum { - Some(parent) => v1_rt::concat(parent.clone(), name), + Some(parent) => v1_rt::concat(parent, name), None => name, } } @@ -5466,10 +5460,10 @@ pub fn emit_match_arm_line( let pat = arm_pattern(arm); let case_kw = match (*pat.clone()).clone() { MatchPattern::Wildcard => match es.wildcard_case.clone() { - Some(wc) => wc.clone(), - None => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat.clone())), + Some(wc) => wc, + None => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat)), }, - _ => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat.clone())), + _ => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat)), }; v1_rt::concat( v1_rt::concat( @@ -5493,7 +5487,7 @@ pub fn emit_arm_guard( let es = language_spec(target.clone()).expression_semantics.clone(); match arm_guard(arm) { Some(g) => match es.guard_prefix.clone() { - Some(prefix) => v1_rt::concat(prefix.clone(), render_guard_expr(g.clone())), + Some(prefix) => v1_rt::concat(prefix, render_guard_expr(g)), None => emit_error_expr( "target does not support pattern guards".to_string(), target.clone(), @@ -5519,7 +5513,7 @@ pub fn emit_go_match_arm_bindings( } else { Rc::new({ let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { + for fb in fbs.iter().cloned() { __result.push(v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -5630,7 +5624,7 @@ pub fn emit_typed_match_unified( arms, depth.clone(), recurse, - render_pattern.clone(), + render_pattern, source_indices, ), _ => { @@ -5733,7 +5727,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5753,7 +5747,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = scope.type_env.clone().source_indices.clone(); + let fa_si = (*scope.type_env).clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), @@ -6179,7 +6173,7 @@ pub fn emit_typed_tco_reassign_shared( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for pair in pairs.clone().iter().cloned() { + for pair in pairs.iter().cloned() { __result.push(emit_ident( param_node_name_at(pair.1.clone(), source_indices.clone()), target.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index e384a9d4951..d7ed120dbc9 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -157,6 +157,7 @@ pub fn to_string_helper(mut value: i64, mut acc: Rc>) -> Rc>) -> Rc String { let cp = ch.clone(); if ((cp.clone() >= 65) && (cp.clone() <= 90)) { { - let lower_cp = (cp.clone() + 32); + let lower_cp = (cp + 32); v1_rt::from_code_point(lower_cp) } } else { @@ -265,7 +266,7 @@ pub fn to_upper_char(ch: i64) -> String { let cp = ch.clone(); if ((cp.clone() >= 97) && (cp.clone() <= 122)) { { - let upper_cp = (cp.clone() - 32); + let upper_cp = (cp - 32); v1_rt::from_code_point(upper_cp) } } else { @@ -302,7 +303,6 @@ pub fn capitalize_first(s: String) -> String { let mut __result = Vec::new(); for pair in Rc::new( chars_list - .clone() .iter() .cloned() .enumerate() @@ -493,11 +493,9 @@ pub fn apply_named_template_nested( } __result }); - processed.join(&val.clone()) - } - None => { - v1_rt::concat("TEMPLATE_ERROR_MISSING_BINDING_".to_string(), key.clone()) + processed.join(&val) } + None => v1_rt::concat("TEMPLATE_ERROR_MISSING_BINDING_".to_string(), key), } } } @@ -585,7 +583,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_type_def_item(item: Rc) -> bool { - ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) + ((item.connective.clone() != Connective::NoConnective) && ((*item.transport).clone() == None)) } pub fn is_bare_leaf_item(item: Rc) -> bool { - (((((item.connective.clone() == Connective::NoConnective) && (item.body.clone() == None)) + (((((item.connective.clone() == Connective::NoConnective) && ((*item.body).clone() == None)) && ((item.params.clone().len() as i64) == 0)) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) } @@ -683,26 +684,26 @@ pub fn is_type_decl_item( ) -> bool { ((is_bare_leaf_item(item.clone()) && !is_type_alias_return_node(resolved_type(item.clone()), source_indices)) - || (((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + || (((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0))) } pub fn is_function_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() == None)) + (((*item.body).clone() != None) && ((*item.type_annotation).clone() == None)) } pub fn is_data_def_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() != None)) + (((*item.body).clone() != None) && ((*item.type_annotation).clone() != None)) } pub fn is_service_def_item(item: Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_resource_def_item(item: Rc) -> bool { - (((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) - || ((((item.transport.clone() == None) && ((item.children.clone().len() as i64) == 0)) + ((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) + || (((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) > 0)) - && (item.body.clone() == None))) + && ((*item.body).clone() == None))) } diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 80ca723d392..b6f4b4b93a8 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -129,16 +129,16 @@ pub fn emit_go(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -182,7 +182,7 @@ pub fn emit_go_v2rt_module() -> Rc { pub fn emit_go_mod(module_name: String) -> Rc { { let manifest_path = match scaffold_for_target(RenderTarget::Go).manifest_file.clone() { - Some(path) => path.clone(), + Some(path) => path, None => "go.mod".to_string(), }; let content = v1_rt::concat( @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -426,7 +426,7 @@ pub fn emit_go_operation_test(projection: Rc, depth: i64) -> Str ), "\n".to_string(), ), - indent.clone(), + indent, ), "// TODO: add dry-run support to Go service emission for full invocation tests\n" .to_string(), @@ -462,9 +462,9 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = typed_module.type_env.clone().source_indices.clone(); + let si = (*typed_module.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( @@ -478,15 +478,11 @@ pub fn emit_go_module( ), pkg_name, ); - let imports_str = emit_go_imports( - typed_module.items.clone(), - module_imports(m.clone()), - si.clone(), - ); + let imports_str = emit_go_imports(typed_module.items.clone(), module_imports(m), si); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), imports_str.clone()) + v1_rt::concat("\n\n".to_string(), imports_str) }; let items_str = Rc::new({ let mut __result = Vec::new(); @@ -513,7 +509,7 @@ pub fn emit_go_module( "// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string(), ), - mod_name_str.clone(), + mod_name_str, ), "\n\n".to_string(), ), @@ -533,7 +529,7 @@ pub fn emit_go_module( v1_rt::concat( v1_rt::concat( v1_rt::concat(go_emit_module_root(), "/".to_string()), - mod_dir.clone(), + mod_dir, ), "/".to_string(), ), @@ -559,15 +555,9 @@ pub fn go_package_name(module_name: String) -> String { match parts.last().cloned() { Some(last_part) => Rc::new({ let mut __result = Vec::new(); - for c in Rc::new( - last_part - .clone() - .chars() - .map(|c| c as i64) - .collect::>(), - ) - .iter() - .cloned() + for c in Rc::new(last_part.chars().map(|c| c as i64).collect::>()) + .iter() + .cloned() { __result.push(to_lower_char(c.clone())); } @@ -641,7 +631,7 @@ pub fn emit_go_imports( "".to_string() } else { { - let imports_str = all_imports.clone().join(&"\n".to_string()); + let imports_str = all_imports.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat("import (\n".to_string(), imports_str), "\n)".to_string(), @@ -695,10 +685,10 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), env.clone()) + emit_go_type_def_from_connective(item.clone(), env) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -717,7 +707,7 @@ pub fn emit_go_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -726,7 +716,7 @@ pub fn emit_go_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -735,18 +725,18 @@ pub fn emit_go_typed_item( if is_data_def_item(item.clone()) { emit_go_data_def( item_text, - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), 0, ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, env.clone()) + emit_go_service_def(item.clone(), registry, env) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), env.clone()) + emit_go_resource_def(item.clone(), env) } else { v1_rt::concat( v1_rt::concat( @@ -874,7 +864,7 @@ pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Str v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("\t".to_string(), go_export_ident(child_text.clone())), + v1_rt::concat("\t".to_string(), go_export_ident(child_text)), " ".to_string(), ), ty, @@ -1046,7 +1036,7 @@ pub fn emit_go_variant_struct(parent_name: String, child: Rc, env: Rc, env: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1245,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1275,13 +1265,8 @@ pub fn emit_go_func_def( ) }, ); - let body_str = emit_unified_typed_func_body( - body, - RenderTarget::Go, - registry.clone(), - body_scope.clone(), - 1, - ); + let body_str = + emit_unified_typed_func_body(body, RenderTarget::Go, registry.clone(), body_scope, 1); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1388,7 +1373,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1498,7 +1483,7 @@ pub fn emit_go_service_struct( ), " {\n".to_string(), ), - decls.clone().join(&"\n".to_string()), + decls.join(&"\n".to_string()), ), "\n}".to_string(), ) @@ -1575,7 +1560,7 @@ pub fn emit_go_rest_call( } __result }); - let send_lines = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(prefix.clone(), "resp, err := http.DefaultClient.Do(req)\n".to_string()), "if err != nil {\n\treturn nil, fmt.Errorf(\"sending request: %w\", err)\n}\n".to_string()), "defer resp.Body.Close()\n".to_string()), "body, err := io.ReadAll(resp.Body)\n".to_string()), "if err != nil {\n\treturn nil, fmt.Errorf(\"reading response: %w\", err)\n}\n".to_string()), "var result interface{}\n".to_string()), "if err := json.Unmarshal(body, &result); err != nil {\n".to_string()), "\treturn nil, fmt.Errorf(\"decoding response: %w\", err)\n}\n".to_string()), "return result, nil".to_string()); + let send_lines = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(prefix, "resp, err := http.DefaultClient.Do(req)\n".to_string()), "if err != nil {\n\treturn nil, fmt.Errorf(\"sending request: %w\", err)\n}\n".to_string()), "defer resp.Body.Close()\n".to_string()), "body, err := io.ReadAll(resp.Body)\n".to_string()), "if err != nil {\n\treturn nil, fmt.Errorf(\"reading response: %w\", err)\n}\n".to_string()), "var result interface{}\n".to_string()), "if err := json.Unmarshal(body, &result); err != nil {\n".to_string()), "\treturn nil, fmt.Errorf(\"decoding response: %w\", err)\n}\n".to_string()), "return result, nil".to_string()); let all_lines = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1583,7 +1568,7 @@ pub fn emit_go_rest_call( if (auth_line.clone() == "".to_string()) { Rc::new(vec![]) } else { - Rc::new(vec![auth_line.clone()]) + Rc::new(vec![auth_line]) }, ), header_lines, @@ -1639,7 +1624,7 @@ pub fn emit_go_shell_call( }); let run_lines = v1_rt::concat( v1_rt::concat( - v1_rt::concat(prefix.clone(), "output, err := cmd.Output()\n".to_string()), + v1_rt::concat(prefix, "output, err := cmd.Output()\n".to_string()), "if err != nil {\n\treturn \"\", fmt.Errorf(\"running command: %w\", err)\n}\n" .to_string(), ), @@ -1800,7 +1785,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( @@ -1824,7 +1809,7 @@ pub fn go_export_ident(name: String) -> String { VisibilitySpec::CaseVisibility { export_case: ec, .. } => { - let result = apply_naming_case(name, ec.clone()); + let result = apply_naming_case(name, ec); if { let mut __found = false; for r in go_reserved().iter().cloned() { @@ -1835,9 +1820,9 @@ pub fn go_export_ident(name: String) -> String { } __found } { - v1_rt::concat(result.clone(), go_reserved_escape_suffix()) + v1_rt::concat(result, go_reserved_escape_suffix()) } else { - result.clone() + result } } _ => "__GO_VISIBILITY_SPEC_MISMATCH__".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index ddb3cc3f4a9..c1a79a0e8e7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,16 +117,16 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -165,7 +165,7 @@ pub fn py_derive_attribute() -> String { .derive_attribute .clone() { - Some(attr) => attr.clone(), + Some(attr) => attr, None => "@dataclass".to_string(), } } @@ -175,7 +175,7 @@ pub fn py_default_value() -> String { .default_value .clone() { - Some(value) => value.clone(), + Some(value) => value, None => "None".to_string(), } } @@ -187,8 +187,8 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -216,7 +216,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { .module_init_file .clone() { - Some(path) => path.clone(), + Some(path) => path, None => "__init__.py".to_string(), }; Rc::new(TextFile { @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -334,7 +334,7 @@ pub fn emit_py_operation_test(projection: Rc, depth: i64) -> Str __result }) .join(&"\n".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(language_spec(RenderTarget::Python).items.clone().func_keyword.clone(), " ".to_string()), test_name), "() -> None:\n".to_string()), indent.clone()), python_test_signature_comment(projection.clone())), "\n".to_string()), indent.clone()), mock_setup), "\n".to_string()), indent.clone()), "# TODO: add dry-run support to Python service emission for full invocation tests\n".to_string()), indent.clone()), "assert True # mock data setup verified\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(language_spec(RenderTarget::Python).items.clone().func_keyword.clone(), " ".to_string()), test_name), "() -> None:\n".to_string()), indent.clone()), python_test_signature_comment(projection.clone())), "\n".to_string()), indent.clone()), mock_setup), "\n".to_string()), indent.clone()), "# TODO: add dry-run support to Python service emission for full invocation tests\n".to_string()), indent), "assert True # mock data setup verified\n".to_string()) } } @@ -364,16 +364,16 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); + let imports_str = emit_py_imports(module_imports(m), si); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) + v1_rt::concat("\n".to_string(), imports_str) }; let items_str = Rc::new({ let mut __result = Vec::new(); @@ -399,7 +399,7 @@ pub fn emit_py_module( "# Generated by v1 compiler -- do not edit.\n".to_string(), "# Source module: ".to_string(), ), - mod_name_str.clone(), + mod_name_str, ), "\n\n".to_string(), ), @@ -537,7 +537,7 @@ pub fn emit_py_prelude(typed_module: Rc) -> String { }; let has_services = { let mut __found = false; - for item in items.clone().iter().cloned() { + for item in items.iter().cloned() { if is_service_item(item.clone()) { __found = true; break; @@ -556,7 +556,7 @@ pub fn emit_py_prelude(typed_module: Rc) -> String { } else { "".to_string() }; - let typing_import = if (has_structs.clone() || has_enums.clone()) { + let typing_import = if (has_structs || has_enums) { "from typing import Optional, Union\n".to_string() } else { "".to_string() @@ -582,10 +582,10 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), env.clone()) + emit_py_type_def_from_connective(item.clone(), env) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -607,7 +607,7 @@ pub fn emit_py_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -616,7 +616,7 @@ pub fn emit_py_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) @@ -625,17 +625,17 @@ pub fn emit_py_typed_item( if is_data_def_item(item.clone()) { emit_py_data_def( item_text, - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry, scope.clone(), ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, env.clone()) + emit_py_service_def(item.clone(), registry, env) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), env.clone()) + emit_py_resource_def(item.clone(), env) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -919,7 +919,7 @@ pub fn emit_py_fn_def( ), ":\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ) @@ -960,7 +960,7 @@ pub fn emit_py_fn_def( ), ":\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), "return ".to_string(), ), @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1014,7 +1014,7 @@ pub fn emit_py_func_def( body, RenderTarget::Python, registry.clone(), - body_scope.clone(), + body_scope, (depth.clone() + 1), ); let items = language_spec(RenderTarget::Python).items.clone(); @@ -1045,7 +1045,7 @@ pub fn emit_py_func_def( ), ":\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ) @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1182,7 +1182,7 @@ pub fn emit_py_service_init( language_spec(RenderTarget::Python).service_fields.clone(), ); let assigns = service_field_ctors( - fs.clone(), + fs, language_spec(RenderTarget::Python).service_fields.clone(), ); if ((params.clone().len() as i64) == 0) { @@ -1190,7 +1190,7 @@ pub fn emit_py_service_init( } else { { let params_str = - v1_rt::concat("self, ".to_string(), params.clone().join(&", ".to_string())); + v1_rt::concat("self, ".to_string(), params.join(&", ".to_string())); let assigns_str = Rc::new({ let mut __result = Vec::new(); for a in assigns.iter().cloned() { @@ -1293,7 +1293,7 @@ pub fn emit_py_headers_dict( let all_entries = if (auth_entry.clone() == "".to_string()) { header_entries.join(&", ".to_string()) } else { - v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) + v1_rt::concat(auth_entry, header_entries.join(&", ".to_string())) }; v1_rt::concat( v1_rt::concat("headers = {".to_string(), all_entries), @@ -1473,7 +1473,7 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String let all_params = if (params_str.clone() == "".to_string()) { "self".to_string() } else { - v1_rt::concat("self, ".to_string(), params_str.clone()) + v1_rt::concat("self, ".to_string(), params_str) }; let ret = emit_node_type( resolved_type(cap_node.clone()), @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 1f1ff4efb8b..970cf6d890b 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -163,8 +163,8 @@ pub fn render_rust_type( if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr.clone()) { return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), _ => match find_property( n.properties.clone(), "__applied_type_args".to_string(), @@ -173,7 +173,7 @@ pub fn render_rust_type( Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { render_rust_applied_type_shared( - applied.clone(), + applied, Rc::new(vec![]), shared_types, corpus_repr.clone(), @@ -252,9 +252,9 @@ pub fn render_rust_type_without_applied_binding( if node_is_set_collection(n.clone(), source_indices.clone()) { match n.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_node = child_type_node(elem_child); + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -267,7 +267,7 @@ pub fn render_rust_type_without_applied_binding( ) { { let elem_name = - authored_name_at(source_indices.clone(), elem_node.clone()); + authored_name_at(source_indices.clone(), elem_node); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("Set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -385,14 +385,14 @@ pub fn map_literal_key_is_string( source_indices: Rc>>, ) -> bool { match map_type_node.children.clone().first().cloned() { - Some(key_child) => is_rust_string_like(key_child.clone(), source_indices.clone()), + Some(key_child) => is_rust_string_like(key_child, source_indices.clone()), None => match find_property( map_type_node.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), ) { Some(applied) => match applied.children.clone().first().cloned() { - Some(akey) => is_rust_string_like(akey.clone(), source_indices.clone()), + Some(akey) => is_rust_string_like(akey, source_indices.clone()), None => false, }, None => false, @@ -488,14 +488,14 @@ pub fn rust_host_text_carrier_elem_name( source_indices: Rc>>, ) -> String { match n.children.clone().first().cloned() { - Some(ch) => authored_name_at(source_indices.clone(), ch.clone()), + Some(ch) => authored_name_at(source_indices.clone(), ch), None => match find_property( n.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), ) { Some(applied) => match applied.children.clone().first().cloned() { - Some(ach) => authored_name_at(source_indices.clone(), ach.clone()), + Some(ach) => authored_name_at(source_indices.clone(), ach), None => "".to_string(), }, None => "".to_string(), @@ -516,8 +516,7 @@ pub fn is_host_text_carrier_type( if (nm.clone() == "String".to_string()) { true } else { - if ((nm.clone() == "FreeMonoid".to_string()) || (nm.clone() == "List".to_string())) - { + if ((nm.clone() == "FreeMonoid".to_string()) || (nm == "List".to_string())) { (rust_host_text_carrier_elem_name(n.clone(), source_indices.clone()) == "Char".to_string()) } else { @@ -584,7 +583,7 @@ pub fn rust_normalize_partial_function_field_type_text(rendered: String) -> Stri pub fn is_parametric_opaque_type_by_name(env: Rc, type_name: String) -> bool { match lookup_type_by_name(env.clone(), type_name) { - Some(item) => is_parametric_opaque_type_decl_item(item.clone(), env.source_indices.clone()), + Some(item) => is_parametric_opaque_type_decl_item(item, env.source_indices.clone()), None => false, } } @@ -603,7 +602,7 @@ pub fn is_parametric_opaque_type_base( source_indices.clone(), module_index, ) { - Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), + Some(item) => is_parametric_opaque_type_decl_item(item, source_indices.clone()), None => false, } } @@ -638,7 +637,7 @@ pub fn type_leaf_name_for_collapse( if (a.clone() == "".to_string()) { n.name.clone() } else { - a.clone() + a } } } @@ -802,8 +801,8 @@ pub fn render_rust_applied_type_arg( ) { "()".to_string() } else { - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), _ => render_rust_decl_type( n.clone(), generic_param_names.clone(), @@ -833,17 +832,17 @@ pub fn render_rust_applied_type( let base_name = authored_name_at(source_indices.clone(), n.clone()); if ((n.children.clone().len() as i64) == 0) { match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { - Some(host) => host.clone(), - None => rust_named_type_base(base_name.clone(), corpus_repr.clone()), + Some(host) => host, + None => rust_named_type_base(base_name, corpus_repr.clone()), } } else { { let base = match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { - Some(host) => host.clone(), + Some(host) => host, None => rust_applied_type_base(base_name.clone(), corpus_repr.clone()), }; - let peel = is_parametric_opaque_type_by_name(env.clone(), base_name.clone()); + let peel = is_parametric_opaque_type_by_name(env.clone(), base_name); let args = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { @@ -948,12 +947,12 @@ pub fn render_rust_decl_type( }; match applied_overlay { Some(applied) => render_rust_applied_type_shared( - applied.clone(), + applied, generic_param_names.clone(), shared_types.clone(), corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), + variant_to_enum, env.clone(), ), None => { @@ -971,7 +970,7 @@ pub fn render_rust_decl_type( __found }) { - to_pascal(name.clone()) + to_pascal(name) } else { if (((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -986,16 +985,14 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) + && (applied_prop == None)) && v1_rt::set_contains(&shared_types, name.clone())) { { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); + let rendered = + rust_render_type_leaf_name(name.clone(), variant_to_enum); render_rust_shared_type_if_needed( - name.clone(), + name, rendered, shared_types.clone(), ) @@ -1009,7 +1006,7 @@ pub fn render_rust_decl_type( { render_rust_shared_type_if_needed( name.clone(), - name.clone(), + name, shared_types.clone(), ) } else { @@ -1059,7 +1056,7 @@ pub fn render_rust_decl_type( __result }); let applied_ty = if (name.clone() == tuple_type_name()) { - render_tuple_parts(arg_list.clone(), RenderTarget::Rust) + render_tuple_parts(arg_list, RenderTarget::Rust) } else { if node_is_keyed_collection( n.clone(), @@ -1071,20 +1068,16 @@ pub fn render_rust_decl_type( .get(1 as usize) .cloned() { - Some(v) => emit_map_type( - k.clone(), - v.clone(), - RenderTarget::Rust, - ), + Some(v) => { + emit_map_type(k, v, RenderTarget::Rust) + } None => v1_rt::concat( v1_rt::concat( v1_rt::concat( base, "<".to_string(), ), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1092,9 +1085,7 @@ pub fn render_rust_decl_type( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1108,7 +1099,7 @@ pub fn render_rust_decl_type( match arg_list.clone().first().cloned() { Some(inner) => emit_container( to_snake(name.clone()), - inner.clone(), + inner, RenderTarget::Rust, ), None => v1_rt::concat( @@ -1117,9 +1108,7 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1128,9 +1117,7 @@ pub fn render_rust_decl_type( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ) @@ -1138,7 +1125,7 @@ pub fn render_rust_decl_type( } }; render_rust_shared_type_if_needed( - name.clone(), + name, applied_ty, shared_types.clone(), ) @@ -1167,11 +1154,11 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { return false; } let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b.clone(), + Some(b) => b, None => { let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name.clone()) { - Some(b) => b.clone(), + match lookup_type_by_name(env.clone(), name) { + Some(b) => b, None => return false, } } @@ -1236,7 +1223,7 @@ pub fn render_rust_fn_sig_type( && !is_container_type(name.clone())) && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) { - render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) + render_rust_shared_type_if_needed(name.clone(), name, shared_types.clone()) } else { if ((generic_param_names.clone().len() as i64) > 0) { render_rust_decl_type( @@ -1285,7 +1272,7 @@ pub fn render_rust_fn_sig_type_applied_binding( { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types, ) } else { @@ -1319,15 +1306,15 @@ pub fn alias_rhs_container_arg( arg: Rc, source_indices: Rc>>, ) -> Rc { - match arg.inferred.clone().as_deref().cloned() { + match (*arg.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if node_is_collection(rt.clone(), source_indices) { - rt.clone() + rt } else { - arg.clone() + arg } } - _ => arg.clone(), + _ => arg, } } @@ -1364,13 +1351,13 @@ pub fn render_rust_alias_rhs_type( __found }) { - to_pascal(name.clone()) + to_pascal(name) } else { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { - Some(host) => host.clone(), + Some(host) => host, None => { if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr.clone())) @@ -1381,14 +1368,12 @@ pub fn render_rust_alias_rhs_type( ) } else { match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), + Some(carrier) => carrier, None => { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); + let rendered = + rust_render_type_leaf_name(name.clone(), variant_to_enum); render_rust_shared_type_if_needed( - name.clone(), + name, rendered, shared_types.clone(), ) @@ -1418,7 +1403,7 @@ pub fn render_rust_alias_rhs_type( name.clone(), corpus_repr.clone(), ) { - Some(host) => host.clone(), + Some(host) => host, None => { if (def_mod.clone() != local_mod) { v1_rt::concat( @@ -1435,7 +1420,7 @@ pub fn render_rust_alias_rhs_type( }; let peel = is_parametric_opaque_type_base( name.clone(), - def_mod.clone(), + def_mod, typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -1487,12 +1472,12 @@ pub fn render_rust_alias_rhs_type( v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), ">".to_string(), ); - if (v1_rt::set_contains(&shared_types, name.clone()) + if (v1_rt::set_contains(&shared_types, name) && !rust_type_is_rc_wrapped(applied_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + wrap_shared_type(RenderTarget::Rust, applied_ty) } else { - applied_ty.clone() + applied_ty } } } else { @@ -1545,7 +1530,7 @@ pub fn is_rust_value_type( { let normed = normalize_access_type_node(n); match is_copy(RenderTarget::Rust, authored_name_at(source_indices, normed)) { - Some(v) => v.clone(), + Some(v) => v, None => false, } } @@ -1563,7 +1548,7 @@ pub fn is_rust_string_like( pub fn rust_source_root() -> String { match scaffold_for_target(RenderTarget::Rust).source_dir.clone() { - Some(dir) => dir.clone(), + Some(dir) => dir, None => "".to_string(), } } @@ -1576,7 +1561,7 @@ pub fn rust_source_ext() -> String { pub fn rust_visibility_prefix() -> String { match (*visibility_for_target(RenderTarget::Rust)).clone() { - VisibilitySpec::KeywordVisibility { prefix: p, .. } => p.clone(), + VisibilitySpec::KeywordVisibility { prefix: p, .. } => p, _ => "__VISIBILITY_SPEC_MISMATCH__".to_string(), } } @@ -1652,10 +1637,9 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( false } else { match children.clone().first().cloned() { - Some(child) => rust_nominal_identity_carrier_shape_eligible( - child_type_node(child.clone()), - source_indices, - ), + Some(child) => { + rust_nominal_identity_carrier_shape_eligible(child_type_node(child), source_indices) + } None => false, } } @@ -1682,8 +1666,7 @@ pub fn rust_nominal_ord_type_ref_eligible( (((((elem_node.children.clone().len() as i64) == 0) && ((elem_node.params.clone().len() as i64) == 0)) && (elem_node.connective.clone() == Connective::NoConnective)) - && ((type_name.clone() == "Symbol".to_string()) - || (type_name.clone() == "DiffId".to_string()))) + && ((type_name.clone() == "Symbol".to_string()) || (type_name == "DiffId".to_string()))) } } @@ -1705,7 +1688,7 @@ pub fn rust_serde_tag_attr() -> String { .tag_attribute .clone() { - Some(attr) => attr.clone(), + Some(attr) => attr, None => emit_error_expr( "missing serde tag_attribute for Rust".to_string(), RenderTarget::Rust, @@ -1793,15 +1776,15 @@ pub fn field_value_by_name( .first() .cloned() { - Some(fi) => Some(field_init_node_value(fi.clone())), + Some(fi) => Some(field_init_node_value(fi)), None => None, } } pub fn literal_string_value(n: Rc) -> Option { match (*n.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s.clone()), + ExprData::ExprLiteral { value: lv, .. } => match (*lv).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s), _ => None, }, _ => None, @@ -1814,7 +1797,7 @@ pub fn record_string_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(value_node) => literal_string_value(value_node.clone()), + Some(value_node) => literal_string_value(value_node), None => None, } } @@ -1832,7 +1815,7 @@ pub fn coproduct_decl_ref_decl_name( ) -> Option { match field_value_by_name(body, "coproduct".to_string(), source_indices.clone()) { Some(decl_ref_node) => record_string_field( - decl_ref_node.clone(), + decl_ref_node, "decl_name".to_string(), source_indices.clone(), ), @@ -1846,7 +1829,7 @@ pub fn optional_string_record_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(n) => literal_string_value(n.clone()), + Some(n) => literal_string_value(n), None => None, } } @@ -1857,7 +1840,7 @@ pub fn required_literal_string_policy_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(n) => literal_string_value(n.clone()), + Some(n) => literal_string_value(n), None => None, } } @@ -1885,7 +1868,7 @@ pub fn rust_string_policy_for_naming( ) { Some(prefix) => rust_serde_policy( "".to_string(), - Some(prefix.clone()), + Some(prefix), None, Some("StripAffixAndSnakeCase".to_string()), ), @@ -1903,7 +1886,7 @@ pub fn rust_string_policy_for_naming( Some(suffix) => rust_serde_policy( "".to_string(), None, - Some(suffix.clone()), + Some(suffix), Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -1915,7 +1898,7 @@ pub fn rust_string_policy_for_naming( { match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy("".to_string(), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + Some(suffix) => rust_serde_policy("".to_string(), Some(prefix), Some(suffix), Some("StripAffixAndSnakeCase".to_string())), None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), }, None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), @@ -1923,7 +1906,7 @@ pub fn rust_string_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name.clone(), + naming_name, )) } } @@ -1985,7 +1968,7 @@ pub fn rust_internal_policy_for_naming( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string(), ), - Some(prefix.clone()), + Some(prefix), None, Some("StripAffixAndSnakeCase".to_string()), ), @@ -2006,7 +1989,7 @@ pub fn rust_internal_policy_for_naming( "\")]".to_string(), ), None, - Some(suffix.clone()), + Some(suffix), Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -2018,7 +2001,7 @@ pub fn rust_internal_policy_for_naming( { match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix), Some(suffix), Some("StripAffixAndSnakeCase".to_string())), None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), }, None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), @@ -2026,7 +2009,7 @@ pub fn rust_internal_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name.clone(), + naming_name, )) } } @@ -2047,11 +2030,9 @@ pub fn rust_internal_policy_for_encoding( source_indices.clone(), ) { Some(tag_field) => match naming_policy_node(encoding.clone(), source_indices.clone()) { - Some(naming) => rust_internal_policy_for_naming( - tag_field.clone(), - naming.clone(), - source_indices.clone(), - ), + Some(naming) => { + rust_internal_policy_for_naming(tag_field, naming, source_indices.clone()) + } None => rust_serde_error_policy( "InternallyTaggedObject requires a naming policy".to_string(), ), @@ -2073,7 +2054,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { if (encoding_name.clone() == "StringVariant".to_string()) { match naming_policy_node(ve.clone(), source_indices.clone()) { - Some(nv) => rust_string_policy_for_naming(nv.clone(), source_indices.clone()), + Some(nv) => rust_string_policy_for_naming(nv, source_indices.clone()), None => rust_serde_error_policy( "StringVariant requires a naming policy".to_string(), ), @@ -2087,7 +2068,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantEncoding: ".to_string(), - encoding_name.clone(), + encoding_name, )) } } @@ -2100,8 +2081,8 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match wire_item.body.clone() { - Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), + match (*wire_item.body).clone() { + Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve, source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), _ => rust_serde_error_policy("wire_contract: VariantEncoding could not be resolved (no initializer body and not a record literal)".to_string()), @@ -2140,13 +2121,13 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( "wire_contract: VariantEncoding alias chain exceeded recursion limit".to_string(), ); } else { - match wire_contract_item { + match wire_contract_item.clone() { None => { break rust_tagged_object_policy(); } Some(wc) => { if is_data_def_item(wc.clone()) { - match wc.body.clone() { + match (*wc.body).clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2197,7 +2178,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( break rust_serde_error_policy(v1_rt::concat("wire_contract: ambiguous VariantEncoding data alias: ".to_string(), alias_name.clone())); } } - None => match init.inferred.clone() { + None => match (*init.inferred).clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2246,7 +2227,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } } } - _ => match init.inferred.clone() { + _ => match (*init.inferred).clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2293,8 +2274,8 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match contract_item.body.clone() { - Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), + match (*contract_item.body).clone() { + Some(body) => field_value_by_name(body, "encoding".to_string(), source_indices), None => None, } } @@ -2311,9 +2292,9 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match contract_item.body.clone() { - Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { - Some(target_name) => (target_name.clone() == coproduct_name), + match (*contract_item.body).clone() { + Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { + Some(target_name) => (target_name == coproduct_name), None => false, }, None => false, @@ -2370,9 +2351,9 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match item.type_annotation.clone() { + match (*item.type_annotation).clone() { Some(type_node) => { - ((authored_name_at(source_indices.clone(), type_node.clone()) + ((authored_name_at(source_indices.clone(), type_node) == "CoproductWireContract".to_string()) && module_imports_std_serialization_coproduct_wire_contract( imports, @@ -2423,7 +2404,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2431,7 +2412,7 @@ pub fn is_coproduct_wire_contract_row( source_indices.clone(), ) != None) && (field_value_by_name( - body.clone(), + body, "encoding".to_string(), source_indices.clone(), ) != None)) @@ -2448,8 +2429,8 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match contract_item.body.clone() { - Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { + match (*contract_item.body).clone() { + Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { Some(target_name) => { if { let mut __found = false; @@ -2466,7 +2447,7 @@ pub fn emit_coproduct_wire_contract_target_validation( emit_rust_compile_error_item(v1_rt::concat( "CoproductWireContract target does not name a local coproduct: " .to_string(), - target_name.clone(), + target_name, )) } } @@ -2562,30 +2543,29 @@ pub fn resolve_local_coproduct_wire_policy( None } else { if ((contracts.clone().len() as i64) == 1) { - match contracts.clone().first().cloned() { - Some(contract) => match coproduct_wire_contract_encoding( - contract.clone(), - source_indices.clone(), - ) { - Some(encoding) => { - if (variant_encoding_is_string_variant( - encoding.clone(), - source_indices.clone(), - ) && !all_unit_variants) - { - Some(rust_serde_error_policy(v1_rt::concat("CoproductWireContract StringVariant requires a nullary-only coproduct: ".to_string(), coproduct_name.clone()))) - } else { - Some(resolve_wire_serde_policy_from_encoding_node( + match contracts.first().cloned() { + Some(contract) => { + match coproduct_wire_contract_encoding(contract, source_indices.clone()) { + Some(encoding) => { + if (variant_encoding_is_string_variant( encoding.clone(), source_indices.clone(), - )) + ) && !all_unit_variants) + { + Some(rust_serde_error_policy(v1_rt::concat("CoproductWireContract StringVariant requires a nullary-only coproduct: ".to_string(), coproduct_name.clone()))) + } else { + Some(resolve_wire_serde_policy_from_encoding_node( + encoding, + source_indices.clone(), + )) + } } + None => Some(rust_serde_error_policy(v1_rt::concat( + "CoproductWireContract missing encoding for ".to_string(), + coproduct_name.clone(), + ))), } - None => Some(rust_serde_error_policy(v1_rt::concat( - "CoproductWireContract missing encoding for ".to_string(), - coproduct_name.clone(), - ))), - }, + } None => None, } } else { @@ -2604,7 +2584,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, tm: Rc| { let module_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2642,7 +2622,7 @@ pub fn insert_scoped_data_item( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&scoped, name.clone()) { - Some(entries) => entries.clone(), + Some(entries) => entries, None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -2660,7 +2640,7 @@ pub fn build_scoped_data_item_index( { let module_name = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.module).clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2686,11 +2666,11 @@ pub fn build_scoped_data_item_index( ) }, ); - module_imports(typed_module.module.clone()) + module_imports((*typed_module.module).clone()) .iter() .cloned() .fold( - local.clone(), + local, |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), @@ -2736,7 +2716,7 @@ pub fn augment_scoped_data_item_index_with_imports( data_items: Rc>>, ) -> Rc>>>> { imports.iter().cloned().fold( - scoped.clone(), + scoped, |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at(source_indices.clone(), imp.clone()); if import_is_all(imp.clone()) { @@ -2777,7 +2757,7 @@ pub fn rust_serde_rename_template_text() -> String { .rename_attribute_template .clone() { - Some(template) => template.clone(), + Some(template) => template, None => emit_error_expr( "missing serde rename_attribute_template for Rust".to_string(), RenderTarget::Rust, @@ -2789,7 +2769,7 @@ pub fn rust_test_file_path(module_name: String) -> String { { let conventions = test_conventions_for_target(RenderTarget::Rust); let file_dir = match conventions.file_dir.clone() { - Some(dir) => dir.clone(), + Some(dir) => dir, None => "".to_string(), }; let filename = module_to_filename(module_name); @@ -2815,7 +2795,7 @@ pub fn rust_async_test_decorator() -> String { .async_decorator .clone() { - Some(decorator) => decorator.clone(), + Some(decorator) => decorator, None => emit_error_expr( "missing async_decorator for Rust test conventions".to_string(), RenderTarget::Rust, @@ -2836,7 +2816,7 @@ pub fn emit_rust_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2859,8 +2839,8 @@ pub fn emit_rust_block_stmts( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2884,7 +2864,7 @@ pub fn emit_rust_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2900,7 +2880,7 @@ pub fn emit_rust_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2918,16 +2898,16 @@ pub fn emit_rust_init_block_stmts( ExprData::ExprLet => true, _ => false, }; - let line = if is_let { - raw_line + let line = if is_let.clone() { + raw_line.clone() } else { - v1_rt::concat(raw_line, ";".to_string()) + v1_rt::concat(raw_line.clone(), ";".to_string()) }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2947,10 +2927,7 @@ pub fn rust_qualify_type_leaf_name( match v1_rt::map_get(&variant_to_enum, name.clone()) { Some(parent) => { if (parent.clone() != "".to_string()) { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) + v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) } else { name.clone() } @@ -2967,7 +2944,7 @@ pub fn rust_render_type_leaf_name( "()".to_string() } else { match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), + Some(carrier) => carrier, None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum.clone()), } } @@ -3120,7 +3097,7 @@ pub fn is_simple_disj(item: Rc) -> bool { pub fn is_dag_value_type_name(name: String) -> bool { match is_copy(RenderTarget::Rust, name) { - Some(v) => v.clone(), + Some(v) => v, None => false, } } @@ -3137,8 +3114,7 @@ pub fn is_type_constant( unit_only: unit_only, .. } => { - (((unit_only.clone() && !is_recursive) && !has_generics) - && !summary.has_fn_fields.clone()) + (((unit_only && !is_recursive) && !has_generics) && !summary.has_fn_fields.clone()) } TypeRepr::StructRepr => { if ((is_recursive || has_generics) || summary.has_fn_fields.clone()) { @@ -3188,7 +3164,7 @@ pub fn maybe_mark_shared_type( TypeRepr::EnumRepr { unit_only: unit_only, .. - } => (unit_only.clone() == false), + } => (unit_only == false), }); if (needs_sharing && !is_type_constant(summary.clone(), recursive_type_set)) { v1_rt::rc_set_insert(acc, summary.name.clone()) @@ -3234,7 +3210,7 @@ pub fn build_shared_types( __result }); collection_keys.iter().cloned().fold( - user_shared.clone(), + user_shared, |acc: Rc>, key: String| { let pascal = to_pascal(key.clone()); v1_rt::rc_set_insert(acc, pascal.clone()) @@ -3266,7 +3242,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>(), }), |acc: Rc, entry: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/05_emit_rust.dag:78228:acc"); { let read_only = if v1_rt::set_contains( &callable_set, @@ -3432,7 +3408,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if ((workflow_default_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: workflow_default_diags.clone(), + diagnostics: workflow_default_diags, }); } let svc_module_map = typed.modules.clone().iter().cloned().fold( @@ -3449,7 +3425,7 @@ pub fn emit_rust(typed: Rc) -> Rc { }); let mod_filename = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3494,7 +3470,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result.push(emit_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -3502,7 +3478,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -3530,7 +3506,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for m in typed.modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - m.module.clone(), + (*m.module).clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -3546,11 +3522,11 @@ pub fn emit_rust(typed: Rc) -> Rc { }; let cargo = emit_cargo_toml(crate_name.clone(), has_services.clone()); let main_file = emit_main_rs( - workflow_funcs.clone(), + workflow_funcs, typed.modules.clone(), has_services.clone(), - crate_name.clone(), - svc_module_map.clone(), + crate_name, + svc_module_map, ); let rt_file = emit_v2_rt_module(); let compiler_tests_file = if has_pipeline.clone() { @@ -3558,7 +3534,7 @@ pub fn emit_rust(typed: Rc) -> Rc { } else { Rc::new(vec![]) }; - let dry_run_file = if has_services.clone() { + let dry_run_file = if has_services { Rc::new(vec![emit_dry_run_module()]) } else { Rc::new(vec![]) @@ -3567,13 +3543,10 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::concat(module_files, Rc::new(vec![rt_file])), dry_run_file, ); - let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline.clone()); + let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline); let files = v1_rt::concat( v1_rt::concat( - v1_rt::concat( - Rc::new(vec![cargo, lib_file, main_file]), - all_mod_files.clone(), - ), + v1_rt::concat(Rc::new(vec![cargo, lib_file, main_file]), all_mod_files), compiler_tests_file, ), test_files, @@ -3694,7 +3667,7 @@ pub fn emit_module( emit_module_full( typed_module.clone(), registry, - emit_info.clone(), + emit_info, shared_types, v1_rt::rc_empty_map::(), build_data_item_index(Rc::new(vec![typed_module.clone()])), @@ -3713,10 +3686,10 @@ pub fn build_module_export_sets( |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), ); let exported = get_exported_names( - tm.module.clone(), + (*tm.module).clone(), (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( @@ -3747,7 +3720,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3757,7 +3730,7 @@ pub fn emit_module_full( ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(Rc::new(m.clone())).iter().cloned() { + for imp in module_imports(m.clone()).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), @@ -3793,12 +3766,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); let imports_str = emit_imports( - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), emit_info.clone(), registry.clone(), local_type_names, @@ -3810,17 +3783,17 @@ pub fn emit_module_full( let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) + v1_rt::concat("\n".to_string(), imports_str) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3869,10 +3842,7 @@ pub fn emit_module_full( let svc_imports_str = if ((extern_svc_imports.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat( - "\n".to_string(), - extern_svc_imports.clone().join(&"\n".to_string()), - ) + v1_rt::concat("\n".to_string(), extern_svc_imports.join(&"\n".to_string())) }; let local_enum_uses = Rc::new({ let mut __result = Vec::new(); @@ -3881,7 +3851,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3896,7 +3866,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ), "::*;".to_string(), )); @@ -3917,12 +3887,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); - let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(m.clone()); + let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3935,7 +3905,7 @@ pub fn emit_module_full( let wire_context_imports = v1_rt::concat( module_import_items, contracts_imports_for_module( - this_module_name.clone(), + this_module_name, typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3951,18 +3921,12 @@ pub fn emit_module_full( if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat( - coproduct_wire_contract_validations.clone(), - "\n\n".to_string(), - ) + v1_rt::concat(coproduct_wire_contract_validations, "\n\n".to_string()) }; let local_uses_str = if ((local_enum_uses.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat( - "\n".to_string(), - local_enum_uses.clone().join(&"\n".to_string()), - ) + v1_rt::concat("\n".to_string(), local_enum_uses.join(&"\n".to_string())) }; let wire_contract_item = Rc::new({ let mut __result = Vec::new(); @@ -3985,7 +3949,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4003,26 +3967,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { - raw_filename.clone() + raw_filename }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4076,7 +4040,7 @@ pub fn is_import_graph_type_name( ) { Some(src) => type_name_is_rust_importable_in_module( name.clone(), - src.clone(), + src, typed_modules.clone(), registry.clone(), export_sets.clone(), @@ -4141,7 +4105,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>, tm: Rc| { let nm = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4154,7 +4118,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4213,7 +4177,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports(tm.module.clone()), + Some(tm) => module_imports((*tm.module).clone()), None => Rc::new(vec![]), } } @@ -4227,10 +4191,10 @@ pub fn module_name_from_filename( match v1_rt::map_get(&module_index.by_filename.clone(), mod_filename) { Some(mods) => Rc::new({ let mut __result = Vec::new(); - for tm in mods.clone().iter().cloned() { + for tm in mods.iter().cloned() { __result.push(authored_name_at( source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), )); } __result @@ -4251,7 +4215,7 @@ pub fn has_physical_type_def_in_module_filename( match v1_rt::map_get(&module_index.by_filename.clone(), mod_filename) { Some(mods) => { let mut __found = false; - for tm in mods.clone().iter().cloned() { + for tm in mods.iter().cloned() { if { let mut __found = false; for item in tm.items.clone().iter().cloned() { @@ -4401,11 +4365,11 @@ pub fn type_name_is_rust_importable_in_module( { None => false, Some(item) => type_item_has_rust_nominal_shell_authority( - item.clone(), + item, name.clone(), module_name.clone(), - module_imports(tm.module.clone()), - module_emit_scope(tm.clone()), + module_imports((*tm.module).clone()), + module_emit_scope(tm), registry, export_sets, typed_modules.clone(), @@ -4434,7 +4398,7 @@ pub fn imported_name_is_non_emittable_type( source_indices.clone(), module_index.clone(), ) { - Some(src) => src.clone(), + Some(src) => src, None => import_module.clone(), }; (type_name_is_export_source_in_module( @@ -4445,7 +4409,7 @@ pub fn imported_name_is_non_emittable_type( module_index.clone(), ) && (type_name_is_rust_importable_in_module( name.clone(), - defining_module.clone(), + defining_module, typed_modules.clone(), registry, export_sets.clone(), @@ -4496,7 +4460,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4607,7 +4571,7 @@ pub fn reexport_source_module_name_with_visited( for imp in Rc::new({ let mut __result = Vec::new(); for imp in - module_imports(tm.module.clone()).iter().cloned() + module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4658,7 +4622,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) + for imp in module_imports((*tm.module).clone()) .iter() .cloned() { @@ -4926,7 +4890,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5054,7 +5018,7 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - mod_name.clone() + mod_name } else { match reexport_source_module_name( name.clone(), @@ -5064,8 +5028,8 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - Some(src) => module_to_filename(src.clone()), - None => mod_name.clone(), + Some(src) => module_to_filename(src), + None => mod_name, } } } @@ -5107,11 +5071,11 @@ pub fn variant_defining_module_filename_for_import( continue; } } else { - break fallback; + break fallback.clone(); } } None => { - break fallback; + break fallback.clone(); } } } @@ -5138,7 +5102,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone() == parent_enum.clone()) { + if (local_parent == parent_enum.clone()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -5183,7 +5147,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5212,14 +5176,14 @@ pub fn explicit_import_source_module_for_name( .first() .cloned() { - Some(src) => Some(src.clone()), + Some(src) => Some(src), None => match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5253,7 +5217,7 @@ pub fn explicit_import_source_module_for_name( .first() .cloned() { - Some(src) => Some(src.clone()), + Some(src) => Some(src), None => None, }, }, @@ -5273,7 +5237,7 @@ pub fn reexport_variant_parent_in_import_module( loop { match reexport_source_module_name( variant_name.clone(), - import_module, + import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), @@ -5354,7 +5318,7 @@ pub fn alias_rhs_rust_qualify_module_filename( source_indices.clone(), module_index.clone(), ) { - spell_mod.clone() + spell_mod } else { match module_name_from_filename( spell_mod.clone(), @@ -5364,16 +5328,16 @@ pub fn alias_rhs_rust_qualify_module_filename( ) { Some(mod_name) => match reexport_source_module_name( name.clone(), - mod_name.clone(), + mod_name, typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone(), ) { - Some(src) => module_to_filename(src.clone()), - None => spell_mod.clone(), + Some(src) => module_to_filename(src), + None => spell_mod, }, - None => spell_mod.clone(), + None => spell_mod, } } } @@ -5469,7 +5433,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .first() .cloned() { - Some(import_module) => module_to_filename(import_module.clone()), + Some(import_module) => module_to_filename(import_module), None => match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ @@ -5513,7 +5477,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .first() .cloned() { - Some(import_module) => module_to_filename(import_module.clone()), + Some(import_module) => module_to_filename(import_module), None => item_defining_module_filename(name.clone(), registry, local_mod), }, } @@ -5546,7 +5510,7 @@ pub fn type_item_by_name_in_module_filename( module_index.clone(), ) { Some(mod_name) => match typed_module_by_name( - mod_name.clone(), + mod_name, typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -5608,7 +5572,7 @@ pub fn type_item_has_rust_nominal_shell_authority( && ((rhs.children.clone().len() as i64) > 0)) { alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -5629,9 +5593,9 @@ pub fn type_item_has_rust_nominal_shell_authority( rhs.clone(), ); (((rhs_name.clone() != item_text.clone()) - && (rhs_name.clone() != "".to_string())) + && (rhs_name != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -5679,7 +5643,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5708,9 +5672,9 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), - registry, + registry.clone(), export_sets.clone(), typed_modules.clone(), source_indices.clone(), @@ -5801,7 +5765,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); (rhs_base_has_rust_type_authority_in_module( - name.clone(), + name, def_mod, module_name.clone(), imports.clone(), @@ -5836,8 +5800,8 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - if ((n.inferred.clone() != None) - && is_type_variable(n.inferred.clone().clone().unwrap())) + if (((*n.inferred).clone() != None) + && is_type_variable((*n.inferred).clone().clone().unwrap())) { true } else { @@ -5847,7 +5811,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - scope.type_env.clone(), + (*scope.type_env).clone(), name.clone(), ) { true @@ -5865,7 +5829,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); rhs_base_has_rust_type_authority_in_module( - name.clone(), + name, def_mod, module_name.clone(), imports.clone(), @@ -5896,7 +5860,7 @@ pub fn is_self_referential_opaque_type_resolved( let item_text = authored_name_at(source_indices.clone(), item.clone()); let rhs = resolved_type(item.clone()); (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), rhs.clone()) == item_text)) + && (authored_name_at(source_indices.clone(), rhs) == item_text)) } } @@ -5912,8 +5876,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -5939,10 +5903,7 @@ pub fn emit_parametric_phantom_opaque_struct( let generic_names = item_generic_param_names(item.clone(), source_indices.clone()); let marker_ty = match generic_names.first().cloned() { Some(g) => v1_rt::concat( - v1_rt::concat( - "std::marker::PhantomData<".to_string(), - to_pascal(g.clone()), - ), + v1_rt::concat("std::marker::PhantomData<".to_string(), to_pascal(g)), ">".to_string(), ), None => "std::marker::PhantomData<()>".to_string(), @@ -5968,8 +5929,8 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs = resolved_type(item.clone()); - if ((rhs.inferred.clone() != None) - && is_compiler_error(rhs.inferred.clone().clone().unwrap())) + if (((*rhs.inferred).clone() != None) + && is_compiler_error((*rhs.inferred).clone().clone().unwrap())) { false } else { @@ -5981,9 +5942,9 @@ pub fn is_emittable_parametric_type_alias_item( ((rhs_name.clone() != item_text) && (((rhs.children.clone().len() as i64) > 0) || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name.clone() != "".to_string())) + && (rhs_name != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -6034,7 +5995,7 @@ pub fn import_variant_parent_for_name( source_indices.clone(), module_index.clone(), ) { - Some(parent) => parent.clone(), + Some(parent) => parent, None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -6045,17 +6006,17 @@ pub fn import_variant_parent_for_name( source_indices.clone(), module_index.clone(), ) { - Some(parent) => parent.clone(), + Some(parent) => parent, None => { match find_variant_parent(type_summaries.clone(), n.clone(), imported_enums) { - Some(parent) => parent.clone(), + Some(parent) => parent, None => match find_variant_parent( type_summaries.clone(), n.clone(), import_module_enums, ) { - Some(parent) => parent.clone(), + Some(parent) => parent, None => "".to_string(), }, } @@ -6298,7 +6259,7 @@ pub fn emit_specific_import_block( __result }); let merged_direct_names = - unique_strings(v1_rt::concat(direct_names.clone(), local_parent_names)); + unique_strings(v1_rt::concat(direct_names, local_parent_names)); let type_direct_names = Rc::new({ let mut __result = Vec::new(); for n in merged_direct_names.clone().iter().cloned() { @@ -6319,7 +6280,7 @@ pub fn emit_specific_import_block( }); let other_direct_names = Rc::new({ let mut __result = Vec::new(); - for n in merged_direct_names.clone().iter().cloned() { + for n in merged_direct_names.iter().cloned() { if (is_import_graph_type_name( n.clone(), import_module.clone(), @@ -6414,7 +6375,7 @@ pub fn emit_specific_import_block( { let names_str = Rc::new({ let mut __result = Vec::new(); - for n in other_direct_names.clone().iter().cloned() { + for n in other_direct_names.iter().cloned() { __result.push(emit_import_name(n.clone(), registry.clone())); } __result @@ -6451,7 +6412,7 @@ pub fn emit_specific_import_block( __result }), if (other_direct_line.clone() != "".to_string()) { - Rc::new(vec![other_direct_line.clone()]) + Rc::new(vec![other_direct_line]) } else { Rc::new(vec![]) }, @@ -6545,7 +6506,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib }); let main_lines = if ((direct_lines.clone().len() as i64) > 0) { v1_rt::concat( - direct_lines.clone(), + direct_lines, Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { @@ -6605,7 +6566,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con }); let imported_enums = Rc::new({ let mut __result = Vec::new(); - for n in top_level.clone().iter().cloned() { + for n in top_level.iter().cloned() { if is_enum_in_summaries(type_summaries.clone(), n.clone()) { __result.push(n); } @@ -6616,7 +6577,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con let mut __result = Vec::new(); for en in Rc::new({ let mut __result = Vec::new(); - for en in imported_enums.clone().iter().cloned() { + for en in imported_enums.iter().cloned() { if (({ let mut __found = false; for p in parent_list.clone().iter().cloned() { @@ -6691,15 +6652,14 @@ pub fn rust_pub_use_module_name(line: String) -> String { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.clone() - .split(&"::".to_string()) + rest.split(&"::".to_string()) .map(|s| s.to_string()) .collect::>(), ) .first() .cloned() { - Some(mod_name) => mod_name.clone(), + Some(mod_name) => mod_name, None => "".to_string(), }, None => "".to_string(), @@ -6721,8 +6681,7 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.clone() - .split(&"::".to_string()) + rest.split(&"::".to_string()) .map(|s| s.to_string()) .collect::>(), ) @@ -6731,7 +6690,6 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { { Some(name_part) => match Rc::new( name_part - .clone() .split(&";".to_string()) .map(|s| s.to_string()) .collect::>(), @@ -6739,7 +6697,7 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { .first() .cloned() { - Some(name) => name.clone(), + Some(name) => name, None => "".to_string(), }, None => "".to_string(), @@ -6765,8 +6723,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.clone() - .split(&"}".to_string()) + rest.split(&"}".to_string()) .map(|s| s.to_string()) .collect::>(), ) @@ -6775,7 +6732,6 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { { Some(names) => Rc::new( names - .clone() .split(&", ".to_string()) .map(|s| s.to_string()) .collect::>(), @@ -7187,10 +7143,10 @@ pub fn emit_prelude(imported_names: Rc>) -> String { let variant_line = if (has_holds.clone() && has_violates.clone()) { "".to_string() } else { - if has_holds.clone() { + if has_holds { "\nuse crate::v1_rt::Witness::Violates;".to_string() } else { - if has_violates.clone() { + if has_violates { "\nuse crate::v1_rt::Witness::Holds;".to_string() } else { "\nuse crate::v1_rt::Witness::{Holds, Violates};".to_string() @@ -7232,15 +7188,15 @@ pub fn emit_typed_item( let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - Rc::new(env.clone()), + env, emit_info.clone(), wire_contract_item, data_items, @@ -7263,7 +7219,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text.clone()) + rust_nominal_identity_carrier_def(item_text) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -7289,11 +7245,11 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), " = ".to_string(), ), - host.clone(), + host, ), ";".to_string(), ), @@ -7308,7 +7264,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), " = ".to_string(), ), @@ -7339,7 +7295,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text.clone()) + rust_nominal_identity_carrier_def(item_text) } else { match rust_seed_host_container_base( item_text.clone(), @@ -7370,19 +7326,19 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), " = ".to_string(), ), - host.clone(), + host, ), "<".to_string(), ), Rc::new({ let mut __result = Vec::new(); - for n in generic_names.clone().iter().cloned() { + for n in generic_names.iter().cloned() { __result.push(to_pascal(n.clone())); } __result @@ -7425,16 +7381,14 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( "std::marker::PhantomData<".to_string(), - rust_phantom_marker_inner( - unused_params.clone(), - ), + rust_phantom_marker_inner(unused_params), ), ">".to_string(), ) } else { render_rust_alias_rhs_type( - alias_rhs.clone(), - generic_names.clone(), + alias_rhs, + generic_names, shared_types, emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -7462,7 +7416,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), @@ -7500,8 +7454,8 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(Rc::new(env.clone()), item.clone()), - item.body.clone().clone().unwrap(), + authored_name(env.clone(), item.clone()), + (*item.body).clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); @@ -7516,14 +7470,14 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco.clone() { + let fn_move_sites = if item_is_tco { v1_rt::rc_empty_map::() } else { match v1_rt::map_get( &emit_info.move_sites_index.clone(), - qualified_name.clone(), + qualified_name, ) { - Some(m) => m.clone(), + Some(m) => m, None => v1_rt::rc_empty_map::(), } }; @@ -7547,7 +7501,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env, item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7557,11 +7511,11 @@ pub fn emit_typed_item( }; if is_effectful { emit_func_def( - item_text.clone(), + item_text, item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7569,10 +7523,10 @@ pub fn emit_typed_item( ) } else { emit_fn_def( - item_text.clone(), + item_text, item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7583,9 +7537,9 @@ pub fn emit_typed_item( } else { if is_data_def_item(item.clone()) { emit_data_def( - item_text.clone(), - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + item_text, + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7599,7 +7553,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env, ) } else { if is_resource_def_item(item.clone()) { @@ -7607,13 +7561,13 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env, ) } else { v1_rt::concat( v1_rt::concat( "compile_error!(\"unhandled item: ".to_string(), - item_text.clone(), + item_text, ), "\");".to_string(), ) @@ -7658,7 +7612,7 @@ pub fn needs_box_wrapping( } } else { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { + if is_optional.clone() { { let __tco_0 = with_required_cardinality(n); n = __tco_0; @@ -7734,8 +7688,8 @@ pub fn emit_type_params_with_clone_bound( pub fn is_function_type_param(param: Rc) -> bool { { let type_expr = param_node_type_expr(param.clone()); - let type_expr_is_var = match type_expr.inferred.clone() { - Some(inf) => is_type_variable(inf.clone()), + let type_expr_is_var = match (*type_expr.inferred).clone() { + Some(inf) => is_type_variable(inf), None => false, }; let same_source_span = (((param.span.clone().file.clone() @@ -7780,7 +7734,7 @@ pub fn function_type_params_have_collision(type_params: Rc>>) -> bo } __result }); - ((names.clone().len() as i64) > (unique_strings(names.clone()).len() as i64)) + ((names.clone().len() as i64) > (unique_strings(names).len() as i64)) } } @@ -7809,7 +7763,7 @@ pub fn emit_type_def_from_connective( __result }); emit_struct_from_children( - item_text.clone(), + item_text, type_params, generic_param_names, item.children.clone(), @@ -7842,7 +7796,7 @@ pub fn emit_type_def_from_connective( rust_visibility_prefix(), "type ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), @@ -7872,9 +7826,9 @@ pub fn emit_type_def_from_connective( imports, env.source_indices.clone(), ) { - Some(local_policy) => local_policy.clone(), + Some(local_policy) => local_policy, None => { - if all_unit_variants.clone() { + if all_unit_variants { match wire_contract_item.clone() { Some(_) => resolve_wire_serde_policy_for_coproduct( wire_contract_item.clone(), @@ -7894,18 +7848,18 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), ); let policy_validation = match serde_policy.error_message.clone() { - Some(message) => emit_rust_compile_error_item(message.clone()), + Some(message) => emit_rust_compile_error_item(message), None => "".to_string(), }; let validations = if (policy_validation.clone() == "".to_string()) { - rename_validations.clone() + rename_validations } else { if (rename_validations.clone() == "".to_string()) { - policy_validation.clone() + policy_validation } else { v1_rt::concat( - v1_rt::concat(policy_validation.clone(), "\n".to_string()), - rename_validations.clone(), + v1_rt::concat(policy_validation, "\n".to_string()), + rename_validations, ) } }; @@ -7918,23 +7872,20 @@ pub fn emit_type_def_from_connective( __result }); let enum_text = emit_enum_from_children( - item_text.clone(), + item_text, type_params, generic_param_names, item.children.clone(), recursive_types, shared_types, env.clone(), - serde_policy.clone(), + serde_policy, emit_info.clone(), ); if (validations.clone() == "".to_string()) { enum_text } else { - v1_rt::concat( - v1_rt::concat(validations.clone(), "\n".to_string()), - enum_text, - ) + v1_rt::concat(v1_rt::concat(validations, "\n".to_string()), enum_text) } } } @@ -8020,13 +7971,10 @@ pub fn rust_phantom_marker_inner(unused: Rc>) -> String { __result }); if ((pascal_unused.clone().len() as i64) == 1) { - pascal_unused.clone().join(&", ".to_string()) + pascal_unused.join(&", ".to_string()) } else { v1_rt::concat( - v1_rt::concat( - "(".to_string(), - pascal_unused.clone().join(&", ".to_string()), - ), + v1_rt::concat("(".to_string(), pascal_unused.join(&", ".to_string())), ")".to_string(), ) } @@ -8128,7 +8076,7 @@ pub fn emit_struct_from_children( ), ": std::marker::PhantomData<".to_string(), ), - rust_phantom_marker_inner(unused_params.clone()), + rust_phantom_marker_inner(unused_params), ), ">,".to_string(), )]), @@ -8195,19 +8143,19 @@ pub fn render_rust_type_with_applied_binding( if (outer_name.clone() != applied_name) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types.clone(), ) } else { if v1_rt::set_contains(&shared_types, outer_name.clone()) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types.clone(), ) } else { render_rust_applied_type_shared( - applied.clone(), + applied, Rc::new(vec![]), shared_types.clone(), corpus_repr.clone(), @@ -8241,7 +8189,7 @@ pub fn render_rust_type_with_applied_binding( } } else { render_rust_applied_type_shared( - applied.clone(), + applied, Rc::new(vec![]), shared_types.clone(), corpus_repr.clone(), @@ -8328,7 +8276,7 @@ pub fn render_rust_field_type_with_applied_binding( ) != None) { render_rust_type_with_applied_binding( - authored_type.clone(), + authored_type, shared_types, corpus_repr, source_indices.clone(), @@ -8338,7 +8286,7 @@ pub fn render_rust_field_type_with_applied_binding( && ((authored_type.children.clone().len() as i64) > 0)) { render_rust_type( - authored_type.clone(), + authored_type, shared_types, corpus_repr, source_indices.clone(), @@ -8400,7 +8348,7 @@ pub fn emit_struct_field_from_child( ) != None) { render_rust_type_with_applied_binding( - authored_child_type.clone(), + authored_child_type, shared_types.clone(), emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -8455,7 +8403,7 @@ pub fn emit_struct_field_from_child( ">".to_string(), ); render_rust_shared_type_if_needed( - rt_child_name.clone(), + rt_child_name, with_params, shared_types.clone(), ) @@ -8501,20 +8449,20 @@ pub fn emit_struct_field_from_child( env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), generic_ty.clone()), + v1_rt::concat("Box<".to_string(), generic_ty), ">".to_string(), ) } else { if (((rt_child.return_cardinality.clone() != Cardinality::CardOptional) && v1_rt::set_contains( &shared_types, - authored_name_at(env.source_indices.clone(), rt_child.clone()), + authored_name_at(env.source_indices.clone(), rt_child), )) && !rust_type_is_rc_wrapped(generic_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, generic_ty.clone()) + wrap_shared_type(RenderTarget::Rust, generic_ty) } else { - generic_ty.clone() + generic_ty } }; let rename_attr = match Rc::new({ @@ -8531,12 +8479,12 @@ pub fn emit_struct_field_from_child( .first() .cloned() { - Some(prop) => match (*field_init_node_value(prop.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { + Some(prop) => match (*field_init_node_value(prop).expr_data.clone()).clone() { + ExprData::ExprLiteral { value: lv, .. } => match (*lv).clone() { LiteralValue::LitStr { value: key, .. } => v1_rt::concat( v1_rt::concat( " ".to_string(), - apply_type_template1(rust_serde_rename_template_text(), key.clone()), + apply_type_template1(rust_serde_rename_template_text(), key), ), "\n".to_string(), ), @@ -8571,7 +8519,7 @@ pub fn emit_rust_field_definition( v1_rt::concat( v1_rt::concat( v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), + snake, ), "\")]\n".to_string(), ) @@ -8589,7 +8537,7 @@ pub fn emit_rust_field_definition( ), visibility, ), - emitted.clone(), + emitted, ), ": ".to_string(), ), @@ -8694,10 +8642,7 @@ pub fn emit_enum_from_children( if (accessor_impl.clone() == "".to_string()) { enum_def } else { - v1_rt::concat( - v1_rt::concat(enum_def, "\n".to_string()), - accessor_impl.clone(), - ) + v1_rt::concat(v1_rt::concat(enum_def, "\n".to_string()), accessor_impl) } } } @@ -8796,7 +8741,7 @@ pub fn emit_enum_shared_accessors( let first_fielded = fielded.clone().first().cloned().clone().unwrap(); let shared = Rc::new({ let mut __result = Vec::new(); - for fname in all_shared.clone().iter().cloned() { + for fname in all_shared.iter().cloned() { if { let types = Rc::new({ let mut __result = Vec::new(); @@ -8855,7 +8800,7 @@ pub fn emit_enum_shared_accessors( } let accessor_fns = Rc::new({ let mut __result = Vec::new(); - for fname in shared.clone().iter().cloned() { + for fname in shared.iter().cloned() { __result.push({ let ty = match Rc::new({ let mut __result = Vec::new(); @@ -9092,22 +9037,20 @@ pub fn wire_variant_tag_for_policy( } else { match policy.rename_style.clone() { Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + if (style == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix.clone()) { + Some(prefix) => match string_without_prefix(authored, prefix) { Some(stripped) => stripped.clone(), None => return None, }, None => authored, }; let without_suffix = match policy.rename_suffix.clone() { - Some(suffix) => { - match string_without_suffix(without_prefix, suffix.clone()) { - Some(stripped) => stripped.clone(), - None => return None, - } - } + Some(suffix) => match string_without_suffix(without_prefix, suffix) { + Some(stripped) => stripped, + None => return None, + }, None => without_prefix, }; Some(to_snake(without_suffix)) @@ -9142,17 +9085,13 @@ pub fn policy_serde_tag_field(policy: Rc) -> Option { let needle = "tag = \"".to_string(); match string_index_of(policy.enum_attr.clone(), needle.clone()) { Some(start) => { - let after = (start.clone() + v1_rt::string_length(&needle)); + let after = (start + v1_rt::string_length(&needle)); match string_index_of_from( policy.enum_attr.clone(), "\"".to_string(), after.clone(), ) { - Some(end) => Some(v1_rt::substring( - &policy.enum_attr.clone(), - after.clone(), - end.clone(), - )), + Some(end) => Some(v1_rt::substring(&policy.enum_attr.clone(), after, end)), None => None, } } @@ -9179,9 +9118,9 @@ pub fn wire_variant_rename_attr_for_policy( match wire_variant_tag_for_policy(authored, policy.clone()) { Some(tag) => match policy.rename_style.clone() { Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + if (style == "StripAffixAndSnakeCase".to_string()) { v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag.clone()), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag), "\")]\n".to_string(), ) } else { @@ -9200,12 +9139,12 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + if (style == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { match string_without_prefix(authored.clone(), prefix.clone()) { - Some(stripped) => stripped.clone(), + Some(stripped) => stripped, None => { return emit_rust_compile_error_item(v1_rt::concat( v1_rt::concat( @@ -9213,7 +9152,7 @@ pub fn variant_rename_validation_for_policy( " does not satisfy declared wire rename prefix: " .to_string(), ), - prefix.clone(), + prefix, )) } } @@ -9229,7 +9168,7 @@ pub fn variant_rename_validation_for_policy( v1_rt::concat("variant ".to_string(), authored.clone()), " does not satisfy declared wire rename suffix: ".to_string(), ), - suffix.clone(), + suffix, )), }, None => "".to_string(), @@ -9282,12 +9221,12 @@ pub fn enum_variant_field_type_node( ) -> Rc { match lookup_type_by_name(env, enum_name) { Some(enum_node) => { - match find_child_named(enum_node.clone(), variant_name, source_indices.clone()) { + match find_child_named(enum_node, variant_name, source_indices.clone()) { Some(variant) => { - match find_child_named(variant.clone(), field_name, source_indices.clone()) { + match find_child_named(variant, field_name, source_indices.clone()) { Some(field) => { - if (field.inferred.clone() != None) { - resolved_type(field.clone()) + if ((*field.inferred).clone() != None) { + resolved_type(field) } else { fallback } @@ -9338,12 +9277,7 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) + render_rust_type(n.clone(), shared_types, corpus_repr, source_indices.clone()) } } @@ -9355,7 +9289,7 @@ pub fn variant_is_synthetic_positional_payload( false } else { match fields.clone().first().cloned() { - Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), + Some(f) => (field_node_name_at(f, source_indices) == "0".to_string()), None => false, } } @@ -9377,10 +9311,7 @@ pub fn emit_variant_from_child( wire_variant_rename_attr_for_policy(child_text.clone(), serde_policy.clone()); if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( - v1_rt::concat( - v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), - ), + v1_rt::concat(v1_rt::concat(rename_attr, " ".to_string()), child_text), ",".to_string(), ) } else { @@ -9395,7 +9326,7 @@ pub fn emit_variant_from_child( if tuple_style { match child.children.clone().first().cloned() { Some(f) => { - let fallback = resolved_type(f.clone()); + let fallback = resolved_type(f); let type_node = if positional_payload.clone() { enum_variant_field_type_node( env.clone(), @@ -9408,7 +9339,7 @@ pub fn emit_variant_from_child( } else { fallback }; - let raw_ty = if positional_payload.clone() { + let raw_ty = if positional_payload { render_variant_payload_type( type_node.clone(), shared_types.clone(), @@ -9439,28 +9370,28 @@ pub fn emit_variant_from_child( raw_ty }; let final_ty = if needs_box_wrapping( - type_node.clone(), - recursive_types.clone(), + type_node, + recursive_types, shared_types.clone(), env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), ty.clone()), + v1_rt::concat("Box<".to_string(), ty), ">".to_string(), ) } else { - ty.clone() + ty }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), "(".to_string(), ), - final_ty.clone(), + final_ty, ), "),".to_string(), ) @@ -9468,7 +9399,7 @@ pub fn emit_variant_from_child( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), ",".to_string(), ), @@ -9519,7 +9450,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), " {\n".to_string(), ), @@ -9576,7 +9507,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), " {\n".to_string(), ), @@ -9608,15 +9539,15 @@ pub fn emit_fn_def( None }; if (host_text_op.clone() != None) { - return match host_text_op.clone() { - Some(op_fn) => op_fn.clone(), + return match host_text_op { + Some(op_fn) => op_fn, None => "".to_string(), }; } match rust_host_string_seam_fn_emit(name.clone()) { Some(seam_fn) => { if corpus_repr_is_faithful(emit_info.corpus_repr.clone()) { - seam_fn.clone() + seam_fn } else { "".to_string() } @@ -9666,13 +9597,9 @@ pub fn emit_fn_def( > 0); let needs_clone_bound = (return_is_bare_generic && !body_is_param_ref); let type_params_str = if needs_clone_bound { - emit_type_params_with_clone_bound( - type_params.clone(), - ret_name.clone(), - si.clone(), - ) + emit_type_params_with_clone_bound(type_params, ret_name, si.clone()) } else { - emit_type_params(type_params.clone(), si.clone()) + emit_type_params(type_params, si.clone()) }; let params_str = emit_params( value_params.clone(), @@ -9682,7 +9609,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9691,7 +9618,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9700,21 +9627,21 @@ pub fn emit_fn_def( let needs_stacker = (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) && (use_tco.clone() == false)); - if use_tco.clone() { + if use_tco { { let tco_params_str = emit_tco_params( value_params.clone(), - generic_param_names.clone(), + generic_param_names, shared_types.clone(), emit_info.corpus_repr.clone(), - si.clone(), + si, emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_str = emit_typed_tco_body( body.clone(), name.clone(), - value_params.clone(), + value_params, registry.clone(), body_scope, (depth.clone() + 1), @@ -9756,7 +9683,7 @@ pub fn emit_fn_def( ), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ), @@ -9772,7 +9699,7 @@ pub fn emit_fn_def( body.clone(), registry.clone(), body_scope, - depth.clone(), + depth, shared_types.clone(), emit_info.clone(), needs_stacker, @@ -9942,7 +9869,7 @@ pub fn emit_func_def( (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_func_inferred( inferred, @@ -9966,7 +9893,7 @@ pub fn emit_func_def( let body_str = emit_func_body( body, registry.clone(), - body_scope.clone(), + body_scope, (depth.clone() + 1), shared_types.clone(), emit_info.clone(), @@ -10003,7 +9930,7 @@ pub fn emit_func_def( ), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ), @@ -10039,15 +9966,15 @@ pub fn emit_func_body( let let_line = emit_let_binding(n.clone(), val_str, RenderTarget::Rust); let next_scope = extend_scope( scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { Some(bd) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_func_body( - bd.clone(), + bd, registry.clone(), next_scope, depth.clone(), @@ -10073,14 +10000,14 @@ pub fn emit_func_body( shared_types.clone(), emit_info.clone(), ); - let last_stmt = ss.clone().last().cloned(); + let last_stmt = ss.last().cloned(); let last_str = match last_stmt { Some(s) => match (*s.expr_data.clone()).clone() { ExprData::ExprReturn => v1_rt::concat( v1_rt::concat( "return Ok(".to_string(), emit_typed_expr( - return_value(s.clone()), + return_value(s), registry.clone(), init_state.scope.clone(), depth.clone(), @@ -10095,7 +10022,7 @@ pub fn emit_func_body( v1_rt::concat( "Ok(".to_string(), emit_typed_expr( - s.clone(), + s, registry.clone(), init_state.scope.clone(), depth.clone(), @@ -10199,7 +10126,7 @@ pub fn emit_tco_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored.clone(), + authored, generic_param_names, shared_types, corpus_repr, @@ -10394,9 +10321,9 @@ pub fn emit_rust_param_type( __result }); let param_str = param_types.join(&", ".to_string()); - let ret_str = match n.inferred.clone().as_deref().cloned() { + let ret_str = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_rust_fn_sig_type( - rt.clone(), + rt, generic_param_names.clone(), shared_types.clone(), corpus_repr.clone(), @@ -10444,7 +10371,7 @@ pub fn emit_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored.clone(), + authored, generic_param_names, shared_types, corpus_repr, @@ -10516,7 +10443,7 @@ pub fn needs_reference_node( pub fn is_string_lit_pattern(p: Rc) -> bool { match (*p).clone() { - MatchPattern::LitPattern { value: v, .. } => match (*v.clone()).clone() { + MatchPattern::LitPattern { value: v, .. } => match (*v).clone() { LiteralValue::LitStr { value: _, .. } => true, _ => false, }, @@ -10552,7 +10479,7 @@ pub fn positional_payload_string_guard(fb_pat: Rc, bind_name: Stri }; v1_rt::concat( v1_rt::concat(bind_name, " == ".to_string()), - emit_string_literal(s.clone(), "".to_string()), + emit_string_literal(s, "".to_string()), ) } _ => "".to_string(), @@ -10621,7 +10548,7 @@ pub fn collect_pattern_string_guards( mut source_indices: Rc>>, ) -> String { loop { - match (*pattern).clone() { + match (*pattern.clone()).clone() { MatchPattern::VariantPattern { name: n, parent_enum: parent, @@ -10675,18 +10602,18 @@ pub fn collect_pattern_string_guards( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), "0".to_string(), ); if is_string_lit_pattern(fb_pat.clone()) { break positional_payload_string_guard( fb_pat.clone(), - pattern_string_binding_name(pos_path), + pattern_string_binding_name(pos_path.clone()), ); } else { { let __tco_0 = fb_pat.clone(); - let __tco_1 = pos_path; + let __tco_1 = pos_path.clone(); pattern = __tco_0; path_prefix = __tco_1; continue; @@ -10695,7 +10622,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), source_indices.clone(), ); } @@ -10707,7 +10634,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), source_indices.clone(), ); } @@ -10784,17 +10711,17 @@ pub fn emit_pattern( emit_info: Rc, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), - MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), + MatchPattern::Bind { name: n, .. } => emit_ident(n, RenderTarget::Rust), + MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v), MatchPattern::VariantPattern { name: n, parent_enum, field_bindings: fbs, .. } => emit_variant_pattern( - n.clone(), - parent_enum.clone(), - fbs.clone(), + n, + parent_enum, + fbs, path_prefix, shared_types, scrut_type, @@ -10815,7 +10742,7 @@ pub fn pattern_parent_enum( let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { - parent_enum.clone() + parent_enum } else { if scrut_is_known_enum { Some(scrut_type.clone()) @@ -10847,7 +10774,7 @@ pub fn unique_variant_parent( __result }); if ((parent_matches.clone().len() as i64) == 1) { - parent_matches.clone().first().cloned() + parent_matches.first().cloned() } else { None } @@ -10860,7 +10787,7 @@ pub fn is_optional_variant_name(name: String) -> bool { pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone() == "Optional".to_string()), + Some(parent) => (parent == "Optional".to_string()), None => false, } } @@ -10874,23 +10801,23 @@ pub fn positional_payload_scrut_type( ) -> String { { let type_key = match parent_enum { - Some(parent) => variant_summary_key(parent.clone(), variant_name), + Some(parent) => variant_summary_key(parent, variant_name), None => variant_name, }; match lookup_emit_type_summary(emit_info, type_key) { Some(summary) => match v1_rt::map_get(&summary.field_type_map.clone(), "0".to_string()) { - Some(payload_type) => payload_type.clone(), - None => match field_binding.inferred.clone().as_deref().cloned() { + Some(payload_type) => payload_type, + None => match (*field_binding.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - authored_name_at(source_indices, normalize_access_type_node(rt.clone())) + authored_name_at(source_indices, normalize_access_type_node(rt)) } _ => "".to_string(), }, }, - None => match field_binding.inferred.clone().as_deref().cloned() { + None => match (*field_binding.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - authored_name_at(source_indices, normalize_access_type_node(rt.clone())) + authored_name_at(source_indices, normalize_access_type_node(rt)) } _ => "".to_string(), }, @@ -10943,20 +10870,20 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb.clone()); + let fb_pat = field_binding_pattern(fb); if is_string_lit_pattern(fb_pat.clone()) { "Some(ref __some_val)".to_string() } else { { let inner_pat = emit_pattern( - fb_pat.clone(), - v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), - shared_types.clone(), + fb_pat, + v1_rt::rc_list_push(path_prefix, rust_name), + shared_types, scrut_type.clone(), source_indices.clone(), emit_info.clone(), @@ -10968,7 +10895,7 @@ pub fn emit_variant_pattern( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -10980,38 +10907,38 @@ pub fn emit_variant_pattern( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), name.clone()), + v1_rt::rc_list_push(path_prefix, name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(ref ".to_string()), - bind_name.clone(), + v1_rt::concat(qualified, "(ref ".to_string()), + bind_name, ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent.clone(), + resolved_parent, name.clone(), - fb.clone(), + fb, emit_info.clone(), source_indices.clone(), ); let inner_pat = emit_pattern( - fb_pat.clone(), - pos_path.clone(), - shared_types.clone(), + fb_pat, + pos_path, + shared_types, payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(".to_string()), + v1_rt::concat(qualified, "(".to_string()), inner_pat, ), ")".to_string(), @@ -11023,24 +10950,18 @@ pub fn emit_variant_pattern( { let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let fb_pat = field_binding_pattern(fb.clone()); + let fb_pat = field_binding_pattern(fb); if is_string_lit_pattern(fb_pat.clone()) { { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), + v1_rt::rc_list_push(path_prefix, name.clone()), + fb_name, )); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - bind_name.clone(), + v1_rt::concat(qualified, " { ref ".to_string()), + bind_name, ), ", .. }".to_string(), ) @@ -11048,31 +10969,25 @@ pub fn emit_variant_pattern( } else { { let pat_str = emit_pattern( - fb_pat.clone(), + fb_pat, v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), + v1_rt::rc_list_push(path_prefix, name.clone()), fb_name.clone(), ), - shared_types.clone(), + shared_types, "".to_string(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), + emit_ident(fb_name, RenderTarget::Rust), ": ".to_string(), ), - pat_str.clone(), + pat_str, ), ), ", .. }".to_string(), @@ -11082,16 +10997,15 @@ pub fn emit_variant_pattern( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent.clone() { - Some(parent) => v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ), + let shape_key = match resolved_parent { + Some(parent) => { + v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) + } None => name.clone(), }; let is_positional = (v1_rt::set_contains( @@ -11101,20 +11015,19 @@ pub fn emit_variant_pattern( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = (v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - shape_key.clone(), - ) || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = + (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) + || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11134,9 +11047,9 @@ pub fn emit_variant_pattern( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent.clone() { + let shape_key2 = match resolved_parent { Some(parent) => v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), + v1_rt::concat(parent, "::".to_string()), name.clone(), ), None => name.clone(), @@ -11150,18 +11063,18 @@ pub fn emit_variant_pattern( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2.clone(), + shape_key2, ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11169,7 +11082,7 @@ pub fn emit_variant_pattern( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.clone().iter().cloned() { + for fb in effective_bindings.iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11268,7 +11181,7 @@ pub fn emit_variant_pattern( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11334,18 +11247,18 @@ pub fn analyze_rc_pattern( } => { if (is_optional_variant_name(n.clone()) && is_optional_parent(parent_enum.clone())) { if ((fbs.clone().len() as i64) == 1) { - match fbs.clone().first().cloned() { + match fbs.first().cloned() { Some(fb) => { let inner = analyze_rc_pattern( - field_binding_pattern(fb.clone()), + field_binding_pattern(fb), "".to_string(), shared_types.clone(), emit_info.clone(), - source_indices.clone(), + source_indices, ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone() == "Present".to_string()) + matches_option_rc_variant: ((n == "Present".to_string()) && inner.matches_rc_variant.clone()), needs_rc_pattern: inner.needs_rc_pattern.clone(), ref_bound_fields: Rc::new(vec![]), @@ -11360,17 +11273,17 @@ pub fn analyze_rc_pattern( { let resolved_parent = pattern_parent_enum( n.clone(), - parent_enum.clone(), + parent_enum, scrut_type, emit_info.type_summaries.clone(), ); let matches_rc_variant = match resolved_parent.clone() { - Some(enum_name) => v1_rt::set_contains(&shared_types, enum_name.clone()), + Some(enum_name) => v1_rt::set_contains(&shared_types, enum_name), None => false, }; let ref_bound_fields = Rc::new({ let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { + for fb in fbs.iter().cloned() { __result.extend( (*{ let fb_name = @@ -11411,7 +11324,7 @@ pub fn analyze_rc_pattern( matches_rc_variant: matches_rc_variant, matches_option_rc_variant: false, needs_rc_pattern: ((ref_bound_fields.clone().len() as i64) > 0), - ref_bound_fields: ref_bound_fields.clone(), + ref_bound_fields: ref_bound_fields, }) } } @@ -11442,19 +11355,16 @@ pub fn analyze_rc_match( } __result }); - let scrutinee_is_optional = match scrutinee.inferred.clone().as_deref().cloned() { + let scrutinee_is_optional = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } _ => false, }; - let scrutinee_is_rc_wrapped = match scrutinee.inferred.clone().as_deref().cloned() { + let scrutinee_is_rc_wrapped = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if (((rt.children.clone().len() as i64) == 0) && (rt.ident_span.clone() != None)) { - v1_rt::set_contains( - &shared_types, - authored_name_at(source_indices.clone(), rt.clone()), - ) + v1_rt::set_contains(&shared_types, authored_name_at(source_indices.clone(), rt)) } else { false } @@ -11473,7 +11383,7 @@ pub fn analyze_rc_match( }; let arms_want_deref = { let mut __found = false; - for a in arm_analyses.clone().iter().cloned() { + for a in arm_analyses.iter().cloned() { if a.matches_rc_variant.clone() { __found = true; break; @@ -11502,17 +11412,17 @@ pub fn emit_pattern_rc_aware( emit_info: Rc, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), - MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), + MatchPattern::Bind { name: n, .. } => emit_ident(n, RenderTarget::Rust), + MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v), MatchPattern::VariantPattern { name: n, parent_enum, field_bindings: fbs, .. } => emit_variant_pattern_rc_aware( - n.clone(), - parent_enum.clone(), - fbs.clone(), + n, + parent_enum, + fbs, path_prefix, rc_analysis, shared_types, @@ -11570,12 +11480,12 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb.clone()); + let fb_pat = field_binding_pattern(fb); if is_string_lit_pattern(fb_pat.clone()) { "Some(ref __some_val)".to_string() } else { @@ -11588,9 +11498,9 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat.clone(), - v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), - inner_analysis.clone(), + fb_pat, + v1_rt::rc_list_push(path_prefix, rust_name), + inner_analysis, shared_types.clone(), scrut_type.clone(), source_indices.clone(), @@ -11603,7 +11513,7 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -11615,24 +11525,24 @@ pub fn emit_variant_pattern_rc_aware( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), name.clone()), + v1_rt::rc_list_push(path_prefix, name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(ref ".to_string()), - bind_name.clone(), + v1_rt::concat(qualified, "(ref ".to_string()), + bind_name, ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent.clone(), + resolved_parent, name.clone(), - fb.clone(), + fb, emit_info.clone(), source_indices.clone(), ); @@ -11644,17 +11554,17 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat.clone(), - pos_path.clone(), - inner_analysis.clone(), + fb_pat, + pos_path, + inner_analysis, shared_types.clone(), - payload_scrut.clone(), + payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(".to_string()), + v1_rt::concat(qualified, "(".to_string()), inner_pat, ), ")".to_string(), @@ -11666,37 +11576,28 @@ pub fn emit_variant_pattern_rc_aware( { let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let fb_pat = field_binding_pattern(fb.clone()); + let fb_pat = field_binding_pattern(fb); if is_string_lit_pattern(fb_pat.clone()) { { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), + v1_rt::rc_list_push(path_prefix, name.clone()), + fb_name, )); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - bind_name.clone(), + v1_rt::concat(qualified, " { ref ".to_string()), + bind_name, ), ", .. }".to_string(), ) } } else { - if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { + if field_needs_rc_ref(fb_name.clone(), rc_analysis) { v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - emit_ident(fb_name.clone(), RenderTarget::Rust), + v1_rt::concat(qualified, " { ref ".to_string()), + emit_ident(fb_name, RenderTarget::Rust), ), ", .. }".to_string(), ) @@ -11710,15 +11611,12 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let pat_str = emit_pattern_rc_aware( - fb_pat.clone(), + fb_pat, v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), + v1_rt::rc_list_push(path_prefix, name.clone()), fb_name.clone(), ), - inner_analysis.clone(), + inner_analysis, shared_types.clone(), "".to_string(), source_indices.clone(), @@ -11726,19 +11624,13 @@ pub fn emit_variant_pattern_rc_aware( ); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ".to_string(), - ), + v1_rt::concat(qualified, " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), + emit_ident(fb_name, RenderTarget::Rust), ": ".to_string(), ), - pat_str.clone(), + pat_str, ), ), ", .. }".to_string(), @@ -11749,16 +11641,15 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent.clone() { - Some(parent) => v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ), + let shape_key = match resolved_parent { + Some(parent) => { + v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) + } None => name.clone(), }; let is_positional = (v1_rt::set_contains( @@ -11768,20 +11659,19 @@ pub fn emit_variant_pattern_rc_aware( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = (v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - shape_key.clone(), - ) || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = + (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) + || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11801,9 +11691,9 @@ pub fn emit_variant_pattern_rc_aware( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent.clone() { + let shape_key2 = match resolved_parent { Some(parent) => v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), + v1_rt::concat(parent, "::".to_string()), name.clone(), ), None => name.clone(), @@ -11817,18 +11707,18 @@ pub fn emit_variant_pattern_rc_aware( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2.clone(), + shape_key2, ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11836,7 +11726,7 @@ pub fn emit_variant_pattern_rc_aware( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.clone().iter().cloned() { + for fb in effective_bindings.iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11959,7 +11849,7 @@ pub fn emit_variant_pattern_rc_aware( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11989,9 +11879,9 @@ pub fn rc_pattern_preludes( } => { if (is_optional_variant_name(n.clone()) && is_optional_parent(parent_enum.clone())) { if ((fbs.clone().len() as i64) == 1) { - match fbs.clone().first().cloned() { + match fbs.first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb.clone()); + let fb_pat = field_binding_pattern(fb); let inner_analysis = analyze_rc_pattern( fb_pat.clone(), "".to_string(), @@ -12000,8 +11890,8 @@ pub fn rc_pattern_preludes( source_indices.clone(), ); rc_pattern_preludes( - fb_pat.clone(), - inner_analysis.clone(), + fb_pat, + inner_analysis, shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -12016,13 +11906,13 @@ pub fn rc_pattern_preludes( { let resolved_parent = pattern_parent_enum( n.clone(), - parent_enum.clone(), + parent_enum, "".to_string(), emit_info.type_summaries.clone(), ); let preludes = Rc::new({ let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { + for fb in fbs.iter().cloned() { __result.extend( (*{ let fb_name = @@ -12119,9 +12009,9 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { + let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { - Some(base) => base.clone(), + Some(base) => base, None => inferred_node.clone(), } } else { @@ -12129,34 +12019,34 @@ pub fn explicit_record_struct_name( }; let is_product = is_product_type(n.clone()); let is_coproduct = is_coproduct_type(n.clone()); - let n_is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let n_is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; let nname = authored_name_at(source_indices, n.clone()); if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { - type_name.clone() + type_name } else { if n_is_error { - type_name.clone() + type_name } else { if is_product { if (n.ident_span.clone() == None) { - type_name.clone() + type_name } else { - Some(nname.clone()) + Some(nname) } } else { if is_coproduct { - type_name.clone() + type_name } else { if (((n.children.clone().len() as i64) == 0) && (n.ident_span.clone() != None)) { - Some(nname.clone()) + Some(nname) } else { - type_name.clone() + type_name } } } @@ -12179,7 +12069,7 @@ pub fn variant_parent_from_binding_kind( Some(VarBindingKind::VariantValueBinding { parent_enum: parent_enum, .. - }) => Some(parent_enum.clone()), + }) => Some(parent_enum), _ => None, } } @@ -12221,7 +12111,7 @@ pub fn effective_variant_parent( let cached = match v1_rt::map_get(&emit_info.variant_to_enum.clone(), name.clone()) { Some(p) => { if (p.clone() != "".to_string()) { - Some(p.clone()) + Some(p) } else { None } @@ -12229,7 +12119,7 @@ pub fn effective_variant_parent( None => None, }; match cached { - Some(parent) => Some(parent.clone()), + Some(parent) => Some(parent), None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); @@ -12240,7 +12130,7 @@ pub fn effective_variant_parent( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { variant_parent_from_binding_kind(binding_kind) } @@ -12271,8 +12161,7 @@ pub fn move_licensed_at_site(emit_info: Rc, name: String, use_spa move_site_key(name.clone(), use_span.clone()), ) { Some(v) => { - (v.clone() - && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + (v && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) } None => false, } @@ -12332,7 +12221,7 @@ pub fn emit_var_ref( }; if variant_ref_self_wraps( name.clone(), - enum_name.clone(), + enum_name, shared_types, emit_info.corpus_repr.clone(), ) { @@ -12418,15 +12307,15 @@ pub fn emit_typed_expr_base( emit_keyword("null".to_string(), RenderTarget::Rust) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n.clone(), RenderTarget::Rust) + emit_keyword(n, RenderTarget::Rust) } else { { let variant_parent = effective_variant_parent( n.clone(), - binding_kind.clone(), - texpr.inferred.clone(), + binding_kind, + (*texpr.inferred).clone(), emit_info.clone(), - si.clone(), + si, ); match variant_parent { Some(enum_name) => { @@ -12440,7 +12329,7 @@ pub fn emit_typed_expr_base( let qualified = if (is_optional_variant_name(n.clone()) && (enum_name.clone() == "Optional".to_string())) { - if (n.clone() == "Present".to_string()) { + if (n == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -12451,11 +12340,10 @@ pub fn emit_typed_expr_base( enum_name.clone(), "::".to_string(), ), - n.clone(), + n, ) }; - if v1_rt::set_contains(&shared_types, enum_name.clone()) - { + if v1_rt::set_contains(&shared_types, enum_name) { v1_rt::concat( v1_rt::concat( "Rc::new(".to_string(), @@ -12473,12 +12361,12 @@ pub fn emit_typed_expr_base( Some(info) => { let is_data = (info.kind.clone() == ItemKind::DataItem); if is_data { - v1_rt::concat(to_snake(n.clone()), "()".to_string()) + v1_rt::concat(to_snake(n), "()".to_string()) } else { - emit_ident(n.clone(), RenderTarget::Rust) + emit_ident(n, RenderTarget::Rust) } } - None => emit_ident(n.clone(), RenderTarget::Rust), + None => emit_ident(n, RenderTarget::Rust), }, } } @@ -12508,7 +12396,7 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); match find_child_named( @@ -12517,7 +12405,7 @@ pub fn field_access_field_is_boxed( (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { - let field_ty = resolved_type(field_child.clone()); + let field_ty = resolved_type(field_child); let field_ty_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), @@ -12536,15 +12424,12 @@ pub fn field_access_field_is_boxed( || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); ((faithful_nat_field || needs_box_wrapping( - field_ty.clone(), + field_ty, emit_info.recursive_type_set.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), )) - || is_recursive_type_by_name( - scope.type_env.clone(), - field_ty_name.clone(), - )) + || is_recursive_type_by_name((*scope.type_env).clone(), field_ty_name)) } } } @@ -12572,7 +12457,7 @@ pub fn emit_typed_field_access( shared_types.clone(), emit_info.clone(), ); - let base_is_anon_record = match base.inferred.clone().as_deref().cloned() { + let base_is_anon_record = match (*base.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: bt, .. }) => { let is_product = is_product_type(bt.clone()); if (is_product && (bt.ident_span.clone() == None)) { @@ -12752,13 +12637,13 @@ pub fn type_needs_rc_seen( mut source_indices: Rc>>, ) -> bool { loop { - let normed = normalize_access_type_node(type_node); + let normed = normalize_access_type_node(type_node.clone()); let is_product = is_product_type(normed.clone()); let is_coproduct = is_coproduct_type(normed.clone()); - if is_product { + if is_product.clone() { break true; } else { - if is_coproduct { + if is_coproduct.clone() { break { let mut __found = false; for child in normed.children.clone().iter().cloned() { @@ -12771,7 +12656,7 @@ pub fn type_needs_rc_seen( }; } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if ((*normed.inferred).clone() != None) { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { @@ -12779,7 +12664,7 @@ pub fn type_needs_rc_seen( }; { let __tco_0 = resolved_type(normed.clone()); - let __tco_1 = next_seen; + let __tco_1 = next_seen.clone(); type_node = __tco_0; seen = __tco_1; continue; @@ -12796,12 +12681,13 @@ pub fn type_needs_rc_seen( v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; let has_structure = (normed.connective.clone() != Connective::NoConnective); - if (!has_structure && ((normed.children.clone().len() as i64) == 0)) { + if (!has_structure.clone() && ((normed.children.clone().len() as i64) == 0)) + { break false; } else { { let __tco_0 = normed.clone(); - let __tco_1 = next_seen; + let __tco_1 = next_seen.clone(); type_node = __tco_0; seen = __tco_1; continue; @@ -12820,8 +12706,8 @@ pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> bool pub fn rust_runtime_bridge_name(function_name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), function_name.clone()) { - Some(runtime_name) => runtime_name.clone(), - None => function_name.clone(), + Some(runtime_name) => runtime_name, + None => function_name, } } @@ -12834,7 +12720,7 @@ pub fn rust_empty_map_value_type_str( match map_type.children.clone().get(1 as usize).cloned() { Some(value_child) => { let rendered = render_rust_type( - child_type_node(value_child.clone()), + child_type_node(value_child), shared_types, corpus_repr, source_indices, @@ -12842,7 +12728,7 @@ pub fn rust_empty_map_value_type_str( if (rendered.clone() == "".to_string()) { "".to_string() } else { - rendered.clone() + rendered } } None => "".to_string(), @@ -12858,7 +12744,7 @@ pub fn rust_empty_map_kv_type_str( { let key_str = match map_type.children.clone().first().cloned() { Some(key_child) => render_rust_type( - child_type_node(key_child.clone()), + child_type_node(key_child), shared_types.clone(), corpus_repr.clone(), source_indices.clone(), @@ -12872,10 +12758,7 @@ pub fn rust_empty_map_kv_type_str( source_indices.clone(), ); if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { - v1_rt::concat( - v1_rt::concat(key_str.clone(), ", ".to_string()), - val_str.clone(), - ) + v1_rt::concat(v1_rt::concat(key_str, ", ".to_string()), val_str) } else { "".to_string() } @@ -12885,8 +12768,8 @@ pub fn rust_empty_map_kv_type_str( pub fn type_node_child_is_type_variable(c: Rc) -> bool { { let ch = child_type_node(c); - if (ch.inferred.clone() != None) { - is_type_variable(ch.inferred.clone().clone().unwrap()) + if ((*ch.inferred).clone() != None) { + is_type_variable((*ch.inferred).clone().clone().unwrap()) } else { false } @@ -12904,7 +12787,7 @@ pub fn rust_btree_set_element_ord_eligible( || (elem_name.clone() == "Bool".to_string())) || (elem_name.clone() == "Unit".to_string())) || (elem_name.clone() == "Secret".to_string())) - || (elem_name.clone() == "Bytes".to_string())) + || (elem_name == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12916,14 +12799,14 @@ pub fn rust_empty_set_element_type_str( ) -> String { match set_type.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_node = child_type_node(elem_child); + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; - let elem_is_error = if (elem_node.inferred.clone() != None) { - is_compiler_error(elem_node.inferred.clone().clone().unwrap()) + let elem_is_error = if ((*elem_node.inferred).clone() != None) { + is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -12934,7 +12817,7 @@ pub fn rust_empty_set_element_type_str( "".to_string() } else { render_node_type( - elem_node.clone(), + elem_node, RenderTarget::Rust, shared_types, source_indices.clone(), @@ -12953,9 +12836,9 @@ pub fn emit_rust_empty_set_expr( ) -> String { match set_type.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_node = child_type_node(elem_child); + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -12964,7 +12847,7 @@ pub fn emit_rust_empty_set_expr( } else { if !rust_btree_set_element_ord_eligible(elem_node.clone(), source_indices.clone()) { { - let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); + let elem_name = authored_name_at(source_indices.clone(), elem_node); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("empty_set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -12979,10 +12862,7 @@ pub fn emit_rust_empty_set_expr( ); if (elem_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat( - "v1_rt::rc_empty_set::<".to_string(), - elem_str.clone(), - ), + v1_rt::concat("v1_rt::rc_empty_set::<".to_string(), elem_str), ">()".to_string(), ) } else { @@ -13048,8 +12928,8 @@ pub fn emit_rust_expr_var( let n = expr_var_name_at(expr.clone(), source_indices.clone()); emit_var_ref( n, - binding_kind.clone(), - expr.inferred.clone(), + binding_kind, + (*expr.inferred).clone(), expr.span.clone().start.clone(), shared_types, registry, @@ -13088,11 +12968,11 @@ pub fn emit_rust_expr_field_access( expr.clone(), (*scope.type_env).clone().source_indices.clone(), ) { - Some(svc_name) => service_var_name(svc_name.clone()), + Some(svc_name) => service_var_name(svc_name), None => emit_typed_field_access( b, f, - summary.clone(), + summary, registry, scope.clone(), depth, @@ -13104,7 +12984,7 @@ pub fn emit_rust_expr_field_access( emit_typed_field_access( b, f, - summary.clone(), + summary, registry, scope.clone(), depth, @@ -13138,7 +13018,7 @@ pub fn emit_rust_expr_call( emit_typed_call_expr( f, expr.children.clone(), - expr.inferred.clone(), + (*expr.inferred).clone(), registry, scope.clone(), depth, @@ -13177,8 +13057,8 @@ pub fn emit_rust_expr_method_call( r, m, a, - expr.inferred.clone(), - method_semantics.clone(), + (*expr.inferred).clone(), + method_semantics, registry, scope.clone(), depth, @@ -13292,11 +13172,11 @@ pub fn emit_rust_expr_record_lit( let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { - Some(n) => n.clone(), + Some(n) => n, None => "".to_string(), }; let peeled_type_name = if (((parent_enum.clone() == None) @@ -13308,13 +13188,13 @@ pub fn emit_rust_expr_record_lit( if ((concrete.clone() != "".to_string()) && (concrete.clone() != variant_name.clone())) { - Some(concrete.clone()) + Some(concrete) } else { - tn.clone() + tn } } } else { - tn.clone() + tn }; let raw = emit_typed_record_lit( peeled_type_name, @@ -13328,31 +13208,30 @@ pub fn emit_rust_expr_record_lit( emit_info.clone(), ); let rc_name = match parent_enum.clone() { - Some(en) => en.clone(), + Some(en) => en, None => match contextual_variant_parent( variant_name.clone(), - parent_enum.clone(), + parent_enum, expanded_rt.clone(), emit_info.clone(), si.clone(), ) { - Some(p) => p.clone(), + Some(p) => p, None => { - let expanded_name = authored_name_at(si.clone(), expanded_rt.clone()); + let expanded_name = authored_name_at(si, expanded_rt.clone()); if ((((expanded_rt.ident_span.clone() != None) && (expanded_name.clone() != "".to_string())) && (expanded_name.clone() != variant_name.clone())) && v1_rt::set_contains(&shared_types, expanded_name.clone())) { - expanded_name.clone() + expanded_name } else { - variant_name.clone() + variant_name } } }, }; - if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name.clone())) + if ((rc_name.clone() != "".to_string()) && v1_rt::set_contains(&shared_types, rc_name)) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -13552,8 +13431,8 @@ pub fn emit_rust_expr_bin_op( algebra_field: algebra, .. } => emit_typed_bin_op( - op.clone(), - algebra.clone(), + op, + algebra, binop_left(expr.clone()), binop_right(expr.clone()), registry, @@ -13780,7 +13659,7 @@ pub fn contextual_variant_parent( variant_name.clone(), explicit_parent.clone(), ) { - Some(explicit_parent.clone()) + Some(explicit_parent) } else { None } @@ -13795,7 +13674,7 @@ pub fn contextual_variant_parent( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { None } @@ -13807,10 +13686,8 @@ pub fn is_map_typed_expr( texpr: Rc, source_indices: Rc>>, ) -> bool { - match texpr.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: n, .. }) => { - node_is_keyed_collection(n.clone(), source_indices) - } + match (*texpr.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: n, .. }) => node_is_keyed_collection(n, source_indices), _ => false, } } @@ -13834,11 +13711,8 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); - match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { + let ty_name = resolved_type_name(arg, (*scope.type_env).clone().source_indices.clone()); + match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13847,7 +13721,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name(scope.type_env.clone(), child.clone()); + authored_name((*scope.type_env).clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13904,7 +13778,7 @@ pub fn emit_discriminant_call_lowering( } __result }); - let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name.clone()) { + let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name) { v1_rt::concat( v1_rt::concat("&*(".to_string(), scrutinee), ")".to_string(), @@ -13928,19 +13802,13 @@ pub fn emit_discriminant_call_lowering( } } else { emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( - v1_rt::concat("\"".to_string(), ty_name.clone()), - "\"".to_string(), - ), + v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), emit_info.corpus_repr.clone(), ) } } None => emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( - v1_rt::concat("\"".to_string(), ty_name.clone()), - "\"".to_string(), - ), + v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), emit_info.corpus_repr.clone(), ), } @@ -13962,17 +13830,14 @@ pub fn emit_typed_call_expr( match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( - ret_type.clone(), + ret_type, shared_types, emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat( - "v1_rt::rc_empty_map::<".to_string(), - kv_type_str.clone(), - ), + v1_rt::concat("v1_rt::rc_empty_map::<".to_string(), kv_type_str), ">()".to_string(), ) } else { @@ -13988,7 +13853,7 @@ pub fn emit_typed_call_expr( match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( - ret_type.clone(), + ret_type, shared_types, (*scope.type_env).clone().source_indices.clone(), ) @@ -14028,9 +13893,7 @@ pub fn rust_call_arg_fail_closed_unwrap( match callee { Some(info) => match info.params.clone().get(idx.clone() as usize).cloned() { Some(param) => { - let param_required = (param_node_type_expr(param.clone()) - .return_cardinality - .clone() + let param_required = (param_node_type_expr(param).return_cardinality.clone() != Cardinality::CardOptional); let arg_optional = (resolved_type(arg).return_cardinality.clone() == Cardinality::CardOptional); @@ -14060,12 +13923,12 @@ pub fn emit_typed_call( { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); - let get_idx = get_args.clone().get(1 as usize).cloned(); + let get_idx = get_args.get(1 as usize).cloned(); let get_result = match get_list { Some(list_arg) => match get_idx { Some(idx_arg) => { let list_str = emit_typed_expr( - arg_value(list_arg.clone()), + arg_value(list_arg), registry.clone(), scope.clone(), depth.clone(), @@ -14074,7 +13937,7 @@ pub fn emit_typed_call( 1024, ); let index_str = emit_typed_expr( - arg_value(idx_arg.clone()), + arg_value(idx_arg), registry.clone(), scope.clone(), depth.clone(), @@ -14110,8 +13973,7 @@ pub fn emit_typed_call( if ((with_args.clone().len() as i64) < 2) { return "compile_error!(\"with call missing update record\")".to_string(); } - let update_arg = - arg_value(with_args.clone().get(1 as usize).cloned().clone().unwrap()); + let update_arg = arg_value(with_args.get(1 as usize).cloned().clone().unwrap()); let base_str = emit_typed_expr( base_arg.clone(), registry.clone(), @@ -14121,10 +13983,10 @@ pub fn emit_typed_call( emit_info.clone(), 1024, ); - let type_name = if (base_arg.inferred.clone() != None) { + let type_name = if ((*base_arg.inferred).clone() != None) { authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(base_arg.clone()), + resolved_type(base_arg), ) } else { "compile_error!(\"with call missing resolved record type\")".to_string() @@ -14158,7 +14020,7 @@ pub fn emit_typed_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg.clone(), + update_arg, registry.clone(), scope.clone(), depth.clone(), @@ -14178,17 +14040,14 @@ pub fn emit_typed_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(type_name.clone(), " { ".to_string()), - fields_str, - ), + v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc.clone() { + if needs_rc { return v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string(), @@ -14241,7 +14100,7 @@ pub fn emit_typed_call( let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { Some(value_arg) => emit_discriminant_call_lowering( - value_arg.clone(), + value_arg, registry.clone(), scope.clone(), depth.clone(), @@ -14420,7 +14279,7 @@ pub fn emit_typed_call( } else { { let mut __found = false; - for a in filled_args.clone().iter().cloned() { + for a in filled_args.iter().cloned() { if expr_references_var(arg_value(a.clone()), func.clone(), si.clone()) { __found = true; break; @@ -14442,21 +14301,21 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt.clone() && (func.clone() == "concat".to_string())) + let call_str = if ((is_rt && (func.clone() == "concat".to_string())) && ((all_args.clone().len() as i64) > 2)) { - emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) + emit_nested_rt_concat(all_args, "".to_string(), shared_types.clone()) } else { v1_rt::concat( v1_rt::concat(v1_rt::concat(func_name, "(".to_string()), args_str), ")".to_string(), ) }; - match callee.clone() { + match callee { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects.clone() { + if has_effects { v1_rt::concat(call_str, ".await?".to_string()) } else { call_str @@ -14639,7 +14498,7 @@ pub fn emit_nested_rt_concat( .skip(1 as usize) .collect::>(), ); - let __tco_1 = next_acc; + let __tco_1 = next_acc.clone(); remaining = __tco_0; acc = __tco_1; continue; @@ -14693,7 +14552,7 @@ pub fn emit_typed_for_each( let ind2 = make_indent((depth.clone() + 2)); let ind0 = make_indent(depth.clone()); let iter_str = apply_type_template1(sharing.iter_owned.clone(), coll_str); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1.clone()), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) } } @@ -14731,10 +14590,7 @@ pub fn emit_typed_index( base_node.clone(), (*scope.type_env).clone().source_indices.clone(), ); - if is_rust_string_like( - base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { apply_type_template2( spec.indexing.clone().string_index.clone(), base_str, @@ -14796,7 +14652,7 @@ pub fn emit_typed_slice( let base_node = normalize_access_type_node(resolved_type(base.clone())); if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), None => emit_error_expr( "unsupported string slice for target".to_string(), RenderTarget::Rust, @@ -14804,7 +14660,7 @@ pub fn emit_typed_slice( } } else { match spec.indexing.clone().list_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), None => emit_error_expr( "unsupported list slice for target".to_string(), RenderTarget::Rust, @@ -14826,14 +14682,14 @@ pub fn collection_element_type( if __rt_is_container { match rt.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child.clone()); - let elem_is_error = if (elem_node.inferred.clone() != None) { - is_compiler_error(elem_node.inferred.clone().clone().unwrap()) + let elem_node = child_type_node(elem_child); + let elem_is_error = if ((*elem_node.inferred).clone() != None) { + is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) } else { false }; - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -14841,7 +14697,7 @@ pub fn collection_element_type( "_".to_string() } else { render_rust_type( - elem_node.clone(), + elem_node, shared_types, corpus_repr, source_indices.clone(), @@ -14873,11 +14729,11 @@ pub fn lambda_scope_from_children( ) .iter() .cloned() - .fold(scope.clone(), |acc: Rc, pair: (i64, String)| { + .fold(scope, |acc: Rc, pair: (i64, String)| { let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match pn.inferred.clone().as_deref().cloned() { + Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: resolved_type, .. @@ -14920,17 +14776,17 @@ pub fn lambda_param_type_strs( let idx = pair.0.clone(); let param_name = pair.1.clone(); let inferred_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match pn.inferred.clone().as_deref().cloned() { + Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: param_type, .. }) => { - let param_is_error = if (param_type.inferred.clone() != None) { - is_compiler_error(param_type.inferred.clone().clone().unwrap()) + let param_is_error = if ((*param_type.inferred).clone() != None) { + is_compiler_error((*param_type.inferred).clone().clone().unwrap()) } else { false }; - let param_is_type_var = if (param_type.inferred.clone() != None) { - is_type_variable(param_type.inferred.clone().clone().unwrap()) + let param_is_type_var = if ((*param_type.inferred).clone() != None) { + is_type_variable((*param_type.inferred).clone().clone().unwrap()) } else { false }; @@ -15008,7 +14864,7 @@ pub fn emit_typed_collection_lambda( (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); - let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); + let lambda_scope = lambda_scope_from_children(scope.clone(), ps, pn); let body_str = emit_typed_expr( bd, registry, @@ -15109,8 +14965,8 @@ pub fn emit_typed_fold_lambda( emit_info.clone(), 1024, ); - let acc_name = match ps.clone().first().cloned() { - Some(n) => n.clone(), + let acc_name = match ps.first().cloned() { + Some(n) => n, None => "".to_string(), }; let needs_unwrap = ((acc_name.clone() != "".to_string()) @@ -15129,7 +14985,7 @@ pub fn emit_typed_fold_lambda( ), ":".to_string(), ), - acc_name.clone(), + acc_name, ); v1_rt::concat( v1_rt::concat( @@ -15147,7 +15003,7 @@ pub fn emit_typed_fold_lambda( ), " = v1_rt::take_owned_counted(".to_string(), ), - acc_ident.clone(), + acc_ident, ), ", \"".to_string(), ), @@ -15202,7 +15058,7 @@ pub fn emit_rust_fold_method_call( 1024, ); let elem_type_str = collection_element_type( - receiver.inferred.clone(), + (*receiver.inferred).clone(), shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15211,7 +15067,7 @@ pub fn emit_rust_fold_method_call( Some(InferredNode::Resolved { node: method_result_type, .. - }) => Some(method_result_type.clone()), + }) => Some(method_result_type), _ => None, }; let acc_type_node = match fold_accumulator_type { @@ -15263,7 +15119,7 @@ pub fn emit_rust_fold_method_call( (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) - || acc_children_have_unit.clone())); + || acc_children_have_unit)); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15278,18 +15134,18 @@ pub fn emit_rust_fold_method_call( || is_under_resolved_non_collection) { match contextual_acc_type { - Some(concrete_type) => concrete_type.clone(), - None => acc_type.clone(), + Some(concrete_type) => concrete_type, + None => acc_type, } } else { - acc_type.clone() + acc_type } } None => match contextual_acc_type { - Some(concrete_type) => concrete_type.clone(), + Some(concrete_type) => concrete_type, None => match args.clone().first().cloned() { Some(init_arg) => { - if (arg_value(init_arg.clone()).inferred.clone() != None) { + if ((*arg_value(init_arg.clone()).inferred).clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15315,7 +15171,7 @@ pub fn emit_rust_fold_method_call( .first() .cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "".to_string(), }, _ => "".to_string(), @@ -15335,7 +15191,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node.clone(), + fold_lambda_node, (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15352,7 +15208,7 @@ pub fn emit_rust_fold_method_call( variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_set_insert( emit_info.owned_bindings.clone(), - acc_name.clone(), + acc_name, ), move_sites_index: emit_info.move_sites_index.clone(), move_sites: emit_info.move_sites.clone(), @@ -15370,7 +15226,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node.clone(), + fold_lambda_node, (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15383,10 +15239,7 @@ pub fn emit_rust_fold_method_call( .clone(), shared_types: emit_info.shared_types.clone(), ownership_index: emit_info.ownership_index.clone(), - movable: v1_rt::rc_set_insert( - emit_info.movable.clone(), - acc_name.clone(), - ), + movable: v1_rt::rc_set_insert(emit_info.movable.clone(), acc_name), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), move_sites_index: emit_info.move_sites_index.clone(), @@ -15410,8 +15263,8 @@ pub fn emit_rust_fold_method_call( emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { - is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) + let acc_type_is_type_var = if ((*acc_type_node.inferred).clone() != None) { + is_type_variable((*acc_type_node.inferred).clone().clone().unwrap()) } else { false }; @@ -15426,7 +15279,7 @@ pub fn emit_rust_fold_method_call( __found }; let is_bare_container = (((acc_type_node.children.clone().len() as i64) == 0) - && is_container_type(acc_type_name.clone())); + && is_container_type(acc_type_name)); let lambda_acc_type_str = if ((is_bare_container || acc_type_is_type_var) || acc_child_is_type_var) { "_".to_string() @@ -15475,7 +15328,7 @@ pub fn emit_rust_fold_method_call( { { let kv_type_str = rust_empty_map_kv_type_str( - acc_type_node.clone(), + acc_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15484,7 +15337,7 @@ pub fn emit_rust_fold_method_call( v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), - kv_type_str.clone(), + kv_type_str, ), ">()".to_string(), ) @@ -15498,20 +15351,20 @@ pub fn emit_rust_fold_method_call( } else { if ((((init_func.clone() == "empty_set".to_string()) && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) - && !acc_has_unit_child.clone()) + && (acc_type_str != "".to_string())) + && !acc_has_unit_child) { emit_rust_empty_set_expr( - acc_type_node.clone(), + acc_type_node, shared_types.clone(), (*scope.type_env).clone().source_indices.clone(), ) } else { - if (init_func.clone() == "empty_set".to_string()) { + if (init_func == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( - arg_value(init_arg.clone()), + arg_value(init_arg), registry.clone(), scope.clone(), depth.clone(), @@ -15525,7 +15378,7 @@ pub fn emit_rust_fold_method_call( } } _ => emit_typed_expr( - arg_value(init_arg.clone()), + arg_value(init_arg), registry.clone(), scope.clone(), depth.clone(), @@ -15545,14 +15398,14 @@ pub fn emit_rust_fold_method_call( scope.clone(), depth.clone(), shared_types.clone(), - fold_emit_info.clone(), + fold_emit_info, ), None => "compile_error!(\"missing fold function argument\")".to_string(), }; let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( - arg_value(a.clone()), + arg_value(a), (*scope.type_env).clone().source_indices.clone(), ), None => false, @@ -15593,7 +15446,7 @@ pub fn fold_lambda_element_unused( ExprData::ExprLambda => { let ps = lambda_param_names_at(lambda_expr.clone(), source_indices); match ps.get(1 as usize).cloned() { - Some(elem_name) => (elem_name.clone() == "_".to_string()), + Some(elem_name) => (elem_name == "_".to_string()), None => false, } } @@ -15620,21 +15473,21 @@ pub fn emit_rust_sort_by_method_call( emit_info.clone(), 1024, ); - let elem_type_str = match receiver.inferred.clone().as_deref().cloned() { + let elem_type_str = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let resolved = rt.clone(); + let resolved = rt; let elem = for_each_element_type_node( resolved, (*scope.type_env).clone().source_indices.clone(), ); - let elem_is_type_var = if (elem.inferred.clone() != None) { - is_type_variable(elem.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem.inferred).clone() != None) { + is_type_variable((*elem.inferred).clone().clone().unwrap()) } else { false }; if ((elem.ident_span.clone() != None) && !elem_is_type_var) { render_rust_type( - elem.clone(), + elem, shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15647,7 +15500,7 @@ pub fn emit_rust_sort_by_method_call( }; let sort_key_fn = match args.first().cloned() { Some(a) => emit_typed_collection_lambda( - arg_value(a.clone()), + arg_value(a), elem_type_str.clone(), registry.clone(), scope.clone(), @@ -15664,7 +15517,7 @@ pub fn emit_rust_sort_by_method_call( if (elem_type_str.clone() == "_".to_string()) { v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a, b| { a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str.clone()), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn.clone()), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } } } @@ -15696,7 +15549,7 @@ pub fn emit_rust_map_method_call( shared_types.clone(), emit_info.clone(), ); - let recv_is_optional = match receiver.inferred.clone().as_deref().cloned() { + let recv_is_optional = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -15707,7 +15560,7 @@ pub fn emit_rust_map_method_call( Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15715,15 +15568,15 @@ pub fn emit_rust_map_method_call( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( - arg_value(a.clone()) + arg_value(a) .children .clone() .iter() @@ -15772,7 +15625,7 @@ pub fn emit_rust_map_method_call( ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15780,15 +15633,15 @@ pub fn emit_rust_map_method_call( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( - arg_value(a.clone()) + arg_value(a) .children .clone() .iter() @@ -15870,7 +15723,7 @@ pub fn emit_rust_higher_order_method( Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15878,15 +15731,15 @@ pub fn emit_rust_higher_order_method( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( - arg_value(a.clone()) + arg_value(a) .children .clone() .iter() @@ -15916,7 +15769,7 @@ pub fn emit_rust_higher_order_method( v1_rt::rc_map_insert( seed_bindings("param".to_string(), p), "body".to_string(), - body_str.clone(), + body_str, ), "iter".to_string(), iter_str, @@ -15983,7 +15836,7 @@ pub fn emit_rust_get_method_call( ); let index_str = match args.first().cloned() { Some(a) => emit_typed_expr( - arg_value(a.clone()), + arg_value(a), registry.clone(), scope.clone(), depth.clone(), @@ -15993,7 +15846,7 @@ pub fn emit_rust_get_method_call( ), None => "compile_error!(\"get method missing index\")".to_string(), }; - let receiver_resolved = match receiver.inferred.clone().as_deref().cloned() { + let receiver_resolved = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }; @@ -16046,17 +15899,17 @@ pub fn emit_rust_with_method_call( emit_info.clone(), 1024, ); - let type_name = match receiver.inferred.clone().as_deref().cloned() { + let type_name = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let rt_is_error = if (rt.inferred.clone() != None) { - is_compiler_error(rt.inferred.clone().clone().unwrap()) + let rt_is_error = if ((*rt.inferred).clone() != None) { + is_compiler_error((*rt.inferred).clone().clone().unwrap()) } else { false }; if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -16094,7 +15947,7 @@ pub fn emit_rust_with_method_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg.clone(), + update_arg, registry.clone(), scope.clone(), depth.clone(), @@ -16114,17 +15967,14 @@ pub fn emit_rust_with_method_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(type_name.clone(), " { ".to_string()), - fields_str, - ), + v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc.clone() { + if needs_rc { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16254,7 +16104,7 @@ pub fn emit_rust_generic_method_call( v1_rt::concat("(".to_string(), recv_str), ".".to_string(), ), - emit_ident(function_name.clone(), RenderTarget::Rust), + emit_ident(function_name, RenderTarget::Rust), ), ")(".to_string(), ), @@ -16317,7 +16167,7 @@ pub fn emit_rust_generic_method_call( ), ")".to_string(), ); - if rust_runtime_bridge_wraps_collection_result_in_rc(function_name.clone()) { + if rust_runtime_bridge_wraps_collection_result_in_rc(function_name) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), lowered), ")".to_string(), @@ -16350,7 +16200,7 @@ pub fn emit_typed_method_call( op_params, .. } => { - let var_name = service_var_name(svc_name.clone()); + let var_name = service_var_name(svc_name); let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), @@ -16382,7 +16232,7 @@ pub fn emit_typed_method_call( ); let json_param_set = Rc::new({ let mut __result = Vec::new(); - for p in op_params.clone().iter().cloned() { + for p in op_params.iter().cloned() { if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), @@ -16479,10 +16329,8 @@ pub fn emit_typed_method_call( fold_accumulator_type, .. } => { - let method_name_raw = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - method_def.clone(), - ); + let method_name_raw = + authored_name_at((*scope.type_env).clone().source_indices.clone(), method_def); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), @@ -16493,12 +16341,12 @@ pub fn emit_typed_method_call( "count".to_string() } } else { - method_name_raw.clone() + method_name_raw }; if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( method_call_node, - fold_accumulator_type.clone(), + fold_accumulator_type, result_type, receiver.clone(), args.clone(), @@ -16544,7 +16392,7 @@ pub fn emit_typed_method_call( .cloned() { Some(ho_spec) => emit_rust_higher_order_method( - ho_spec.clone(), + ho_spec, receiver.clone(), args.clone(), registry.clone(), @@ -16683,10 +16531,9 @@ pub fn emit_typed_method_call( first_arg_str, ); let raw = apply_named_template( - tmpl.clone(), - bindings, + tmpl, bindings, ); - if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { + if rust_runtime_bridge_wraps_collection_result_in_rc(method_name) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16694,7 +16541,7 @@ pub fn emit_typed_method_call( } None => { emit_rust_generic_method_call( - method_name.clone(), + method_name, receiver.clone(), args.clone(), result_type, @@ -16774,7 +16621,7 @@ pub fn emit_typed_first_arg( ) -> String { match args.first().cloned() { Some(a) => emit_typed_expr( - arg_value(a.clone()), + arg_value(a), registry, scope, depth, @@ -16814,7 +16661,7 @@ pub fn freemonoid_cons_binding( .. } => match Rc::new({ let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { + for fb in fbs.iter().cloned() { if (field_binding_name_at(fb.clone(), source_indices.clone()) == field.clone()) { __result.push(fb); } @@ -16824,8 +16671,8 @@ pub fn freemonoid_cons_binding( .first() .cloned() { - Some(fb) => match (*field_binding_pattern(fb.clone())).clone() { - MatchPattern::Bind { name: nm, .. } => nm.clone(), + Some(fb) => match (*field_binding_pattern(fb)).clone() { + MatchPattern::Bind { name: nm, .. } => nm, _ => "_".to_string(), }, None => "_".to_string(), @@ -16844,14 +16691,14 @@ pub fn arm_resolved_parent_enum( name: n, parent_enum: pe, .. - } => pattern_parent_enum(n.clone(), pe.clone(), scrut_type, type_summaries), + } => pattern_parent_enum(n, pe, scrut_type, type_summaries), _ => None, } } pub fn parent_enum_is_freemonoid(p: Option) -> bool { match p { - Some(nm) => (nm.clone() == "FreeMonoid".to_string()), + Some(nm) => (nm == "FreeMonoid".to_string()), None => false, } } @@ -16876,7 +16723,7 @@ pub fn freemonoid_catchall_arm(arms: Rc>>) -> Option> { pub fn freemonoid_catchall_bind_name(arm: Rc) -> String { match (*arm_pattern(arm)).clone() { - MatchPattern::Bind { name: nm, .. } => nm.clone(), + MatchPattern::Bind { name: nm, .. } => nm, _ => "".to_string(), } } @@ -16897,7 +16744,7 @@ pub fn arms_are_freemonoid_coproduct( }; let empty_is_fm = match freemonoid_match_arm_for(arms.clone(), "Empty".to_string()) { Some(ea) => parent_enum_is_freemonoid(arm_resolved_parent_enum( - ea.clone(), + ea, scrut_type.clone(), type_summaries.clone(), )), @@ -16905,7 +16752,7 @@ pub fn arms_are_freemonoid_coproduct( }; let cons_is_fm = match freemonoid_match_arm_for(arms.clone(), "Cons".to_string()) { Some(ca) => parent_enum_is_freemonoid(arm_resolved_parent_enum( - ca.clone(), + ca, scrut_type.clone(), type_summaries.clone(), )), @@ -16917,7 +16764,7 @@ pub fn arms_are_freemonoid_coproduct( }; let is_fm = (empty_is_fm || cons_is_fm); let empty_fillable = (has_empty || has_catchall.clone()); - let cons_fillable = (has_cons || has_catchall.clone()); + let cons_fillable = (has_cons || has_catchall); ((is_fm && empty_fillable) && cons_fillable) } } @@ -16933,7 +16780,7 @@ pub fn freemonoid_empty_branch_body( ) -> String { match empty_arm { Some(ea) => emit_typed_expr( - arm_body(ea.clone()), + arm_body(ea), registry, scope, depth, @@ -16948,14 +16795,14 @@ pub fn freemonoid_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_expr( - arm_body(wa.clone()), + arm_body(wa), registry, scope, depth, @@ -16988,7 +16835,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind.clone()), + v1_rt::concat("let ".to_string(), head_bind), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -16996,14 +16843,14 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind.clone()), + v1_rt::concat("let ".to_string(), tail_bind), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; v1_rt::concat( v1_rt::concat(head_let, tail_let), emit_typed_expr( - arm_body(ca.clone()), + arm_body(ca), registry, scope, depth, @@ -17020,14 +16867,14 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_expr( - arm_body(wa.clone()), + arm_body(wa), registry, scope, depth, @@ -17067,7 +16914,7 @@ pub fn emit_native_freemonoid_match( ); let nonempty_body = freemonoid_nonempty_branch_body( cons_arm, - catchall.clone(), + catchall, si, registry.clone(), scope.clone(), @@ -17086,11 +16933,11 @@ pub fn emit_native_freemonoid_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body.clone(), + empty_body, ), " } else { ".to_string(), ), - nonempty_body.clone(), + nonempty_body, ), " } }".to_string(), ) @@ -17117,16 +16964,16 @@ pub fn emit_typed_match( emit_info.clone(), 1024, ); - let scrut_type = match scrutinee.inferred.clone().as_deref().cloned() { + let scrut_type = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( (*scope.type_env).clone().source_indices.clone(), - with_required_cardinality(rt.clone()), + with_required_cardinality(rt), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt) } } _ => "".to_string(), @@ -17150,7 +16997,7 @@ pub fn emit_typed_match( "".to_string() }; if (native_fm.clone() != "".to_string()) { - return native_fm.clone(); + return native_fm; } let rc_match = analyze_rc_match( scrutinee.clone(), @@ -17161,7 +17008,7 @@ pub fn emit_typed_match( (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { - Some(first_arm) => resolved_type(arm_body(first_arm.clone())), + Some(first_arm) => resolved_type(arm_body(first_arm)), None => type_variable_node("match_result".to_string()), }; let arm_strs = Rc::new({ @@ -17191,7 +17038,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -17211,10 +17058,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( "match ".to_string(), - apply_type_template1( - sharing.deref_clone.clone(), - scrut_str.clone(), - ), + apply_type_template1(sharing.deref_clone.clone(), scrut_str), ), " {\n".to_string(), ), @@ -17228,7 +17072,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_str() {\n".to_string(), ), arms_str, @@ -17259,7 +17103,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), sf_arms_str, @@ -17271,7 +17115,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), arms_str, @@ -17314,11 +17158,11 @@ pub fn emit_typed_match_arm( LiteralValue::LitStr { value: s, .. } => v1_rt::concat( v1_rt::concat( "ref __s if __s == \"".to_string(), - escape_string_literal_body(s.clone()), + escape_string_literal_body(s), ), "\"".to_string(), ), - _ => rust_literal_for_pattern(v.clone()), + _ => rust_literal_for_pattern(v), }, _ => emit_pattern( arm_pat.clone(), @@ -17355,7 +17199,7 @@ pub fn emit_typed_match_arm( collect_pattern_string_guards(arm_pat.clone(), Rc::new(vec![]), si.clone()); let arm_guard_str = match arm_g { Some(g) => emit_typed_expr( - g.clone(), + g, registry.clone(), scope.clone(), depth.clone(), @@ -17370,17 +17214,17 @@ pub fn emit_typed_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), + v1_rt::concat(" if ".to_string(), field_guards), " && ".to_string(), ), - arm_guard_str.clone(), + arm_guard_str, ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat(" if ".to_string(), field_guards) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + v1_rt::concat(" if ".to_string(), arm_guard_str) } else { "".to_string() } @@ -17395,7 +17239,7 @@ pub fn emit_typed_match_arm( if (variant_parent_from_binding_kind(body_binding_kind.clone()) != None) { emit_var_ref( body_name, - body_binding_kind.clone(), + body_binding_kind, Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), @@ -17407,7 +17251,7 @@ pub fn emit_typed_match_arm( ) } else { emit_typed_expr( - arm_b.clone(), + arm_b, registry.clone(), scope.clone(), depth.clone(), @@ -17418,7 +17262,7 @@ pub fn emit_typed_match_arm( } } _ => emit_typed_expr( - arm_b.clone(), + arm_b, registry.clone(), scope.clone(), depth.clone(), @@ -17430,10 +17274,10 @@ pub fn emit_typed_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat.clone(), - rc_analysis.clone(), + arm_pat, + rc_analysis, shared_types.clone(), - si.clone(), + si, emit_info.clone(), ); v1_rt::concat( @@ -17578,13 +17422,13 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name(scope.type_env.clone(), struct_name) { + match lookup_type_by_name((*scope.type_env).clone(), struct_name) { Some(struct_node) => match find_child_named( - struct_node.clone(), + struct_node, field_name, (*scope.type_env).clone().source_indices.clone(), ) { - Some(field_node) => Some(resolved_type(field_node.clone())), + Some(field_node) => Some(resolved_type(field_node)), None => None, }, None => None, @@ -17626,7 +17470,7 @@ pub fn rust_record_field_needs_box( ) -> bool { match rust_struct_field_type_node(scope.clone(), struct_name, field_name) { Some(field_type) => needs_box_wrapping( - field_type.clone(), + field_type, emit_info.recursive_type_set.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), @@ -17679,9 +17523,9 @@ pub fn is_already_optional( let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); - let f = field_access_field_at(texpr.clone(), si.clone()); + let f = field_access_field_at(texpr.clone(), si); match (*texpr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -17690,7 +17534,7 @@ pub fn is_already_optional( .. } => { if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) - && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() + && (variant_parent_from_binding_kind(binding_kind).as_deref() == Some("Optional".to_string()).as_deref())) { true @@ -17698,11 +17542,11 @@ pub fn is_already_optional( if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { - match texpr.inferred.clone().as_deref().cloned() { + match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } - _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { + _ => match v1_rt::map_get(&scope.locals.clone(), n) { Some(binding) => { ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) @@ -17718,9 +17562,9 @@ pub fn is_already_optional( .. } => match tn { Some(name) => { - ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) + ((parent.as_deref() == Some("Optional".to_string()).as_deref()) && ((name.clone() == "Present".to_string()) - || (name.clone() == "Absent".to_string()))) + || (name == "Absent".to_string()))) } None => false, }, @@ -17729,7 +17573,7 @@ pub fn is_already_optional( .. } => { let b = field_access_base(texpr.clone()); - let summary_says_optional = match fa_summary.clone() { + let summary_says_optional = match fa_summary { Some(fs) => match fs.value_shape.clone() { FieldValueShape::OptionalValue => true, _ => false, @@ -17739,11 +17583,11 @@ pub fn is_already_optional( if summary_says_optional { true } else { - match b.inferred.clone().as_deref().cloned() { + match (*b.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. }) => { - let resolved_base = base_type.clone(); + let resolved_base = base_type; if is_optional_struct_field( emit_info, authored_name_at( @@ -17754,7 +17598,7 @@ pub fn is_already_optional( ) { true } else { - match texpr.inferred.clone().as_deref().cloned() { + match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17762,7 +17606,7 @@ pub fn is_already_optional( } } } - _ => match texpr.inferred.clone().as_deref().cloned() { + _ => match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17771,7 +17615,7 @@ pub fn is_already_optional( } } } - _ => match texpr.inferred.clone().as_deref().cloned() { + _ => match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17794,11 +17638,11 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if (field_child.inferred.clone() != None) { + if ((*field_child.inferred).clone() != None) { { let field_type = resolved_type(field_child.clone()); - let ft_is_type_var = if (field_type.inferred.clone() != None) { - is_type_variable(field_type.inferred.clone().clone().unwrap()) + let ft_is_type_var = if ((*field_type.inferred).clone() != None) { + is_type_variable((*field_type.inferred).clone().clone().unwrap()) } else { false }; @@ -17815,48 +17659,42 @@ pub fn lookup_struct_field_type_name( None => None, }; match direct.clone() { - Some(_) => direct.clone(), + Some(_) => direct, None => match variant_name { - Some(vn) => { - match find_child_named(struct_node.clone(), vn.clone(), source_indices.clone()) - { - Some(variant_child) => match find_child_named( - variant_child.clone(), - field_name.clone(), - source_indices.clone(), - ) { - Some(field_child) => { - if (field_child.inferred.clone() != None) { + Some(vn) => match find_child_named(struct_node.clone(), vn, source_indices.clone()) + { + Some(variant_child) => match find_child_named( + variant_child, + field_name.clone(), + source_indices.clone(), + ) { + Some(field_child) => { + if ((*field_child.inferred).clone() != None) { + { + let field_type = resolved_type(field_child); + let ft_is_type_var = if ((*field_type.inferred).clone() != None) { - let field_type = resolved_type(field_child.clone()); - let ft_is_type_var = - if (field_type.inferred.clone() != None) { - is_type_variable( - field_type.inferred.clone().clone().unwrap(), - ) - } else { - false - }; - if ((field_type.ident_span.clone() != None) - && !ft_is_type_var.clone()) - { - Some(authored_name_at( - source_indices.clone(), - field_type.clone(), - )) - } else { - None - } + is_type_variable( + (*field_type.inferred).clone().clone().unwrap(), + ) + } else { + false + }; + if ((field_type.ident_span.clone() != None) && !ft_is_type_var) + { + Some(authored_name_at(source_indices.clone(), field_type)) + } else { + None } - } else { - None } + } else { + None } - None => None, - }, + } None => None, - } - } + }, + None => None, + }, None => None, }, } @@ -17892,7 +17730,7 @@ pub fn emit_field_value_with_context( (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { - Some(_) => node_lookup.clone(), + Some(_) => node_lookup, None => { if (struct_node.ident_span.clone() != None) { match lookup_emit_type_summary( @@ -17920,15 +17758,15 @@ pub fn emit_field_value_with_context( variant_name.clone(), et.clone(), ) { - Some(et.clone()) + Some(et) } else { - pe.clone() + pe } } - None => pe.clone(), + None => pe, }; let raw = emit_typed_record_lit( - tn.clone(), + tn, inner_fields, corrected_parent.clone(), resolved_type(field_value.clone()), @@ -17938,12 +17776,12 @@ pub fn emit_field_value_with_context( shared_types.clone(), emit_info.clone(), ); - let rc_name = match corrected_parent.clone() { - Some(en) => en.clone(), - None => variant_name.clone(), + let rc_name = match corrected_parent { + Some(en) => en, + None => variant_name, }; if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name.clone())) + && v1_rt::set_contains(&shared_types, rc_name)) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -18024,7 +17862,7 @@ pub fn find_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) <= 1) { - match candidates.clone().first().cloned() { + match candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -18059,13 +17897,13 @@ pub fn find_struct_name_by_fields( __result }); if ((typed_candidates.clone().len() as i64) == 1) { - match typed_candidates.clone().first().cloned() { + match typed_candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } } else { match Rc::new({ - let mut __sorted: Vec<_> = candidates.clone().iter().cloned().collect(); + let mut __sorted: Vec<_> = candidates.iter().cloned().collect(); __sorted.sort_by(|a: &Rc, b: &Rc| { let __ka = (|c: Rc| c.name.clone())(a.clone()); let __kb = (|c: Rc| c.name.clone())(b.clone()); @@ -18092,7 +17930,7 @@ pub fn find_unique_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) == 1) { - match candidates.clone().first().cloned() { + match candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -18121,7 +17959,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { - Some(sn) => Some(sn.clone()), + Some(sn) => Some(sn), None => { let rt_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -18148,7 +17986,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( - field_init_node_value(f.clone()), + field_init_node_value(f), registry.clone(), scope.clone(), depth.clone(), @@ -18194,7 +18032,7 @@ pub fn emit_typed_record_lit( " {\n ".to_string(), ), emit_ident( - fname0.clone(), + fname0, RenderTarget::Rust, ), ), @@ -18204,8 +18042,7 @@ pub fn emit_typed_record_lit( ), ",\n}".to_string(), ); - if v1_rt::set_contains(&shared_types, r_sn.clone()) - { + if v1_rt::set_contains(&shared_types, r_sn) { v1_rt::concat( v1_rt::concat( "Rc::new(".to_string(), @@ -18248,7 +18085,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); - match fval.inferred.clone().as_deref().cloned() { + match (*fval.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => v1_rt::rc_map_insert( @@ -18317,7 +18154,7 @@ pub fn emit_typed_record_lit( ), "\n}".to_string(), ); - if v1_rt::set_contains(&shared_types, resolved_sn.clone()) { + if v1_rt::set_contains(&shared_types, resolved_sn) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), struct_lit), ")".to_string(), @@ -18368,7 +18205,7 @@ pub fn emit_typed_record_lit( { let resolved_struct = (*resolve_node( resolved_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) .resolved) @@ -18388,7 +18225,7 @@ pub fn emit_typed_record_lit( ) { Some(canonical) => { if (canonical.clone() != tn.clone()) { - canonical.clone() + canonical } else { tn.clone() } @@ -18410,10 +18247,10 @@ pub fn emit_typed_record_lit( si.clone(), ); let effective_parent = match context_lookup { - Some(context_parent) => Some(context_parent.clone()), + Some(context_parent) => Some(context_parent), None => { - let rt_is_type_var = if (resolved_type.inferred.clone() != None) { - is_type_variable(resolved_type.inferred.clone().clone().unwrap()) + let rt_is_type_var = if ((*resolved_type.inferred).clone() != None) { + is_type_variable((*resolved_type.inferred).clone().clone().unwrap()) } else { false }; @@ -18428,7 +18265,7 @@ pub fn emit_typed_record_lit( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { parent_enum.clone() } @@ -18525,19 +18362,19 @@ pub fn emit_typed_record_lit( } else { match effective_parent.clone() { Some(resolved_parent_enum) => v1_rt::concat( - v1_rt::concat(resolved_parent_enum.clone(), "::".to_string()), + v1_rt::concat(resolved_parent_enum, "::".to_string()), rust_tn, ), None => ctor_name.clone(), } }; - if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) + if ((optional_variant && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { Some(f) => { let inner = emit_typed_expr( - field_init_node_value(f.clone()), + field_init_node_value(f), registry.clone(), scope.clone(), depth.clone(), @@ -18556,19 +18393,19 @@ pub fn emit_typed_record_lit( if ((fields.clone().len() as i64) == 0) { { let host_freemonoid_carrier = - authored_name_at(si.clone(), resolved_type.clone()); + authored_name_at(si, resolved_type.clone()); match rust_seed_host_freemonoid_empty( host_freemonoid_carrier, emit_info.corpus_repr.clone(), ) { - Some(grounded) => grounded.clone(), + Some(grounded) => grounded, None => v1_rt::concat(display_tn, " {}".to_string()), } } } else { { - let variant_summary_name = match effective_parent.clone() { - Some(parent) => variant_summary_key(parent.clone(), tn.clone()), + let variant_summary_name = match effective_parent { + Some(parent) => variant_summary_key(parent, tn), None => ctor_name.clone(), }; let is_positional_ctor = (((fields.clone().len() as i64) == 1) @@ -18582,7 +18419,7 @@ pub fn emit_typed_record_lit( if is_positional_ctor { match fields.clone().first().cloned() { Some(f) => { - let f_value = field_init_node_value(f.clone()); + let f_value = field_init_node_value(f); let val_str = emit_field_value_with_context( f_value.clone(), resolved_type.clone(), @@ -18596,25 +18433,25 @@ pub fn emit_typed_record_lit( ); let needs_wrap = (is_optional_struct_field( emit_info.clone(), - variant_summary_name.clone(), + variant_summary_name, "0".to_string(), ) && (is_already_optional( - f_value.clone(), + f_value, emit_info.clone(), scope.clone(), ) == false)); - let field_val = if needs_wrap.clone() { + let field_val = if needs_wrap { v1_rt::concat( - v1_rt::concat("Some(".to_string(), val_str.clone()), + v1_rt::concat("Some(".to_string(), val_str), ")".to_string(), ) } else { - val_str.clone() + val_str }; v1_rt::concat( v1_rt::concat( v1_rt::concat(display_tn, "(".to_string()), - field_val.clone(), + field_val, ), ")".to_string(), ) @@ -18765,7 +18602,7 @@ pub fn emit_typed_record_lit( if all_defaultable { Rc::new({ let mut __result = Vec::new(); - for fname in missing.clone().iter().cloned() { + for fname in missing.iter().cloned() { __result.extend((*if is_optional_struct_field(emit_info.clone(), variant_summary_name.clone(), fname.clone()) { Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { @@ -18787,7 +18624,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18807,7 +18644,7 @@ pub fn emit_typed_record_lit( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - si.clone(), + si, ); let has_unused = ((unused.len() as i64) > 0); if (is_struct && has_unused) { @@ -18837,7 +18674,7 @@ pub fn emit_typed_record_lit( "\n}".to_string(), ); if (ctor_alias_resolved - && v1_rt::set_contains(&shared_types, ctor_name.clone())) + && v1_rt::set_contains(&shared_types, ctor_name)) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), @@ -18925,7 +18762,7 @@ pub fn emit_typed_bin_op( let r_optional = is_optional_typed_expr(right.clone()); if (l_optional.clone() || r_optional.clone()) { { - let l_cmp = if l_optional.clone() { + let l_cmp = if l_optional { v1_rt::concat(l_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18939,7 +18776,7 @@ pub fn emit_typed_bin_op( ").as_deref()".to_string(), ) }; - let r_cmp = if r_optional.clone() { + let r_cmp = if r_optional { v1_rt::concat(r_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18961,7 +18798,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_cmp), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -18985,7 +18822,7 @@ pub fn emit_typed_bin_op( ), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -19017,7 +18854,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str.clone(), + op_str, ), " &".to_string(), ), @@ -19034,7 +18871,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -19051,7 +18888,7 @@ pub fn emit_typed_bin_op( } pub fn is_optional_typed_expr(e: Rc) -> bool { - match e.inferred.clone().as_deref().cloned() { + match (*e.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -19082,13 +18919,13 @@ pub fn is_string_typed_expr( e: Rc, source_indices: Rc>>, ) -> bool { - match e.inferred.clone().as_deref().cloned() { + match (*e.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); let inner = if is_optional { - with_required_cardinality(rt.clone()) + with_required_cardinality(rt) } else { - rt.clone() + rt }; is_rust_string_like(inner, source_indices) } @@ -19145,7 +18982,7 @@ pub fn emit_typed_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.clone().iter().cloned() { + for p in fmt_parts.iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -19166,7 +19003,7 @@ pub fn emit_typed_string_interp( ) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); emit_rust_host_to_dag_string_via_seam( v1_rt::concat( v1_rt::concat( @@ -19197,9 +19034,9 @@ pub fn typed_interp_format_part( match (*part).clone() { StringPart::Text { value: v, .. } => { let escaped = if has_interpolations { - escape_rust_interp_text(v.clone()) + escape_rust_interp_text(v) } else { - escape_string_literal_body(v.clone()) + escape_string_literal_body(v) }; Rc::new(InterpPart { format_segment: escaped, @@ -19208,15 +19045,7 @@ pub fn typed_interp_format_part( } StringPart::Interpolation { expr: e, .. } => Rc::new(InterpPart { format_segment: "{}".to_string(), - arg_expr: emit_typed_expr( - e.clone(), - registry, - scope, - depth, - shared_types, - emit_info, - 1024, - ), + arg_expr: emit_typed_expr(e, registry, scope, depth, shared_types, emit_info, 1024), }), } } @@ -19263,7 +19092,7 @@ pub fn emit_tco_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -19279,7 +19108,7 @@ pub fn emit_tco_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -19296,8 +19125,8 @@ pub fn emit_tco_init_block_stmts( let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -19352,13 +19181,13 @@ pub fn emit_tco_init_stmt( if is_param { v1_rt::concat( v1_rt::concat( - v1_rt::concat(emit_ident(n.clone(), RenderTarget::Rust), " = ".to_string()), + v1_rt::concat(emit_ident(n, RenderTarget::Rust), " = ".to_string()), val_str, ), ";".to_string(), ) } else { - emit_let_binding(n.clone(), val_str, RenderTarget::Rust) + emit_let_binding(n, val_str, RenderTarget::Rust) } } _ => emit_typed_expr( @@ -19413,7 +19242,7 @@ pub fn emit_rust_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), + (*frame.expr).clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -19450,9 +19279,9 @@ pub fn emit_rust_tco_if( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19475,7 +19304,7 @@ pub fn emit_rust_tco_if( match e { Some(eb) => { let else_str = emit_typed_tco_expr( - eb.clone(), + eb, fn_name.clone(), params.clone(), registry.clone(), @@ -19542,7 +19371,7 @@ pub fn freemonoid_tco_empty_branch_body( ) -> String { match empty_arm { Some(ea) => emit_typed_tco_expr( - arm_body(ea.clone()), + arm_body(ea), fn_name, params, registry, @@ -19558,14 +19387,14 @@ pub fn freemonoid_tco_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_tco_expr( - arm_body(wa.clone()), + arm_body(wa), fn_name, params, registry, @@ -19601,7 +19430,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind.clone()), + v1_rt::concat("let ".to_string(), head_bind), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -19609,14 +19438,14 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind.clone()), + v1_rt::concat("let ".to_string(), tail_bind), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; v1_rt::concat( v1_rt::concat(head_let, tail_let), emit_typed_tco_expr( - arm_body(ca.clone()), + arm_body(ca), fn_name, params, registry, @@ -19634,14 +19463,14 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_tco_expr( - arm_body(wa.clone()), + arm_body(wa), fn_name, params, registry, @@ -19686,7 +19515,7 @@ pub fn emit_native_freemonoid_tco_match( ); let nonempty_body = freemonoid_tco_nonempty_branch_body( cons_arm, - catchall.clone(), + catchall, si, fn_name.clone(), params.clone(), @@ -19707,11 +19536,11 @@ pub fn emit_native_freemonoid_tco_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body.clone(), + empty_body, ), " } else { ".to_string(), ), - nonempty_body.clone(), + nonempty_body, ), " } }".to_string(), ) @@ -19729,8 +19558,8 @@ pub fn emit_rust_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19740,7 +19569,7 @@ pub fn emit_rust_tco_match( emit_info.clone(), 1024, ); - let tco_scrut_type = match s.inferred.clone().as_deref().cloned() { + let tco_scrut_type = match (*s.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -19749,7 +19578,7 @@ pub fn emit_rust_tco_match( .clone() .source_indices .clone(), - with_required_cardinality(rt.clone()), + with_required_cardinality(rt), ) } else { authored_name_at( @@ -19757,7 +19586,7 @@ pub fn emit_rust_tco_match( .clone() .source_indices .clone(), - rt.clone(), + rt, ) } } @@ -19784,11 +19613,11 @@ pub fn emit_rust_tco_match( "".to_string() }; if (native_tco_fm.clone() != "".to_string()) { - native_tco_fm.clone() + native_tco_fm } else { { let rc_match = analyze_rc_match( - s.clone(), + s, arm_list.clone(), tco_scrut_type.clone(), shared_types.clone(), @@ -19817,14 +19646,14 @@ pub fn emit_rust_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let tco_needs_as_str = (all_arms_are_string_lit(arm_list.clone()) - && ((arm_list.clone().len() as i64) > 0)); + && ((arm_list.len() as i64) > 0)); if rc_match.needs_option_deref.clone() { v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -19846,7 +19675,7 @@ pub fn emit_rust_tco_match( "match ".to_string(), apply_type_template1( sharing.deref_clone.clone(), - scrut_str.clone(), + scrut_str, ), ), " {\n".to_string(), @@ -19861,7 +19690,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_str() {\n".to_string(), ), arms_str, @@ -19872,7 +19701,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), arms_str, @@ -19903,14 +19732,14 @@ pub fn emit_rust_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), + (*frame.expr).clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19962,15 +19791,15 @@ pub fn emit_rust_tco_let( }; let next_scope = extend_scope( frame.scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { Some(b) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_typed_tco_expr( - b.clone(), + b, fn_name, params.clone(), registry.clone(), @@ -20015,9 +19844,9 @@ pub fn emit_rust_tco_block( emit_info.clone(), params.clone(), ); - let last_str = match ss.clone().last().cloned() { + let last_str = match ss.last().cloned() { Some(last_expr) => emit_typed_tco_expr( - last_expr.clone(), + last_expr, fn_name, params.clone(), registry.clone(), @@ -20057,7 +19886,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - frame.expr.clone(), + (*frame.expr).clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20206,7 +20035,7 @@ pub fn emit_typed_tco_match_arm( collect_pattern_string_guards(arm_pat.clone(), Rc::new(vec![]), si.clone()); let arm_guard_str = match arm_g { Some(g) => emit_typed_expr( - g.clone(), + g, registry.clone(), scope.clone(), depth.clone(), @@ -20221,17 +20050,17 @@ pub fn emit_typed_tco_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), + v1_rt::concat(" if ".to_string(), field_guards), " && ".to_string(), ), - arm_guard_str.clone(), + arm_guard_str, ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat(" if ".to_string(), field_guards) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + v1_rt::concat(" if ".to_string(), arm_guard_str) } else { "".to_string() } @@ -20250,10 +20079,10 @@ pub fn emit_typed_tco_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat.clone(), - rc_analysis.clone(), + arm_pat, + rc_analysis, shared_types.clone(), - si.clone(), + si, emit_info.clone(), ); v1_rt::concat( @@ -20300,7 +20129,7 @@ pub fn expr_references_var( match (*node.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), + } => (expr_var_name_at(node.clone(), source_indices) == var_name), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -20440,7 +20269,7 @@ pub fn emit_typed_tco_reassign( }); let ordered_args = Rc::new({ let mut __result = Vec::new(); - for av in filtered_arg_values.clone().iter().cloned() { + for av in filtered_arg_values.iter().cloned() { __result.push(emit_typed_expr( av.clone(), registry.clone(), @@ -20455,7 +20284,7 @@ pub fn emit_typed_tco_reassign( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for p in filtered_params.clone().iter().cloned() { + for p in filtered_params.iter().cloned() { __result.push(emit_ident( param_node_name_at(p.clone(), si.clone()), RenderTarget::Rust, @@ -20502,9 +20331,9 @@ pub fn emit_service_def( env.source_indices.clone(), ); let impl_block = emit_service_impl( - safe_name.clone(), - fallback_transport.clone(), - op_children.clone(), + safe_name, + fallback_transport, + op_children, registry, shared_types, corpus_repr, @@ -20569,14 +20398,12 @@ pub fn emit_service_config_fields( } else { fs.clone() }; - let decls = service_field_decls( - fs.clone(), - language_spec(RenderTarget::Rust).service_fields.clone(), - ); + let decls = + service_field_decls(fs, language_spec(RenderTarget::Rust).service_fields.clone()); if ((decls.clone().len() as i64) == 0) { " // No configuration needed for local binding.\n".to_string() } else { - decls.clone().join(&"".to_string()) + decls.join(&"".to_string()) } } } @@ -20626,7 +20453,7 @@ pub fn emit_service_impl( v1_rt::concat("impl ".to_string(), name.clone()), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), methods_str, ), @@ -20677,7 +20504,7 @@ pub fn emit_service_new_method( None => "".to_string(), }; let base_url_default = if (from_config.clone() != "".to_string()) { - from_config.clone() + from_config } else { if fs.has_rest.clone() { { @@ -20692,7 +20519,7 @@ pub fn emit_service_new_method( else { unreachable!() }; - s.clone() + s } _ => "".to_string(), }, @@ -20702,7 +20529,7 @@ pub fn emit_service_new_method( "".to_string() }; if (from_fallback.clone() != "".to_string()) { - from_fallback.clone() + from_fallback } else { "http://localhost".to_string() } @@ -20711,10 +20538,8 @@ pub fn emit_service_new_method( "".to_string() } }; - let ctors = service_field_ctors( - fs.clone(), - language_spec(RenderTarget::Rust).service_fields.clone(), - ); + let ctors = + service_field_ctors(fs, language_spec(RenderTarget::Rust).service_fields.clone()); let ctors = Rc::new({ let mut __result = Vec::new(); for c in ctors.clone().iter().cloned() { @@ -20736,7 +20561,7 @@ pub fn emit_service_new_method( }), None => ctors.clone(), }; - let inits = ctors.clone().join(&"".to_string()); + let inits = ctors.join(&"".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -20771,14 +20596,14 @@ pub fn emit_auth_source_ctor( ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { Some(variant) => if (variant.clone() == "EnvVar".to_string()) { match source_expr.children.clone().first().cloned() { - Some(fi) => match (*field_init_node_value(fi.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: env_name, .. } = value.as_ref() else { unreachable!() }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" auth_token: std::env::var(\"".to_string(), env_name.clone()), "\").expect(\"missing credential: ".to_string()), env_name.clone()), "\"),\n".to_string()) }, + Some(fi) => match (*field_init_node_value(fi).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: env_name, .. } = value.as_ref() else { unreachable!() }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" auth_token: std::env::var(\"".to_string(), env_name.clone()), "\").expect(\"missing credential: ".to_string()), env_name), "\"),\n".to_string()) }, _ => " auth_token: compile_error!(\"EnvVar.name must be a string literal\"),\n".to_string(), }, None => " auth_token: compile_error!(\"EnvVar requires a name field\"),\n".to_string(), } } else { - v1_rt::concat(v1_rt::concat(" auth_token: compile_error!(\"unsupported CredentialSource variant: ".to_string(), variant.clone()), "\"),\n".to_string()) + v1_rt::concat(v1_rt::concat(" auth_token: compile_error!(\"unsupported CredentialSource variant: ".to_string(), variant), "\"),\n".to_string()) }, None => " auth_token: compile_error!(\"auth_source record literal has no type name\"),\n".to_string(), }, @@ -20796,10 +20621,7 @@ pub fn emit_modifier_doc_from_props( "".to_string() } else { v1_rt::concat( - v1_rt::concat( - "/// Modifiers: ".to_string(), - names.clone().join(&", ".to_string()), - ), + v1_rt::concat("/// Modifiers: ".to_string(), names.join(&", ".to_string())), "\n".to_string(), ) } @@ -20847,7 +20669,7 @@ pub fn emit_operation_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str.clone()) + v1_rt::concat("&self, ".to_string(), params_str) }; let ret_type = render_rust_type( resolved_type(op_node.clone()), @@ -20943,7 +20765,7 @@ pub fn emit_operation_method( ), " ".to_string(), ), - emit_ident(op_text.clone(), RenderTarget::Rust), + emit_ident(op_text, RenderTarget::Rust), ), "(".to_string(), ), @@ -20985,7 +20807,7 @@ pub fn emit_dry_run_branch_from_props( let first_mock = mock_props.clone().first().cloned(); match first_mock { Some(mp) => { - let mock_json = emit_data_value_json(field_init_node_value(mp.clone()), source_indices.clone()); + let mock_json = emit_data_value_json(field_init_node_value(mp), source_indices.clone()); let is_multi_field_conj = ((inferred.connective.clone() == Connective::Conj) && ((inferred.children.clone().len() as i64) > 1)); if is_multi_field_conj { { @@ -21007,8 +20829,8 @@ let prelude = match wire_opt.clone() { v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()) } else { { - let wire_ty = match tn.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => tn.clone(), }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let __rest_wire: ".to_string(), render_rust_type(wire_ty, shared_types, corpus_repr.clone(), source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) @@ -21023,7 +20845,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -let raw = match ch.inferred.clone().as_deref().cloned() { +let raw = match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -21039,7 +20861,7 @@ match ch.return_cardinality.clone() { _ => raw.clone(), } }); } __result }); -let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.clone().iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); +let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); let result_body = v1_rt::concat(v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(log_line, "\n".to_string()), prelude), extract_lines.join(&"\n".to_string())), "\nOk(".to_string()), result_body), ")".to_string()) } @@ -21206,9 +21028,9 @@ pub fn emit_rest_http_method( source_indices: Rc>>, ) -> String { match transport_method(transport, source_indices.clone()) { - Some(m) => match m.inferred.clone().as_deref().cloned() { + Some(m) => match (*m.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - let method_name = expr_var_name_at(m.clone(), source_indices.clone()); + let method_name = expr_var_name_at(m, source_indices.clone()); Rc::new({ let mut __result = Vec::new(); for ch in Rc::new(method_name.chars().map(|c| c as i64).collect::>()) @@ -21244,7 +21066,7 @@ pub fn emit_rest_url_line( v1_rt::concat( v1_rt::concat( "let url = format!(\"{}".to_string(), - escape_string_literal_body(path_str.clone()), + escape_string_literal_body(path_str), ), "\", self.base_url);".to_string(), ) @@ -21283,7 +21105,7 @@ pub fn emit_rest_url_line( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.clone().iter().cloned() { + for p in parts.iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -21316,7 +21138,7 @@ pub fn emit_rest_url_line( ) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21365,7 +21187,7 @@ pub fn emit_rest_auth_line( "self.auth_token.clone()".to_string() } else { match auth_input { - Some(ai) => emit_simple_expr(ai.clone(), RenderTarget::Rust, source_indices.clone()), + Some(ai) => emit_simple_expr(ai, RenderTarget::Rust, source_indices.clone()), None => "compile_error!(\"service config has auth but no auth_input or auth_source\")".to_string(), } }; @@ -21374,8 +21196,8 @@ pub fn emit_rest_auth_line( ExprData::ExprCall { .. } => { let header_name = match auth.children.clone().first().cloned() { Some(arg_node) => match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; s.clone() }, - _ => emit_simple_expr(arg_value(arg_node.clone()), RenderTarget::Rust, source_indices.clone()), + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; s }, + _ => emit_simple_expr(arg_value(arg_node), RenderTarget::Rust, source_indices.clone()), }, None => "x-api-key".to_string(), }; @@ -21391,16 +21213,14 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con transport.clone(), source_indices.clone(), ) { - Some(h) => h.clone(), + Some(h) => h, None => "Authorization".to_string(), }; let token_node = match transport_auth_token(transport.clone(), source_indices.clone()) { - Some(tn) => emit_simple_expr( - tn.clone(), - RenderTarget::Rust, - source_indices.clone(), - ), + Some(tn) => { + emit_simple_expr(tn, RenderTarget::Rust, source_indices.clone()) + } None => "\"\"".to_string(), }; v1_rt::concat( @@ -21471,7 +21291,7 @@ pub fn emit_rest_query_line( v1_rt::concat( v1_rt::concat( "let request = request.query(&[".to_string(), - pairs.clone().join(&", ".to_string()), + pairs.join(&", ".to_string()), ), "]);".to_string(), ) @@ -21498,11 +21318,11 @@ if (((req_strs.clone().len() as i64) == 0) && ((optional_fields.clone().len() as } else { { let body_init = if ((req_strs.clone().len() as i64) > 0) { - v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.clone().join(&", ".to_string())), " });".to_string()) + v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.join(&", ".to_string())), " });".to_string()) } else { "let mut __body = serde_json::json!({});".to_string() }; -let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.clone().iter().cloned() { __result.push({ +let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.iter().cloned() { __result.push({ let fname = field_init_node_name_at(fi.clone(), source_indices.clone()); let fexpr = emit_simple_expr(field_init_node_value(fi.clone()), RenderTarget::Rust, source_indices.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("if let Some(ref __v) = ".to_string(), fexpr.clone()), " { __body[\"".to_string()), fname.clone()), "\"] = serde_json::json!(__v); }".to_string()) @@ -21544,12 +21364,12 @@ pub fn child_from_key( .first() .cloned() { - Some(prop) => match (*field_init_node_value(prop.clone()).expr_data.clone()).clone() { + Some(prop) => match (*field_init_node_value(prop).expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; - Some(s.clone()) + Some(s) } _ => None, }, @@ -21619,18 +21439,16 @@ pub fn operation_response_200_resolved_type( .cloned() { Some(p) => { - let v = field_init_node_value(p.clone()); - match v.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: tn, .. }) => Some(tn.clone()), + let v = field_init_node_value(p); + match (*v.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: tn, .. }) => Some(tn), _ => { - let type_name = authored_name_at( - source_indices.clone(), - normalize_access_type_node(v.clone()), - ); + let type_name = + authored_name_at(source_indices.clone(), normalize_access_type_node(v)); if (type_name.clone() == "".to_string()) { None } else { - lookup_type_by_name(env, type_name.clone()) + lookup_type_by_name(env, type_name) } } } @@ -21650,13 +21468,12 @@ pub fn is_json_wire_declaration_type( } else { { let parts = Rc::new( - n.clone() - .split(&".".to_string()) + n.split(&".".to_string()) .map(|s| s.to_string()) .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone() == "Json".to_string()), + Some(last) => (last == "Json".to_string()), None => false, } } @@ -21717,7 +21534,7 @@ pub fn wire_child_for_segment( .first() .cloned() { - Some(ch) => Some(ch.clone()), + Some(ch) => Some(ch), None => None, } } @@ -21734,11 +21551,8 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match state.node.clone() { - Some(n) => Some(for_each_element_type_node( - n.clone(), - source_indices.clone(), - )), + let next_node = match (*state.node).clone() { + Some(n) => Some(for_each_element_type_node(n, source_indices.clone())), None => None, }; Rc::new(WirePathProjection { @@ -21770,30 +21584,28 @@ pub fn advance_wire_path_projection( }) } } else { - match state.node.clone() { - Some(n) => { - match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { - Some(ch) => Rc::new(WirePathProjection { - expr: v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), state.expr.clone()), - ").".to_string(), - ), - emit_ident( - authored_name_at(source_indices.clone(), ch.clone()), - RenderTarget::Rust, - ), + match (*state.node).clone() { + Some(n) => match wire_child_for_segment(n, seg.clone(), source_indices.clone()) { + Some(ch) => Rc::new(WirePathProjection { + expr: v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), state.expr.clone()), + ").".to_string(), ), - node: Some(resolved_type(ch.clone())), - ok: true, - }), - None => Rc::new(WirePathProjection { - expr: state.expr.clone(), - node: None, - ok: false, - }), - } - } + emit_ident( + authored_name_at(source_indices.clone(), ch.clone()), + RenderTarget::Rust, + ), + ), + node: Some(resolved_type(ch)), + ok: true, + }), + None => Rc::new(WirePathProjection { + expr: state.expr.clone(), + node: None, + ok: false, + }), + }, None => Rc::new(WirePathProjection { expr: state.expr.clone(), node: None, @@ -21948,7 +21760,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "bool".to_string()) { + if (rust_type == "bool".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -22013,8 +21825,8 @@ pub fn emit_from_key_extraction( .to_string() } else { { - let wire_ty = match tn.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => tn.clone(), }; v1_rt::concat( @@ -22046,7 +21858,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -match ch.inferred.clone().as_deref().cloned() { +match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -22063,7 +21875,7 @@ match ch.inferred.clone().as_deref().cloned() { }); let field_names = Rc::new({ let mut __result = Vec::new(); - for ch in children.clone().iter().cloned() { + for ch in children.iter().cloned() { __result.push(emit_ident( authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust, @@ -22075,13 +21887,13 @@ match ch.inferred.clone().as_deref().cloned() { v1_rt::concat( v1_rt::concat( "(".to_string(), - field_names.clone().first().cloned().clone().unwrap(), + field_names.first().cloned().clone().unwrap(), ), ",)".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), field_names.clone().join(&", ".to_string())), + v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string(), ) }; @@ -22107,9 +21919,7 @@ pub fn emit_plain_response_body( ) -> String { { let is_text = match transport_response_format(transport, source_indices.clone()) { - Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) - } + Some(fmt) => (authored_name_at(source_indices.clone(), fmt) == "Text".to_string()), None => false, }; if is_text { @@ -22140,22 +21950,22 @@ pub fn emit_response_code_handling( __result }); if ((response_props.clone().len() as i64) == 0) { - if use_from_key.clone() { + if use_from_key { emit_from_key_extraction( op_node.clone(), source_indices.clone(), - shared_types.clone(), - corpus_repr.clone(), - env.clone(), + shared_types, + corpus_repr, + env, ) } else { - emit_plain_response_body(op_node.clone(), transport.clone(), source_indices.clone()) + emit_plain_response_body(op_node.clone(), transport, source_indices.clone()) } } else { { let arms = Rc::new({ let mut __result = Vec::new(); - for p in response_props.clone().iter().cloned() { + for p in response_props.iter().cloned() { __result.push(emit_response_arm( p.clone(), op_node.clone(), @@ -22215,15 +22025,12 @@ pub fn emit_response_arm( { let prefix = v1_rt::substring(&code_str, 0, 1); v1_rt::concat( - v1_rt::concat( - v1_rt::concat(prefix.clone(), "00..=".to_string()), - prefix.clone(), - ), + v1_rt::concat(v1_rt::concat(prefix.clone(), "00..=".to_string()), prefix), "99".to_string(), ) } } else { - code_str.clone() + code_str } }; if is_success { @@ -22287,7 +22094,7 @@ pub fn emit_exit_code_handling( __result }); if ((exit_props.clone().len() as i64) == 0) { - emit_shell_return(inferred.clone(), source_indices.clone()) + emit_shell_return(inferred, source_indices) } else { { let has_nonzero = { @@ -22304,7 +22111,7 @@ pub fn emit_exit_code_handling( }; let exit_arms = Rc::new({ let mut __result = Vec::new(); - for p in exit_props.clone().iter().cloned() { + for p in exit_props.iter().cloned() { __result.push(emit_exit_arm( p.clone(), inferred.clone(), @@ -22351,7 +22158,7 @@ pub fn emit_exit_arm( } else { code_str.clone() }; - let is_success = (code_str.clone() == "0".to_string()); + let is_success = (code_str == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -22419,7 +22226,7 @@ pub fn emit_shell_call( v1_rt::concat( v1_rt::concat(let_kw, " = std::process::Command::new(".to_string()), emit_shell_argv_element( - first_arg.clone(), + first_arg, optional_params.clone(), corpus_repr.clone(), source_indices.clone(), @@ -22447,15 +22254,9 @@ pub fn emit_shell_call( let arg_lines = if ((argv.clone().len() as i64) > 1) { Rc::new({ let mut __result = Vec::new(); - for arg in Rc::new( - argv.clone() - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ) - .iter() - .cloned() + for arg in Rc::new(argv.iter().cloned().skip(1 as usize).collect::>()) + .iter() + .cloned() { __result.push(v1_rt::concat( v1_rt::concat( @@ -22500,7 +22301,7 @@ pub fn emit_shell_call( __result }); let wd_line = " .current_dir(self.working_dir.as_deref().unwrap_or(\".\"))".to_string(); - if has_stdin.clone() { + if has_stdin { { let stdin_expr = transport_stdin(transport.clone(), source_indices.clone()) .clone() @@ -22509,14 +22310,10 @@ pub fn emit_shell_call( ExprData::ExprVar { binding_kind: _, .. } => emit_ident( - expr_var_name_at(stdin_expr.clone(), source_indices.clone()), - RenderTarget::Rust, - ), - _ => emit_simple_expr( - stdin_expr.clone(), + expr_var_name_at(stdin_expr, source_indices.clone()), RenderTarget::Rust, - source_indices.clone(), ), + _ => emit_simple_expr(stdin_expr, RenderTarget::Rust, source_indices.clone()), }; let spawn_line = " .stdin(std::process::Stdio::piped())\n .stdout(std::process::Stdio::piped())\n .stderr(std::process::Stdio::piped())".to_string(); let spawn_exec = " .spawn()?;".to_string(); @@ -22577,7 +22374,7 @@ pub fn emit_shell_argv_element( unreachable!() }; v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_string_literal_body(s.clone())), + v1_rt::concat("\"".to_string(), escape_string_literal_body(s)), "\"".to_string(), ) } @@ -22614,7 +22411,7 @@ pub fn emit_shell_argv_element( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.clone().iter().cloned() { + for p in parts.iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -22657,23 +22454,23 @@ pub fn emit_shell_argv_element( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(arg.clone(), source_indices.clone()); + let name = expr_var_name_at(arg.clone(), source_indices); let var_name = emit_ident(name.clone(), RenderTarget::Rust); let is_opt = (is_optional_typed_expr(arg.clone()) - || match v1_rt::map_get(&optional_params, name.clone()) { + || match v1_rt::map_get(&optional_params, name) { Some(_) => true, None => false, }); - if is_opt.clone() { + if is_opt { emit_rust_dag_string_to_host_via_seam( - v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), + v1_rt::concat(var_name, ".as_deref().unwrap_or(\"\")".to_string()), corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name, corpus_repr) } } - _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), + _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices), } } @@ -22697,10 +22494,10 @@ pub fn emit_shell_return( Some(channel) => { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr(channel.clone(), is_optional.clone()) + emit_shell_channel_expr(channel, is_optional) } None => { - if (is_product.clone() && ((effective.children.clone().len() as i64) > 1)) { + if (is_product && ((effective.children.clone().len() as i64) > 1)) { { let needs_stderr = { let mut __found = false; @@ -22738,7 +22535,7 @@ pub fn emit_shell_return( __result }); let lines = if (stderr_line.clone() != "".to_string()) { - v1_rt::concat(stderr_line.clone(), "\n".to_string()) + v1_rt::concat(stderr_line, "\n".to_string()) } else { "".to_string() }; @@ -22754,7 +22551,7 @@ pub fn emit_shell_return( { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr("stdout".to_string(), is_optional.clone()) + emit_shell_channel_expr("stdout".to_string(), is_optional) } } } @@ -22792,11 +22589,11 @@ pub fn unwrap_single_field_product(n: Rc) -> Rc { && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { - Some(field_node) => resolved_type(field_node.clone()), - None => n.clone(), + Some(field_node) => resolved_type(field_node), + None => n, } } else { - n.clone() + n } } } @@ -22861,7 +22658,7 @@ pub fn emit_resource_def( let depth = 0; let cap_methods = Rc::new({ let mut __result = Vec::new(); - for c in cap_children.clone().iter().cloned() { + for c in cap_children.iter().cloned() { __result.push(emit_capability_method( c.clone(), shared_types.clone(), @@ -22928,7 +22725,7 @@ pub fn emit_capability_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str.clone()) + v1_rt::concat("&self, ".to_string(), params_str) }; let ret = render_rust_type( resolved_type(cap_node.clone()), @@ -23006,8 +22803,8 @@ pub fn data_def_annotation_is_named_refinement( { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); ((((ann_name.clone() != "".to_string()) - && (annotation.type_annotation.clone() != None)) - && !is_container_type(ann_name.clone())) + && ((*annotation.type_annotation).clone() != None)) + && !is_container_type(ann_name)) && !is_host_text_carrier_type( annotation.clone(), source_indices.clone(), @@ -23031,8 +22828,8 @@ pub fn emit_data_def( let render_type_node = if ((annotation_type_node.children.clone().len() as i64) > 0) { annotation_type_node.clone() } else { - match value.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + match (*value.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => annotation_type_node.clone(), } }; @@ -23044,7 +22841,7 @@ pub fn emit_data_def( RenderTarget::Rust, authored_name_at( (*scope.type_env).clone().source_indices.clone(), - annotation_type_node.clone(), + annotation_type_node, ), ) } else { @@ -23066,31 +22863,28 @@ pub fn emit_data_def( Some(top_value) => { let top_type_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(top_value.clone()), + resolved_type(top_value), ); if (top_type_name.clone() == "".to_string()) { - raw_ty_str.clone() + raw_ty_str } else { - if (raw_ty_str.clone() == "Rc".to_string()) { + if (raw_ty_str == "Rc".to_string()) { v1_rt::concat( - v1_rt::concat( - "Rc>".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("BoundedLattice<".to_string(), top_type_name.clone()), + v1_rt::concat("BoundedLattice<".to_string(), top_type_name), ">".to_string(), ) } } } - None => raw_ty_str.clone(), + None => raw_ty_str, } } else { - raw_ty_str.clone() + raw_ty_str }; let fn_name = to_snake(name); let needs_rc = v1_rt::set_contains( @@ -23118,7 +22912,7 @@ pub fn emit_data_def( value.clone(), (*scope.type_env).clone().source_indices.clone(), ) { - Some(identity_expr) => identity_expr.clone(), + Some(identity_expr) => identity_expr, None => emit_typed_expr( value.clone(), registry, @@ -23144,7 +22938,7 @@ pub fn emit_data_def( ), "() -> ".to_string(), ), - ty_str.clone(), + ty_str, ), " { ".to_string(), ), @@ -23163,10 +22957,10 @@ pub fn emit_data_def( depth, shared_types.clone(), emit_info.clone(), - needs_rc.clone(), + needs_rc, ); let kw = rust_items().func_keyword.clone(); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str.clone()), "| c.clone())\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str), "| c.clone())\n".to_string()), "}".to_string()) } } } @@ -23191,7 +22985,7 @@ pub fn rust_nominal_identity_data_expr( let symbol_name = expr_var_name_at(value.clone(), source_indices.clone()); Some(v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_name.clone(), "(\"".to_string()), + v1_rt::concat(type_name, "(\"".to_string()), escape_string_literal_body(symbol_name), ), "\".to_string())".to_string(), @@ -23255,9 +23049,9 @@ pub fn emit_data_def_body( (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => match lattice_value.clone() { + None => match lattice_value { Some(lattice) => field_value_by_name( - lattice.clone(), + lattice, "join".to_string(), (*scope.type_env).clone().source_indices.clone(), ), @@ -23310,7 +23104,7 @@ pub fn emit_data_def_body( (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( - n.clone(), + n, registry.clone(), scope.clone(), depth.clone(), @@ -23323,7 +23117,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23455,7 +23249,7 @@ pub fn emit_data_def_body( emit_info.clone(), 1024, ); - v1_rt::concat(" ".to_string(), val_str.clone()) + v1_rt::concat(" ".to_string(), val_str) } } } else { @@ -23481,14 +23275,14 @@ pub fn emit_data_def_body( ); match effective_variant_parent( vname.clone(), - bk.clone(), - value.inferred.clone(), + bk, + (*value.inferred).clone(), emit_info.clone(), (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( - vname.clone(), - enum_name.clone(), + vname, + enum_name, shared_types.clone(), emit_info.corpus_repr.clone(), ), @@ -23502,7 +23296,7 @@ pub fn emit_data_def_body( } else { "".to_string() }; - let wrap_end = if (needs_rc.clone() && !is_already_wrapped.clone()) { + let wrap_end = if (needs_rc.clone() && !is_already_wrapped) { ")".to_string() } else { "".to_string() @@ -23510,7 +23304,7 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat(" ".to_string(), wrap_start), - val_str.clone(), + val_str, ), wrap_end, ) @@ -23548,7 +23342,7 @@ pub fn emit_test_file( } else { { let filename = module_to_filename(module_name.clone()); - let tests_str = test_fns.clone().join(&"\n\n".to_string()); + let tests_str = test_fns.join(&"\n\n".to_string()); let content = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -23570,7 +23364,7 @@ pub fn emit_test_file( ), " use super::*;\n\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), tests_str, ), @@ -23646,7 +23440,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23678,9 +23472,9 @@ pub fn emit_operation_test( let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { - args_str.clone() + args_str }; - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent.clone()), "assert!(result.is_ok(), \"".to_string()), struct_name.clone()), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent), "assert!(result.is_ok(), \"".to_string()), struct_name), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) } } @@ -23692,11 +23486,11 @@ pub fn emit_rust_default_value( let type_name = authored_name_at(source_indices, param_node_type_expr(param)); match lookup_checkpoint(RenderTarget::Rust, type_name.clone()) { Some(cp) => match cp.default_expr.clone() { - Some(expr) => expr.clone(), + Some(expr) => expr, None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name.clone(), + type_name, ), "\")".to_string(), ), @@ -23704,7 +23498,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name.clone(), + type_name, ), "\")".to_string(), ), @@ -23862,9 +23656,9 @@ pub struct WorkflowFunc { pub fn extract_literal_string(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s.clone()), - LiteralValue::LitBool { value: b, .. } => Some(if b.clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s), + LiteralValue::LitBool { value: b, .. } => Some(if b { "true".to_string() } else { "false".to_string() @@ -23883,7 +23677,7 @@ pub fn resolve_param_default( ) -> Option { match param_node_default_value(param) { Some(dv) => match (*dv.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: _, .. } => extract_literal_string(dv.clone()), + ExprData::ExprLiteral { value: _, .. } => extract_literal_string(dv), ExprData::ExprVar { binding_kind: _, .. } => match lookup_item( @@ -23905,8 +23699,8 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match data_item.body.clone() { - Some(body) => extract_literal_string(body.clone()), + Some(data_item) => match (*data_item.body).clone() { + Some(body) => extract_literal_string(body), None => None, }, None => None, @@ -23956,11 +23750,11 @@ pub fn to_workflow_func( item_name.clone(), ); let ro_params = match v1_rt::map_get(&read_only_params_index, qualified) { - Some(m) => m.clone(), + Some(m) => m, None => v1_rt::rc_empty_set::(), }; Rc::new(WorkflowFunc { - name: item_name.clone(), + name: item_name, module_name: module_name.clone(), params: item.params.clone(), inferred: resolved_type(item.clone()), @@ -23978,7 +23772,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if (item.body.clone() == None) { + if ((*item.body).clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -24026,7 +23820,7 @@ pub fn collect_workflow_funcs( item.clone(), authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), ), registry.clone(), tm.items.clone(), @@ -24046,17 +23840,17 @@ pub fn collect_workflow_funcs( pub fn cli_default_literal_value(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s.clone()), - LiteralValue::LitInt { value: i, .. } => Some((i.clone()).to_string()), - LiteralValue::LitFloat { value: f, .. } => Some(f.clone()), - LiteralValue::LitBool { value: b, .. } => Some(if b.clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s), + LiteralValue::LitInt { value: i, .. } => Some((i).to_string()), + LiteralValue::LitFloat { value: f, .. } => Some(f), + LiteralValue::LitBool { value: b, .. } => Some(if b { emit_keyword("true".to_string(), RenderTarget::Rust) } else { emit_keyword("false".to_string(), RenderTarget::Rust) }), LiteralValue::LitNull => None, - LiteralValue::LitSymbol { value: s, .. } => Some(s.clone()), + LiteralValue::LitSymbol { value: s, .. } => Some(s), }, _ => None, } @@ -24121,7 +23915,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - tm.module.clone(), + (*tm.module).clone(), )), None => "".to_string(), }; @@ -24142,7 +23936,7 @@ pub fn emit_main_rs( for m in modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - m.module.clone(), + (*m.module).clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -24278,12 +24072,12 @@ pub fn emit_main_rs( "".to_string() }; let resource_use = if (resource_imports_str.clone() != "".to_string()) { - v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) + v1_rt::concat(resource_imports_str, "\n".to_string()) } else { "".to_string() }; let svc_use = if (svc_imports_str.clone() != "".to_string()) { - v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) + v1_rt::concat(svc_imports_str, "\n".to_string()) } else { "".to_string() }; @@ -24331,7 +24125,7 @@ pub fn emit_main_rs( has_pipeline.clone(), crate_name.clone(), ); - let diagnostic_fns = if has_pipeline.clone() { + let diagnostic_fns = if has_pipeline { emit_main_diagnostic_fns(crate_name.clone()) } else { "".to_string() @@ -24418,7 +24212,7 @@ pub fn emit_main_mod_uses( { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); let core_mod = module_to_filename("v1.std.core".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) } } else { base @@ -24551,7 +24345,7 @@ pub fn emit_subcommand_enum( "#[derive(Subcommand)]\n".to_string(), "enum Commands {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), variants_str, ), @@ -24627,19 +24421,13 @@ pub fn emit_subcommand_field( emit_cli_param_type_node(param_node_type_expr(param.clone()), source_indices.clone()); let default_attr = match v1_rt::map_get(&resolved_defaults, param_name) { Some(resolved) => v1_rt::concat( - v1_rt::concat( - "#[arg(long, default_value = \"".to_string(), - resolved.clone(), - ), + v1_rt::concat("#[arg(long, default_value = \"".to_string(), resolved), "\")]\n".to_string(), ), None => match param_node_default_value(param.clone()) { - Some(dv) => match cli_default_literal_value(dv.clone()) { + Some(dv) => match cli_default_literal_value(dv) { Some(default_value) => v1_rt::concat( - v1_rt::concat( - "#[arg(long, default_value = \"".to_string(), - default_value.clone(), - ), + v1_rt::concat("#[arg(long, default_value = \"".to_string(), default_value), "\")]\n".to_string(), ), None => "#[arg(long)]\n".to_string(), @@ -24685,8 +24473,8 @@ pub fn emit_cli_param_type_node( { let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname.clone()) { - mapped.clone() + if (mapped.clone() != nname) { + mapped } else { "String".to_string() } @@ -24766,10 +24554,7 @@ pub fn emit_main_fn( } else { v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(parse_line, "\n".to_string()), - dry_run_line.clone(), - ), + v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), dry_run_line), "\n".to_string(), ), result_handling, @@ -24779,7 +24564,7 @@ pub fn emit_main_fn( v1_rt::concat( v1_rt::concat( v1_rt::concat(async_attr, "{\n".to_string()), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_lines, ), @@ -24791,7 +24576,7 @@ pub fn emit_main_fn( pub fn emit_compile_match_arm(crate_name: String) -> String { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) } } @@ -24814,7 +24599,7 @@ pub fn emit_main_pipeline_fns(crate_name: String) -> String { ), emit_resolve_transitively_fn(crate_name.clone(), pipeline_mod.clone()), ), - emit_compile_target_helpers(crate_name.clone(), pipeline_mod.clone(), artifact_mod), + emit_compile_target_helpers(crate_name.clone(), pipeline_mod, artifact_mod), ) } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 988059445b2..ab19ab22d2d 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,20 +45,18 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, - inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, - lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - put_inductive_field, put_inductive_field_cross, record_build_type_env_call, - record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, + build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, + is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, + lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, + rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{ - inferred_to_outputs, item_kind, variant_locals_from_items, -}; +pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -109,13 +107,11 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; -// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. -use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, + FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, + VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -146,18 +142,19 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, - index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, - is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, - is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, - let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, - make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, - make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, - make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, - method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, - node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, - resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, - string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, + is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, + is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, + lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, + make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, + make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, + make_param_node, make_span, make_text_part_node, make_transport_node, map_children, + match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, + param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, + return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, + with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -242,16 +239,20 @@ pub fn infer_block_stmts( None => { break Rc::new(BlockInferState { scope: scope.clone(), - diag_chunks: diag_chunks, - last_type: last_type, - typed_stmts: typed_stmts, + diag_chunks: diag_chunks.clone(), + last_type: last_type.clone(), + typed_stmts: typed_stmts.clone(), }); } Some(stmt) => { let is_last = (remaining_count.clone() == 1); - let stmt_expected = if is_last { expected.clone() } else { None }; - let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = stmt_result.typed.clone(); + let stmt_expected = if is_last.clone() { + expected.clone() + } else { + None + }; + let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected.clone()); + let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = @@ -265,9 +266,9 @@ pub fn infer_block_stmts( .collect::>(), ); let __tco_1 = (remaining_count - 1); - let __tco_2 = next_scope; + let __tco_2 = next_scope.clone(); let __tco_3 = v1_rt::rc_list_push(typed_stmts, stmt_typed.clone()); - let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags); + let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags.clone()); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; remaining_count = __tco_1; @@ -372,19 +373,19 @@ pub fn merge_scope_from_imports( match remaining.clone().first().cloned() { None => { break Rc::new(InferScopeComponents { - svc_registry: svc_registry, - svc_locals: svc_locals, + svc_registry: svc_registry.clone(), + svc_locals: svc_locals.clone(), }); } Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => { let parent_result = typed_parent.items.clone().iter().cloned().fold( Rc::new(InferScopeComponents { - svc_registry: svc_registry, - svc_locals: svc_locals, + svc_registry: svc_registry.clone(), + svc_locals: svc_locals.clone(), }), |acc: Rc, titem: Rc| { - if ((titem.transport.clone() != None) + if (((*titem.transport).clone() != None) && ((titem.children.clone().len() as i64) > 0)) { { @@ -397,7 +398,7 @@ pub fn merge_scope_from_imports( c.clone(), ), outputs: inferred_to_outputs( - c.inferred.clone(), + (*c.inferred).clone(), c.span.clone(), env.source_indices.clone(), ), @@ -428,11 +429,11 @@ pub fn merge_scope_from_imports( }) } } else { - if (((((titem.body.clone() != None) + if ((((((*titem.body).clone() != None) && ((titem.params.clone().len() as i64) == 0)) - && (titem.transport.clone() == None)) + && ((*titem.transport).clone() == None)) && (titem.connective.clone() == Connective::NoConnective)) - && (titem.inferred.clone() != None)) + && ((*titem.inferred).clone() != None)) { Rc::new(InferScopeComponents { svc_registry: acc.svc_registry.clone(), @@ -517,8 +518,8 @@ pub fn classify_field_recursion( source_indices: Rc>>, ) -> Option> { { - let type_expr = match field_node.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + let type_expr = match (*field_node.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); @@ -537,7 +538,7 @@ pub fn classify_field_recursion( if is_container_type(field_type_name.clone()) { { let arity = match container_expected_arity(field_type_name.clone()) { - Some(a) => a.clone(), + Some(a) => a, None => 0, }; let value_index = if (arity == 2) { 1 } else { 0 }; @@ -547,7 +548,7 @@ pub fn classify_field_recursion( .get(value_index as usize) .cloned() { - Some(t) => authored_name_at(source_indices.clone(), t.clone()), + Some(t) => authored_name_at(source_indices.clone(), t), None => "".to_string(), }; let is_recursive_element = ((value_type.clone() == parent_name.clone()) @@ -557,9 +558,9 @@ pub fn classify_field_recursion( let elem = if (value_type.clone() == parent_name.clone()) { parent_name.clone() } else { - value_type.clone() + value_type }; - match field_type_name.clone().as_str() { + match field_type_name.as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, element_type: elem, @@ -584,11 +585,11 @@ pub fn classify_field_recursion( match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, - element_type: field_type_name.clone(), + element_type: field_type_name, })), _ => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::DirectRecursion, - element_type: field_type_name.clone(), + element_type: field_type_name, })), } } else { @@ -608,7 +609,7 @@ pub fn collect_fields_inductive( source_indices: Rc>>, ) -> Rc>>>> { fields.iter().cloned().fold( - acc.clone(), + acc, |field_acc: Rc>>>>, field_node: Rc| { match classify_field_recursion( field_node.clone(), @@ -654,9 +655,9 @@ pub fn collect_item_inductive_fields( ), Connective::Conj => collect_fields_inductive( item.children.clone(), - item_name.clone(), + item_name, "".to_string(), - recursive_type_set.clone(), + recursive_type_set, v1_rt::rc_empty_map::>>>(), source_indices.clone(), ), @@ -737,17 +738,15 @@ pub fn namespace_root_from_properties( .first() .cloned() { - Some(ns_prop) => { - match (*field_init_node_value(ns_prop.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitStr { value: root, .. } = value.as_ref() else { - unreachable!() - }; - root.clone() - } - _ => name, + Some(ns_prop) => match (*field_init_node_value(ns_prop).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitStr { value: root, .. } = value.as_ref() else { + unreachable!() + }; + root } - } + _ => name, + }, None => name, } } @@ -773,53 +772,66 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) { - Some(authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), - )) + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent, + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), + )) + } else { + None + } } else { None } - } else { - None } + None => None, } - None => None, - }, + } None => None, } } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup -// via the binding edge — replaced by regen's true emission of variant_owner_node -// in the convergence commit. +pub fn variant_owner_node_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(owner) => { - if owner.connective.clone() == Connective::Disj - && has_child_named( - owner.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) - { - Some(owner) - } else { - None + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(owner) => { + let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); + if owner_is_coproduct { + if has_child_named( + owner.clone(), + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(owner) + } else { + None + } + } else { + None + } } + None => None, } - None => None, - }, + } None => None, } } @@ -827,7 +839,7 @@ pub fn variant_owner_node(scope: Rc, name: String) -> Option, name: String) -> Rc { match lookup_variant_parent_enum(scope.clone(), name.clone()) { Some(parent_enum) => Rc::new(VarBindingKind::VariantValueBinding { - parent_enum: parent_enum.clone(), + parent_enum: parent_enum, }), None => match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(_) => { @@ -842,45 +854,6 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, - name: String, - scope_enum: String, - expected: Option>, -) -> Option { - match expected { - Some(exp_node) => { - let exp_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), - exp_node.clone(), - ); - if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) - && (exp_name.clone() != name.clone())) - { - match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { - Some(exp_type) => { - if ((exp_type.connective.clone() == Connective::Disj) - && has_child_named( - exp_type.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - )) - { - Some(exp_name.clone()) - } else { - None - } - } - None => None, - } - } else { - None - } - } - None => None, - } -} - pub fn inference_error( message: String, span: Rc, @@ -911,7 +884,15 @@ pub fn type_mismatch_error( ) } -// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) +pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -919,32 +900,30 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { - if (expected.return_cardinality.clone() != Cardinality::CardOptional) { - return false; - } let expected_resolved = - match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { - Some(resolved) => resolved.clone(), + match lookup_type_for(env, with_required_cardinality(expected.clone())) { + Some(resolved) => resolved, None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = - (expected_resolved.connective.clone() == Connective::Disj); - let got_shape = node_type_shape(got.clone(), source_indices.clone()); - let got_is_string = (got_shape == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); + let expected_is_optional_coproduct = ((expected.return_cardinality.clone() + == Cardinality::CardOptional) + && (expected_resolved.connective.clone() == Connective::Disj)); + let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) + == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - if (ft.return_cardinality.clone() != Cardinality::CardOptional) { - return false; + { + let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { + Some(resolved) => resolved, + None => with_required_cardinality(ft.clone()), + }; + ((ft.return_cardinality.clone() == Cardinality::CardOptional) + && (inner.connective.clone() == Connective::Disj)) } - let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -952,17 +931,14 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { Some(direct) => direct.children.clone(), - // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), - // no name round-trip, no whole-env scan fallback. Regen replaces - // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -984,37 +960,6 @@ pub fn record_lit_expected_fields( } } -pub fn record_lit_variant_fields_from_visible_env( - env: Rc, - variant_name: String, - module_name: String, -) -> Rc>> { - let source_indices = env.source_indices.clone(); - let visible = flatten_visible_bindings(env.clone()); - for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { - let node = expand_type_for_field_access( - binding.resolved.clone(), - env.clone(), - module_name.clone(), - ); - if (node.connective.clone() == Connective::Disj) { - for arm in node.children.clone().iter().cloned() { - let arm_name = authored_name_at(source_indices.clone(), arm.clone()); - if (arm_name == variant_name.clone()) { - let expanded = - expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); - if (expanded.connective.clone() == Connective::Conj) { - return expanded.children.clone(); - } else { - return arm.children.clone(); - } - } - } - } - } - Rc::new(vec![]) -} - pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -1024,34 +969,34 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { - Some(exp.clone()) + Some(exp) } else { - match exp.inferred.clone().as_deref().cloned() { + match (*exp.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), expanded.clone(), - ) == tn.clone()) + ) == tn) { - Some(expanded.clone()) + Some(expanded) } else { None } } _ => { - let rt = resolved_type(exp.clone()); + let rt = resolved_type(exp); if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), rt.clone(), - ) == tn.clone()) + ) == tn) { - Some(rt.clone()) + Some(rt) } else { None } @@ -1092,15 +1037,17 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - != tn.clone()) + if (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + exp.clone(), + ) != tn) { None } else { if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for(scope.type_env.clone(), exp.clone()) { + match lookup_type_for((*scope.type_env).clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1109,7 +1056,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1134,8 +1081,7 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -1146,15 +1092,15 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { .return_cardinality .clone(), uses: sf.uses.clone(), - body: sf.body.clone(), - transport: sf.transport.clone(), + body: (*sf.body).clone(), + transport: (*sf.transport).clone(), properties: sf.properties.clone(), - type_annotation: sf.type_annotation.clone(), + type_annotation: (*sf.type_annotation).clone(), is_self_recursive: sf.is_self_recursive.clone(), has_non_tail_self_call: sf .has_non_tail_self_call .clone(), - match_pattern: sf.match_pattern.clone(), + match_pattern: (*sf.match_pattern).clone(), expr_data: sf.expr_data.clone(), ident: None, })); @@ -1185,7 +1131,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1195,20 +1141,24 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { + match (*arg_value(receiver_arg).inferred) + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( - receiver_type.clone(), - scope.type_env.clone().source_indices.clone(), + receiver_type, + (*scope.type_env).clone().source_indices.clone(), ), _ => false, } @@ -1218,13 +1168,10 @@ pub fn set_union_other_operand_is_resolved_non_set( other_arg: Rc, scope: Rc, ) -> bool { - match arg_value(other_arg).inferred.clone().as_deref().cloned() { + match (*arg_value(other_arg).inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. - }) => !node_is_set_collection( - other_type.clone(), - scope.type_env.clone().source_indices.clone(), - ), + }) => !node_is_set_collection(other_type, (*scope.type_env).clone().source_indices.clone()), _ => false, } } @@ -1233,15 +1180,15 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, scope.type_env.clone()) { - Some(elem_slot) => Some(child_type_node(elem_slot.clone())), + match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { + Some(elem_slot) => Some(child_type_node(elem_slot)), None => None, } } pub fn set_element_type_is_concrete(elem: Rc) -> bool { - match elem.inferred.clone() { - Some(inf) => !is_type_variable(inf.clone()), + match (*elem.inferred).clone() { + Some(inf) => !is_type_variable(inf), None => true, } } @@ -1285,8 +1232,8 @@ pub fn nominal_call_arg_brand_mismatch( && (formal_name.clone() != actual_name.clone())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) == structural_carrier_template_name(actual.clone(), source_indices.clone()))) - && !is_declared_container_alias_spelling(formal_name.clone())) - && !is_declared_container_alias_spelling(actual_name.clone())) + && !is_declared_container_alias_spelling(formal_name)) + && !is_declared_container_alias_spelling(actual_name)) } } @@ -1306,12 +1253,12 @@ pub fn container_element_nominal_brand_mismatch( Some(formal_ch) => match actual.children.clone().first().cloned() { Some(actual_ch) => { let formal_el = peel_nominal_alias_identity( - child_type_node(formal_ch.clone()), + child_type_node(formal_ch), type_env.clone(), module_name.clone(), ); let actual_el = peel_nominal_alias_identity( - child_type_node(actual_ch.clone()), + child_type_node(actual_ch), type_env.clone(), module_name.clone(), ); @@ -1435,8 +1382,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) .clone() .as_deref() .cloned() @@ -1444,18 +1390,16 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => { - match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) - } + }) => match map_value_type_in_env(receiver_type, (*scope.type_env).clone()) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type) + } else { + with_optional_cardinality(value_type) } - None => resolve_builtin_call_type(func_name.clone()), } - } + None => resolve_builtin_call_type(func_name.clone()), + }, _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1465,8 +1409,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) .clone() .as_deref() .cloned() @@ -1474,21 +1417,19 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => { - match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { - Some(key_type) => { - let lk = list_kernel_ty_from_element(key_type.clone()); - Rc::new(Tier2bBt { - bt: lk.ty.clone(), - kernel_diags: lk.miss_diags.clone(), - }) - } - None => Rc::new(Tier2bBt { - bt: resolve_builtin_call_type(func_name.clone()), - kernel_diags: Rc::new(vec![]), - }), + }) => match map_key_type_in_env(receiver_type, (*scope.type_env).clone()) { + Some(key_type) => { + let lk = list_kernel_ty_from_element(key_type); + Rc::new(Tier2bBt { + bt: (*lk.ty).clone(), + kernel_diags: lk.miss_diags.clone(), + }) } - } + None => Rc::new(Tier2bBt { + bt: resolve_builtin_call_type(func_name.clone()), + kernel_diags: Rc::new(vec![]), + }), + }, _ => Rc::new(Tier2bBt { bt: resolve_builtin_call_type(func_name.clone()), kernel_diags: Rc::new(vec![]), @@ -1502,8 +1443,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) .clone() .as_deref() .cloned() @@ -1511,14 +1451,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env( - receiver_type.clone(), - scope.type_env.clone(), - ) { + }) => match map_value_type_in_env(receiver_type, (*scope.type_env).clone()) + { Some(value_type) => { - let lv = list_kernel_ty_from_element(value_type.clone()); + let lv = list_kernel_ty_from_element(value_type); Rc::new(Tier2bBt { - bt: lv.ty.clone(), + bt: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1547,23 +1485,19 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()) - .inferred + Some(insert_arg) => match (*arg_value(insert_arg).inferred) .clone() .as_deref() .cloned() { - Some(InferredNode::Resolved { node: elem, .. }) => { - Some(elem.clone()) - } + Some(InferredNode::Resolved { node: elem, .. }) => Some(elem), _ => None, }, None => None, } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()) - .inferred + Some(other_arg) => match (*arg_value(other_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1571,10 +1505,10 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: other_type, .. }) => match set_element_type_in_env( - other_type.clone(), - scope.type_env.clone(), + other_type, + (*scope.type_env).clone(), ) { - Some(elem_slot) => Some(child_type_node(elem_slot.clone())), + Some(elem_slot) => Some(child_type_node(elem_slot)), None => None, }, _ => None, @@ -1591,7 +1525,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let union_other_bad = if (func_name.clone() == "set_union".to_string()) { match typed_args.clone().get(1 as usize).cloned() { Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), + other_arg, scope.clone(), ), None => false, @@ -1600,8 +1534,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) .clone() .as_deref() .cloned() @@ -1620,9 +1553,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let elem_mismatch = match recv_elem.clone() { Some(re) => match operand_elem.clone() { Some(oe) => set_element_types_mismatch( - re.clone(), - oe.clone(), - scope.type_env.clone().source_indices.clone(), + re, + oe, + (*scope.type_env).clone().source_indices.clone(), ), None => false, }, @@ -1673,8 +1606,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()) - .inferred + match (*arg_value(receiver_arg).inferred) .clone() .as_deref() .cloned() @@ -1682,14 +1614,14 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match recv_elem.clone() { - Some(_) => receiver_type.clone(), + }) => match recv_elem { + Some(_) => receiver_type, None => match operand_elem.clone() { - Some(element) => { - set_kernel_ty_from_element(element.clone()) - .ty - .clone() - } + Some(element) => (*set_kernel_ty_from_element( + element.clone(), + ) + .ty) + .clone(), None => { resolve_builtin_call_type(func_name.clone()) } @@ -1707,14 +1639,10 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let build_diags = if (func_name.clone() == "set_contains".to_string()) { Rc::new(vec![]) } else { - match operand_elem.clone() { + match operand_elem { Some(element) => { - if ((recv_is_set.clone() && !elem_mismatch.clone()) - && !union_other_bad.clone()) - { - set_kernel_ty_from_element(element.clone()) - .miss_diags - .clone() + if ((recv_is_set && !elem_mismatch) && !union_other_bad) { + set_kernel_ty_from_element(element).miss_diags.clone() } else { Rc::new(vec![]) } @@ -1757,11 +1685,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(key_type) => { - let lk = list_kernel_ty_from_element(key_type.clone()); + let lk = list_kernel_ty_from_element(key_type); Rc::new(MethodPipeFallback { - result_ty: lk.ty.clone(), + result_ty: (*lk.ty).clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1772,11 +1700,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(value_type) => { - let lv = list_kernel_ty_from_element(value_type.clone()); + let lv = list_kernel_ty_from_element(value_type); Rc::new(MethodPipeFallback { - result_ty: lv.ty.clone(), + result_ty: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1818,7 +1746,7 @@ pub fn validate_cast( ) -> Option> { match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { - let source_name = authored_name_at(source_indices, src_node.clone()); + let source_name = authored_name_at(source_indices, src_node); if (source_name.clone() == target_name.clone()) { None } else { @@ -1834,10 +1762,7 @@ pub fn validate_cast( { let msg = v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "invalid cast: ".to_string(), - source_name.clone(), - ), + v1_rt::concat("invalid cast: ".to_string(), source_name), " as ".to_string(), ), target_name.clone(), @@ -1893,7 +1818,7 @@ pub fn inferred_or_error( fallback_span: Rc, ) -> Rc { match result { - Some(inferred) => inferred.clone(), + Some(inferred) => inferred, None => Rc::new(InferredNode::CompilerError { message: fallback_message, span: fallback_span, @@ -1910,14 +1835,12 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - scope.type_env.clone(), - scrutinee_type.clone(), + (*scope.type_env).clone(), + scrutinee_type, )), PatternSubject::PatternDynamic { span: dynamic_span, .. - } => Rc::new(PatternSubject::PatternDynamic { - span: dynamic_span.clone(), - }), + } => Rc::new(PatternSubject::PatternDynamic { span: dynamic_span }), PatternSubject::PatternLookupBlocked => Rc::new(PatternSubject::PatternLookupBlocked), } } @@ -1941,7 +1864,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1969,7 +1892,7 @@ pub fn annotate_pattern_parent_enums( let is_coproduct = (resolved_scrut_node.connective.clone() == Connective::Disj); if is_coproduct { - Some(scrutinee_name.clone()) + Some(scrutinee_name) } else { None } @@ -1982,31 +1905,31 @@ pub fn annotate_pattern_parent_enums( }; let annotated_variant_name = variant_name.clone(); let variant_lookup = lookup_variant_in_type( - resolved_scrut.clone(), + resolved_scrut, variant_name.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); let annotated_bindings = Rc::new({ let mut __result = Vec::new(); - for binding in bindings.clone().iter().cloned() { + for binding in bindings.iter().cloned() { __result.push({ let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -2023,17 +1946,17 @@ pub fn annotate_pattern_parent_enums( match inferred_parent { Some(parent_name) => Rc::new(MatchPattern::VariantPattern { name: annotated_variant_name, - parent_enum: Some(parent_name.clone()), + parent_enum: Some(parent_name), field_bindings: annotated_bindings, }), None => Rc::new(MatchPattern::VariantPattern { - name: variant_name.clone(), + name: variant_name, parent_enum: None, field_bindings: annotated_bindings, }), } } - _ => pattern.clone(), + _ => pattern, } }) } @@ -2045,11 +1968,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), + param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2058,8 +1981,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2077,8 +2000,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2103,8 +2026,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2143,8 +2066,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2165,14 +2088,14 @@ pub fn scope_after_stmt_node( if ((stmt.children.clone().len() as i64) <= 1) { { let val = match stmt.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => stmt.clone(), }; extend_scope( scope.clone(), let_binding_name_at( stmt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2198,8 +2121,8 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - scope.type_env.clone().source_indices.clone(), - resolved_type(n.clone()), + (*scope.type_env).clone().source_indices.clone(), + resolved_type(n), ), _ => "".to_string(), }; @@ -2208,7 +2131,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); + inductive_fields_for((*scope.type_env).clone(), scrut_type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2224,7 +2147,7 @@ pub fn derive_field_provenance( .cloned(); match matching { Some(ind_field) => { - compose_sub_value(scrutinee_provenance.clone(), ind_field.clone()) + compose_sub_value(scrutinee_provenance.clone(), ind_field) } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -2244,9 +2167,9 @@ pub fn extend_scope_with_pattern_node( MatchPattern::Bind { name: n, .. } => Rc::new(PatternScopeResult { scope: extend_scope_match_bound( scope.clone(), - n.clone(), + n, pattern_binding_type(scrutinee_subject.clone()), - scrutinee_provenance.clone(), + scrutinee_provenance, ), diagnostics: Rc::new(vec![]), }), @@ -2268,12 +2191,12 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); let variant_diags = variant_lookup.diagnostics.clone(); - bindings.clone().iter().cloned().fold( + bindings.iter().cloned().fold( Rc::new(PatternScopeResult { scope: scope.clone(), diagnostics: variant_diags, @@ -2281,13 +2204,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2377,7 +2300,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(a); } @@ -2387,7 +2310,7 @@ pub fn extract_fold_init_info( .first() .cloned() { - Some(a) => Some(a.clone()), + Some(a) => Some(a), None => method_args.clone().first().cloned(), }; match init_arg { @@ -2398,9 +2321,9 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - init_result.typed.clone(), + (*init_result.typed).clone(), ia.span.clone(), ia.span.clone(), ), @@ -2427,7 +2350,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2435,9 +2358,9 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2456,9 +2379,7 @@ pub fn derive_element_provenance( .first() .cloned(); match list_field { - Some(f) => { - Rc::new(SubValueRelation::IteratedSubValue { field: f.clone() }) - } + Some(f) => Rc::new(SubValueRelation::IteratedSubValue { field: f }), None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -2498,10 +2419,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2564,8 +2485,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2582,9 +2503,9 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -2606,8 +2527,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2673,8 +2594,11 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), - ar.typed.clone(), + arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + (*ar.typed).clone(), arg.span.clone(), arg.span.clone(), ), @@ -2696,84 +2620,83 @@ pub fn infer_expr( Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: infer_literal_node(lit.clone()), + node: infer_literal_node(lit), })), - span.clone(), + span, )) } ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); Rc::new(InferResult { - typed: make_expr_error_node(kind.clone(), message.clone(), span.clone()), + typed: make_expr_error_node(kind, message, span), diagnostics: Rc::new(vec![]), }) } ExprData::ExprVar { binding_kind: _, .. } => { - let name = - expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let name = expr_var_name_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { - // HAND-PATCH (§1c): the expected-type-as-owner-picker - // is deleted; the binding edge alone names the owner. - // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( - name.clone(), + name, Rc::new(ExprData::ExprVar { binding_kind: Some(Rc::new( VarBindingKind::VariantValueBinding { - parent_enum: scope_enum.clone(), + parent_enum: scope_enum, }, )), }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), - span.clone(), + span, )), None => { let binding_kind = infer_var_binding_kind(scope.clone(), name.clone()); ok_infer(make_named_expr_node( - name.clone(), + name, Rc::new(ExprData::ExprVar { binding_kind: Some(binding_kind), }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), - span.clone(), + span, )) } } } - None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { + None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( - name.clone(), + name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: fsig.inferred.clone(), + node: (*fsig.inferred).clone(), })), span.clone(), - span.clone(), + span, )) } else { ok_infer(make_named_expr_node( - name.clone(), + name, Rc::new(ExprData::ExprVar { binding_kind: Some(Rc::new( VarBindingKind::FunctionValueBinding, @@ -2783,11 +2706,11 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - fsig.inferred.clone(), + (*fsig.inferred).clone(), ), })), span.clone(), - span.clone(), + span, )) } } @@ -2804,13 +2727,10 @@ pub fn infer_expr( typed: err_texpr, diagnostics: Rc::new(vec![inference_error( v1_rt::concat( - v1_rt::concat( - "undefined variable '".to_string(), - name.clone(), - ), + v1_rt::concat("undefined variable '".to_string(), name), "'".to_string(), ), - span.clone(), + span, scope.module_name.clone(), )]), }) @@ -2821,45 +2741,35 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let base_rt = resolved_type(base_typed.clone()); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { + if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) }; - let resolved_base_is_error = if resolved_base.inferred.clone() != None { - is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) + let resolved_base_is_error = if ((*resolved_base.inferred).clone() != None) { + is_compiler_error((*resolved_base.inferred).clone().clone().unwrap()) } else { false }; if resolved_base_is_error { - // HAND-PATCH (debug instrumentation, removed with regen): - // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - format!( - "error type cascade (field '{}' on error-typed base '{}' in {})", - field_name, - authored_name_at( - scope.type_env.clone().source_indices.clone(), - base_typed.clone() - ), - scope.module_name - ), - span.clone(), + "error type cascade".to_string(), + span, ), diagnostics: base_diags, }) @@ -2868,32 +2778,30 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { let field_summary = match field_summary_for_type( - base_rt.clone(), - scope.type_env.clone(), + base_rt, + (*scope.type_env).clone(), field_name.clone(), ) { - Some(s) => Some(s.clone()), + Some(s) => Some(s), None => field_summary_for_type( - resolved_base.clone(), - scope.type_env.clone(), + resolved_base, + (*scope.type_env).clone(), field_name.clone(), ), }; let fa_texpr = make_named_expr_node( - field_name.clone(), + field_name, Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![base_typed.clone()]), - Some(Rc::new(InferredNode::Resolved { - node: field_type.clone(), - })), - span.clone(), + Rc::new(vec![base_typed]), + Some(Rc::new(InferredNode::Resolved { node: field_type })), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2904,23 +2812,23 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); if base_is_type_var { { let fa_texpr = make_named_expr_node( - field_name.clone(), + field_name, Rc::new(ExprData::ExprFieldAccess { summary: Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::StoredField, value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed.clone()]), + Rc::new(vec![base_typed]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), - span.clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2930,25 +2838,25 @@ pub fn infer_expr( } } else { match check_service_field_access_node( - base_rt.clone(), + base_rt, field_name.clone(), scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( - field_name.clone(), + field_name, Rc::new(ExprData::ExprFieldAccess { summary: Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::StoredField, value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed.clone()]), + Rc::new(vec![base_typed]), Some(Rc::new(InferredNode::Resolved { - node: svc_type.clone(), + node: svc_type, })), - span.clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2962,17 +2870,16 @@ pub fn infer_expr( v1_rt::concat( v1_rt::concat( "no field '".to_string(), - field_name.clone(), + field_name, ), "' on type '".to_string(), ), authored_name_at( - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), - resolved_base.clone(), + resolved_base, ), ), "'".to_string(), @@ -2987,8 +2894,8 @@ pub fn infer_expr( diagnostics: v1_rt::concat( base_diags, Rc::new(vec![inference_error( - error_message.clone(), - span.clone(), + error_message, + span, scope.module_name.clone(), )]), ), @@ -3002,11 +2909,13 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = - expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let func_name = expr_call_func_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); + let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -3038,7 +2947,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -3050,22 +2959,22 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type(first_result.typed.clone()); + let first_type = resolved_type((*first_result.typed).clone()); let elem_type = for_each_element_type_node( first_type, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - first_result.typed.clone(), + (*first_result.typed).clone(), elem_type.clone(), scope.clone(), ); let remaining_results = infer_method_args_with_fold( - call_method_name.clone(), - call_method_args.clone(), + call_method_name, + call_method_args, call_fold_info.clone(), call_fold_acc_type.clone(), - elem_type.clone(), + elem_type, call_elem_provenance, scope.clone(), ); @@ -3074,9 +2983,9 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - first_result.typed.clone(), + (*first_result.typed).clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3095,7 +3004,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3109,7 +3018,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3121,7 +3030,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -3157,7 +3066,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3178,11 +3087,11 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), - ar.typed.clone(), + (*ar.typed).clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3190,9 +3099,9 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type(ar.typed.clone()), + resolved_type((*ar.typed).clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.subst.clone(), ) } @@ -3204,9 +3113,12 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -3225,13 +3137,13 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for air in arg_infer_results.clone().iter().cloned() { + for air in arg_infer_results.iter().cloned() { __result.extend((*air.diagnostics.clone()).iter().cloned()); } __result @@ -3239,20 +3151,20 @@ pub fn infer_expr( let typed_arg_nodes = typed_args.clone(); if (sig.clone() != None) { { - let resolved_type = match sig.clone() { + let resolved_type = match sig { Some(s) => substitute_generics( - s.inferred.clone(), + (*s.inferred).clone(), call_subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => error_type(), }; let value_params_for_check = Rc::new({ let mut __result = Vec::new(); - for p in sig_params.clone().iter().cloned() { + for p in sig_params.iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3265,15 +3177,15 @@ pub fn infer_expr( } else { direct_call_arg_mismatch_diags( value_params_for_check, - typed_args.clone(), - call_subst.clone(), - scope.type_env.clone(), + typed_args, + call_subst, + (*scope.type_env).clone(), scope.module_name.clone(), ) }; Rc::new(InferResult { typed: make_named_expr_node( - func_name.clone(), + func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, @@ -3282,7 +3194,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_type, })), - span.clone(), + span, node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat(arg_diags, arg_compat_diags), @@ -3303,34 +3215,33 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) - && call_acc_is_under_resolved) - { - match Rc::new({ - let mut __result = Vec::new(); - for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(a.clone())) { - __result.push(a); + let refined_call_fold_acc_type = + if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) { + match Rc::new({ + let mut __result = Vec::new(); + for a in typed_args.clone().iter().cloned() { + if is_lambda_expr(arg_value(a.clone())) { + __result.push(a); + } } + __result + }) + .first() + .cloned() + { + Some(lambda_arg) => resolved_type(arg_value(lambda_arg)), + None => call_fold_acc_type, } - __result - }) - .first() - .cloned() - { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), - None => call_fold_acc_type.clone(), - } - } else { - call_fold_acc_type.clone() - }; + } else { + call_fold_acc_type + }; let method_resolution = resolve_known_method_node( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3339,31 +3250,32 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let is_known_method = (method_resolution.result_type.clone() != None); + let is_known_method = ((*method_resolution.result_type).clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { { - let receiver = method_receiver.clone(); + let receiver = method_receiver; let remaining = Rc::new( typed_args - .clone() .iter() .cloned() .skip(1 as usize) .collect::>(), ); - let base_result_type = match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) { + let base_result_type = + match (*method_resolution.result_type).clone() { + Some(mt) => mt, + None => error_type(), + }; + let method_tv = if ((*method_resolution.semantics).clone() == None) + { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }) } else { - match (*method_resolution.semantics.clone().clone().unwrap()) + match (*(*method_resolution.semantics).clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3374,8 +3286,7 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3394,11 +3305,10 @@ pub fn infer_expr( __result }); let fold_overrides = - if (call_fold_info.clone() != None) { + if (call_fold_info != None) { fold_override_map( "FoldAccumulator".to_string(), - refined_call_fold_acc_type - .clone(), + refined_call_fold_acc_type, ) } else { empty_override_map() @@ -3408,8 +3318,7 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3417,37 +3326,38 @@ pub fn infer_expr( } } else { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }), } }; - let bridge_result_type = method_tv.ty.clone(); + let bridge_result_type = (*method_tv.ty).clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics.clone() + let returns_receiver_self = if ((*method_resolution.semantics) + .clone() == None) { false } else { - match (*method_resolution.semantics.clone().clone().unwrap()) + match (*(*method_resolution.semantics).clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - } => match at.clone() { - Some(t) => template_return_is_receiver_self(t.clone()), + } => match at { + Some(t) => template_return_is_receiver_self(t), None => false, }, _ => false, @@ -3456,11 +3366,11 @@ pub fn infer_expr( let final_receiver = if ((returns_receiver_self && is_fully_resolved( bridge_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( - first_arg_type.clone(), - scope.type_env.clone().source_indices.clone(), + first_arg_type, + (*scope.type_env).clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3474,28 +3384,28 @@ pub fn infer_expr( })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), - body: receiver.body.clone(), - transport: receiver.transport.clone(), + body: (*receiver.body).clone(), + transport: (*receiver.transport).clone(), properties: receiver.properties.clone(), - type_annotation: receiver.type_annotation.clone(), + type_annotation: (*receiver.type_annotation).clone(), is_self_recursive: receiver.is_self_recursive.clone(), has_non_tail_self_call: receiver .has_non_tail_self_call .clone(), - match_pattern: receiver.match_pattern.clone(), + match_pattern: (*receiver.match_pattern).clone(), expr_data: receiver.expr_data.clone(), ident: None, }) } else { - receiver.clone() + receiver }; let remaining_arg_nodes = Rc::new({ let mut __result = Vec::new(); - for ta in remaining.clone().iter().cloned() { + for ta in remaining.iter().cloned() { __result.push(make_arg_node( arg_name_at( ta.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), arg_value(ta.clone()), span.clone(), @@ -3506,18 +3416,19 @@ pub fn infer_expr( }); Rc::new(InferResult { typed: make_named_expr_node( - func_name.clone(), + func_name, Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics.clone(), + method_semantics: (*method_resolution.semantics) + .clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: bridge_result_type.clone(), + node: bridge_result_type, })), - span.clone(), + span, node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat( @@ -3534,14 +3445,14 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: exp.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: exp, +})), span, node_name_span(texpr.clone())), diagnostics: arg_diags, }) } else { @@ -3549,46 +3460,46 @@ pub fn infer_expr( let empty_map_diags = v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): expected type is not a keyed collection".to_string(), span.clone(), scope.module_name.clone())])); match bare_m { Some(map_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: map_t.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: map_t, +})), span, node_name_span(texpr.clone())), diagnostics: empty_map_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(empty_map_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), + diagnostics: v1_rt::concat(empty_map_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span, scope.module_name.clone())])), }), } } }, None => match bare_m { Some(map_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: map_t.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: map_t, +})), span, node_name_span(texpr.clone())), diagnostics: arg_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), + diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span, scope.module_name.clone())])), }), }, } @@ -3598,14 +3509,14 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: exp.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: exp, +})), span, node_name_span(texpr.clone())), diagnostics: arg_diags, }) } else { @@ -3613,46 +3524,46 @@ match bare_m { let empty_set_diags = v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): expected type is not Set<...>".to_string(), span.clone(), scope.module_name.clone())])); match bare_s { Some(set_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: set_t.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: set_t, +})), span, node_name_span(texpr.clone())), diagnostics: empty_set_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(empty_set_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), + diagnostics: v1_rt::concat(empty_set_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span, scope.module_name.clone())])), }), } } }, None => match bare_s { Some(set_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: set_t.clone(), -})), span.clone(), node_name_span(texpr.clone())), + node: set_t, +})), span, node_name_span(texpr.clone())), diagnostics: arg_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), + diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span, scope.module_name.clone())])), }), }, } @@ -3662,11 +3573,11 @@ match bare_s { { let tier2b = infer_tier2b_builtin_with_kernel_diags( func_name.clone(), - typed_args.clone(), + typed_args, scope.clone(), span.clone(), ); - let bt = tier2b.bt.clone(); + let bt = (*tier2b.bt).clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3675,7 +3586,7 @@ match bare_s { }; Rc::new(InferResult { typed: make_named_expr_node( - func_name.clone(), + func_name, Rc::new(ExprData::ExprCall { call_semantics: call_semantics, descent_evidence: None, @@ -3684,7 +3595,7 @@ match bare_s { Some(Rc::new(InferredNode::Resolved { node: bt, })), - span.clone(), + span, node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat( @@ -3700,8 +3611,7 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if ((binding - .resolved + if (((*binding.resolved) .clone() .params .clone() @@ -3709,7 +3619,7 @@ match bare_s { as i64) > 0) { - Some(binding.resolved.clone()) + Some((*binding.resolved).clone()) } else { None } @@ -3718,43 +3628,42 @@ match bare_s { }; if (callable_local.clone() != None) { { - let callable_type = match callable_local.clone() - { - Some(ct) => ct.clone(), + let callable_type = match callable_local { + Some(ct) => ct, None => error_type(), }; let resolved_type = callable_inferred(callable_type); Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { node: resolved_type, -})), span.clone(), node_name_span(texpr.clone())), +})), span, node_name_span(texpr.clone())), diagnostics: arg_diags, }) } } else { match infer_variant_constructor_call( func_name.clone(), - call_args.clone(), + call_args, span.clone(), node_name_span(texpr.clone()), scope.clone(), ) { - Some(ctor_result) => ctor_result.clone(), + Some(ctor_result) => ctor_result, None => { let type_match = lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), func_name.clone(), ); let resolved_type = match type_match.clone() { - Some(tn) => tn.clone(), + Some(tn) => tn, None => error_type(), }; - let call_diags = match type_match.clone() { + let call_diags = match type_match { Some(_) => Rc::new(vec![]), None => Rc::new(vec![inference_error( v1_rt::concat( @@ -3770,12 +3679,12 @@ match bare_s { )]), }; Rc::new(InferResult { - typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { node: resolved_type, -})), span.clone(), node_name_span(texpr.clone())), +})), span, node_name_span(texpr.clone())), diagnostics: v1_rt::concat(arg_diags, call_diags), }) } @@ -3795,21 +3704,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = recv_result.typed.clone(); + let recv_typed = (*recv_result.typed).clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( resolved_type(recv_typed.clone()), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3820,7 +3729,7 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( @@ -3829,31 +3738,31 @@ match bare_s { scope.clone(), ); let mc_arg_infer_results = infer_method_args_with_fold( - mc_method_name.clone(), - mc_args.clone(), + mc_method_name, + mc_args, fold_info.clone(), fold_acc_type.clone(), - recv_elem_type.clone(), + recv_elem_type, mc_elem_provenance, scope.clone(), ); let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); let mc_arg_diags = Rc::new({ let mut __result = Vec::new(); - for air in mc_arg_infer_results.clone().iter().cloned() { + for air in mc_arg_infer_results.iter().cloned() { __result.extend((*air.diagnostics.clone()).iter().cloned()); } __result }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { @@ -3869,11 +3778,11 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), - None => fold_acc_type.clone(), + Some(lambda_arg) => resolved_type(arg_value(lambda_arg)), + None => fold_acc_type, } } else { - fold_acc_type.clone() + fold_acc_type }; let method_resolution = resolve_known_method_node( recv_typed.clone(), @@ -3885,11 +3794,11 @@ match bare_s { None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let pipe_fb = match method_resolution.result_type.clone() { + let pipe_fb = match (*method_resolution.result_type).clone() { Some(rt) => Rc::new(MethodPipeFallback { - result_ty: rt.clone(), + result_ty: rt, kernel_diags: Rc::new(vec![]), }), None => method_pipe_map_keys_values_fallback( @@ -3899,23 +3808,23 @@ match bare_s { span.clone(), ), }; - let base_result_type = pipe_fb.result_ty.clone(); - let method_tv_mc = if (method_resolution.semantics.clone() == None) { + let base_result_type = (*pipe_fb.result_ty).clone(); + let method_tv_mc = if ((*method_resolution.semantics).clone() == None) { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }) } else { - match (*method_resolution.semantics.clone().clone().unwrap()).clone() { + match (*(*method_resolution.semantics).clone().clone().unwrap()).clone() { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - } => match at.clone() { + } => match at { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { { @@ -3926,56 +3835,56 @@ match bare_s { } __result }); - let mc_fold_overrides = if (fold_info.clone() != None) { + let mc_fold_overrides = if (fold_info != None) { fold_override_map( "FoldAccumulator".to_string(), - refined_fold_acc_type.clone(), + refined_fold_acc_type, ) } else { empty_override_map() }; resolve_type_variables_from_template( - t.clone(), + t, mc_arg_types, - recv_rt.clone(), + recv_rt, mc_fold_overrides, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } } else { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: base_result_type, diagnostics: Rc::new(vec![]), }), } }; - let result_type = method_tv_mc.ty.clone(); + let result_type = (*method_tv_mc.ty).clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); - let method_semantics = if (method_resolution.semantics.clone() != None) { - method_resolution.semantics.clone() + let method_semantics = if ((*method_resolution.semantics).clone() != None) { + (*method_resolution.semantics).clone() } else { Some(Rc::new(MethodSemantics::PlainMethodSemantics)) }; - let typed_mc_arg_nodes = typed_mc_args.clone(); + let typed_mc_arg_nodes = typed_mc_args; let mc_texpr = make_named_expr_node( - method_name.clone(), + method_name, Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![recv_typed.clone()]), typed_mc_arg_nodes), + v1_rt::concat(Rc::new(vec![recv_typed]), typed_mc_arg_nodes), Some(Rc::new(InferredNode::Resolved { node: result_type })), - span.clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -3994,11 +3903,11 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = scrut_result.typed.clone(); + let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(scrut_typed.clone()); - let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); - let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); + let scrut_subject = pattern_subject_from_inferred((*scrut_typed.inferred).clone()); + let scrut_provenance = classify_binding_provenance(scrut, scope.clone()); let arm_infer_results = Rc::new({ let mut __result = Vec::new(); for arm_node in arm_nodes.clone().iter().cloned() { @@ -4026,7 +3935,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4044,7 +3953,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4064,14 +3973,13 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.body_type.clone()); + __result.push((*ar.body_type).clone()); } __result }); let unified_arm_type = match arm_body_types.clone().first().cloned() { Some(first_type) => Rc::new( arm_body_types - .clone() .iter() .cloned() .skip(1 as usize) @@ -4083,20 +3991,19 @@ match bare_s { prefer_specific_type( acc, t.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( arm_nodes - .clone() .iter() .cloned() .enumerate() @@ -4147,8 +4054,8 @@ match bare_s { }), }; if !is_fully_resolved( - original.body_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*original.body_type).clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4181,7 +4088,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4199,7 +4106,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4229,7 +4136,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.typed_arm.clone()); + __result.push((*ar.typed_arm).clone()); } __result }); @@ -4240,8 +4147,8 @@ match bare_s { } __result }); - let result_type = unified_arm_type.clone(); - let empty_arms_diags = if ((arm_infer_results.clone().len() as i64) == 0) { + let result_type = unified_arm_type; + let empty_arms_diags = if ((arm_infer_results.len() as i64) == 0) { Rc::new(vec![inference_error( "match expression has no arms".to_string(), span.clone(), @@ -4250,30 +4157,26 @@ match bare_s { } else { Rc::new(vec![]) }; - let exhaustiveness_diags = match (*resolve_pattern_subject( - scope.clone(), - scrut_subject.clone(), - )) - .clone() - { - PatternSubject::PatternResolved { - node: resolved_scrutinee, - .. - } => check_match_exhaustiveness( - resolved_scrutinee.clone(), - typed_arms.clone(), - scope.type_env.clone(), - span.clone(), - scope.module_name.clone(), - ), - PatternSubject::PatternDynamic { span: _, .. } => Rc::new(vec![]), - PatternSubject::PatternLookupBlocked => Rc::new(vec![]), - }; + let exhaustiveness_diags = + match (*resolve_pattern_subject(scope.clone(), scrut_subject)).clone() { + PatternSubject::PatternResolved { + node: resolved_scrutinee, + .. + } => check_match_exhaustiveness( + resolved_scrutinee, + typed_arms.clone(), + (*scope.type_env).clone(), + span.clone(), + scope.module_name.clone(), + ), + PatternSubject::PatternDynamic { span: _, .. } => Rc::new(vec![]), + PatternSubject::PatternLookupBlocked => Rc::new(vec![]), + }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![scrut_typed.clone()]), typed_arms.clone()), + v1_rt::concat(Rc::new(vec![scrut_typed]), typed_arms), Some(Rc::new(InferredNode::Resolved { node: result_type })), - span.clone(), + span, ); Rc::new(InferResult { typed: match_texpr, @@ -4289,54 +4192,54 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = cond_result.typed.clone(); + let cond_typed = (*cond_result.typed).clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type(then_result.typed.clone()); - let else_rt = resolved_type(else_result.typed.clone()); + let then_rt = resolved_type((*then_result.typed).clone()); + let else_rt = resolved_type((*else_result.typed).clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { - infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) + infer_expr(then_expr, scope.clone(), Some(else_rt.clone())) } else { then_result.clone() }; let else_result = if (!is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { - infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) + infer_expr(else_branch, scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = else_result.typed.clone(); + let else_typed = (*else_result.typed).clone(); let else_diags = else_result.diagnostics.clone(); let then_rt = resolved_type(then_typed.clone()); let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4347,15 +4250,15 @@ match bare_s { "if branches resolve to incompatible types: " .to_string(), node_type_shape( - then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + then_rt, + (*scope.type_env).clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( - else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + else_rt, + (*scope.type_env).clone().source_indices.clone(), ), ), span.clone(), @@ -4364,9 +4267,9 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed.clone(), else_typed.clone()]), + Rc::new(vec![cond_typed, then_typed, else_typed]), Some(Rc::new(InferredNode::Resolved { node: unified })), - span.clone(), + span, ); Rc::new(InferResult { typed: if_texpr, @@ -4379,9 +4282,9 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed.clone()]), + Rc::new(vec![cond_typed, then_typed]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), - span.clone(), + span, ); Rc::new(InferResult { typed: if_texpr2, @@ -4393,7 +4296,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4403,10 +4306,8 @@ match bare_s { ExprData::ExprVar { binding_kind: _, .. } => { - (authored_name_at( - scope.type_env.clone().source_indices.clone(), - bd.clone(), - ) == let_name.clone()) + (authored_name_at((*scope.type_env).clone().source_indices.clone(), bd) + == let_name.clone()) } _ => false, }, @@ -4418,17 +4319,17 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( - let_name.clone(), + let_name, Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed.clone()]), + Rc::new(vec![val_typed]), Some(Rc::new(InferredNode::Resolved { node: val_type })), - span.clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -4446,19 +4347,19 @@ match bare_s { ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( - let_name.clone(), + let_name, Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed.clone(), body_typed.clone()]), - body_typed.inferred.clone(), - span.clone(), + Rc::new(vec![val_typed, body_typed.clone()]), + (*body_typed.inferred).clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { typed: let_texpr2, - diagnostics: v1_rt::concat(val_diags, body_diags.clone()), + diagnostics: v1_rt::concat(val_diags, body_diags), }) } } @@ -4469,10 +4370,10 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), field_inits, - span.clone(), + span, node_name_span(texpr.clone()), scope.clone(), expected.clone(), @@ -4485,7 +4386,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4507,7 +4408,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push(r.typed.clone()); + __result.push((*r.typed).clone()); } __result }); @@ -4520,7 +4421,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type(r.typed.clone()), + Some(r) => resolved_type((*r.typed).clone()), None => unit_type(), } } else { @@ -4528,10 +4429,10 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { - Some(elem) => child_type_node(elem.clone()), + Some(elem) => child_type_node(elem), None => unit_type(), } } else { @@ -4541,12 +4442,12 @@ match bare_s { None => unit_type(), } }; - let empty_list_diags = if ((elem_results.clone().len() as i64) == 0) { + let empty_list_diags = if ((elem_results.len() as i64) == 0) { match expected.clone() { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4571,14 +4472,14 @@ match bare_s { } else { Rc::new(vec![]) }; - let list_k = list_kernel_ty_from_element(elem_type_node.clone()); + let list_k = list_kernel_ty_from_element(elem_type_node); let ll_texpr = make_expr_node( Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: list_k.ty.clone(), + node: (*list_k.ty).clone(), })), - span.clone(), + span, ); Rc::new(InferResult { typed: ll_texpr, @@ -4593,26 +4494,26 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = left_result.typed.clone(); + let left_typed = (*left_result.typed).clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = right_result.typed.clone(); + let right_typed = (*right_result.typed).clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), resolved_type(left_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { - op: op.clone(), + op: op, algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![left_typed.clone(), right_typed]), + Rc::new(vec![left_typed, right_typed]), Some(Rc::new(InferredNode::Resolved { - node: binop_info.result_type.clone(), + node: (*binop_info.result_type).clone(), })), - span.clone(), + span, ); Rc::new(InferResult { typed: bo_texpr, @@ -4623,17 +4524,17 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = operand_result.typed.clone(); + let operand_typed = (*operand_result.typed).clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), UnaryOpKind::Neg => resolved_type(operand_typed.clone()), }; let uo_texpr = make_expr_node( - Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![operand_typed.clone()]), + Rc::new(ExprData::ExprUnaryOp { op: op }), + Rc::new(vec![operand_typed]), Some(Rc::new(InferredNode::Resolved { node: result_type })), - span.clone(), + span, ); Rc::new(InferResult { typed: uo_texpr, @@ -4645,7 +4546,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4707,12 +4608,9 @@ match bare_s { } else { if ((lam_params.clone().len() as i64) == 1) { match lam_params.clone().first().cloned() { - Some(p) => extend_scope( - scope.clone(), - p.clone(), - exp.clone(), - elem_prov.clone(), - ), + Some(p) => { + extend_scope(scope.clone(), p, exp.clone(), elem_prov) + } None => scope.clone(), } } else { @@ -4766,7 +4664,7 @@ match bare_s { { let exp = expected.clone().unwrap(); if ((exp.params.clone().len() as i64) > 0) { - Some(callable_inferred(exp.clone())) + Some(callable_inferred(exp)) } else { None } @@ -4775,8 +4673,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: lam_scope.type_env.clone(), - func_env: lam_scope.func_env.clone(), + type_env: (*lam_scope.type_env).clone(), + func_env: (*lam_scope.func_env).clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4785,7 +4683,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4811,7 +4709,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), None => None, }; @@ -4826,13 +4724,13 @@ match bare_s { inferred: param_type.clone(), return_cardinality: pn.return_cardinality.clone(), uses: pn.uses.clone(), - body: pn.body.clone(), - transport: pn.transport.clone(), + body: (*pn.body).clone(), + transport: (*pn.transport).clone(), properties: pn.properties.clone(), - type_annotation: pn.type_annotation.clone(), + type_annotation: (*pn.type_annotation).clone(), is_self_recursive: pn.is_self_recursive.clone(), has_non_tail_self_call: pn.has_non_tail_self_call.clone(), - match_pattern: pn.match_pattern.clone(), + match_pattern: (*pn.match_pattern).clone(), expr_data: pn.expr_data.clone(), }) }); @@ -4842,12 +4740,12 @@ match bare_s { let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), - body_typed.inferred.clone(), - span.clone(), + (*body_typed.inferred).clone(), + span, ); Rc::new(InferResult { typed: lam_texpr, - diagnostics: body_diags.clone(), + diagnostics: body_diags, }) } ExprData::ExprStringInterp => { @@ -4860,7 +4758,10 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node(r.typed.clone(), part_node.span.clone()) + make_interp_part_node( + (*r.typed).clone(), + part_node.span.clone(), + ) } None => part_node.clone(), }, @@ -4894,7 +4795,7 @@ match bare_s { Some(Rc::new(InferredNode::Resolved { node: string_type(), })), - span.clone(), + span, ); Rc::new(InferResult { typed: si_texpr, @@ -4908,7 +4809,7 @@ match bare_s { { let state = infer_block_stmts( stmts.clone(), - (stmts.clone().len() as i64), + (stmts.len() as i64), scope.clone(), Rc::new(vec![]), Rc::new(vec![]), @@ -4919,9 +4820,9 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: state.last_type.clone(), + node: (*state.last_type).clone(), })), - span.clone(), + span, ); Rc::new(InferResult { typed: blk_texpr, @@ -4939,7 +4840,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), - span.clone(), + span, )) } } @@ -4948,28 +4849,26 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = inner_result.typed.clone(); + let inner_typed = (*inner_result.typed).clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( - inner_typed.inferred.clone(), + (*inner_typed.inferred).clone(), target_name, span.clone(), - si.clone(), + si, scope.module_name.clone(), ); let cast_diags = match cast_diag { - Some(d) => Rc::new(vec![d.clone()]), + Some(d) => Rc::new(vec![d]), None => Rc::new(vec![]), }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![inner_typed.clone(), target_type.clone()]), - Some(Rc::new(InferredNode::Resolved { - node: target_type.clone(), - })), - span.clone(), + Rc::new(vec![inner_typed, target_type.clone()]), + Some(Rc::new(InferredNode::Resolved { node: target_type })), + span, ); Rc::new(InferResult { typed: cast_texpr, @@ -4979,17 +4878,17 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = coll_result.typed.clone(); + let coll_typed = (*coll_result.typed).clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( resolved_type(coll_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( coll_typed.clone(), @@ -4999,23 +4898,23 @@ match bare_s { let body_scope = extend_scope( scope.clone(), variable.clone(), - elem_type_node.clone(), + elem_type_node, elem_provenance, ); - let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = body_result.typed.clone(); + let body_result = infer_expr(body_expr, body_scope, None); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( - variable.clone(), + variable, Rc::new(ExprData::ExprForEach), - Rc::new(vec![coll_typed.clone(), body_typed.clone()]), - body_typed.inferred.clone(), - span.clone(), + Rc::new(vec![coll_typed, body_typed.clone()]), + (*body_typed.inferred).clone(), + span, node_name_span(texpr.clone()), ); Rc::new(InferResult { typed: fe_texpr, - diagnostics: v1_rt::concat(coll_diags, body_diags.clone()), + diagnostics: v1_rt::concat(coll_diags, body_diags), }) } ExprData::ExprIndex => { @@ -5023,50 +4922,52 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = index_result.typed.clone(); + let index_typed = (*index_result.typed).clone(); let index_diags = index_result.diagnostics.clone(); - let index_check = match base_typed.inferred.clone().as_deref().cloned() { + let index_check = match (*base_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match index_typed.inferred.clone().as_deref().cloned() { + }) => match (*index_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: index_type, .. }) => Some(check_index_access_node( - base_type.clone(), - index_type.clone(), + base_type, + index_type, span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = + match (*base_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + (*index_typed.inferred).clone() + } + _ => (*base_typed.inferred).clone(), + }; let idx_inferred = match index_check.clone() { - Some(checked) => checked.inferred.clone(), + Some(checked) => (*checked.inferred).clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid index access".to_string(), span.clone(), )), }; - let index_access_diags = match index_check.clone() { + let index_access_diags = match index_check { Some(checked) => checked.diagnostics.clone(), None => Rc::new(vec![]), }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base_typed.clone(), index_typed.clone()]), + Rc::new(vec![base_typed, index_typed]), idx_inferred, - span.clone(), + span, ); Rc::new(InferResult { typed: idx_texpr, @@ -5082,29 +4983,29 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = start_result.typed.clone(); + let start_typed = (*start_result.typed).clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = end_result.typed.clone(); + let end_typed = (*end_result.typed).clone(); let end_diags = end_result.diagnostics.clone(); - let slice_check = match base_typed.inferred.clone().as_deref().cloned() { + let slice_check = match (*base_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match start_typed.inferred.clone().as_deref().cloned() { + }) => match (*start_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: start_type, .. - }) => match end_typed.inferred.clone().as_deref().cloned() { + }) => match (*end_typed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: end_type, .. }) => { Some(check_slice_access_node( - base_type.clone(), - start_type.clone(), - end_type.clone(), + base_type, + start_type, + end_type, span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) } _ => None, @@ -5113,39 +5014,35 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() + let access_failure_inferred = + match (*base_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + match (*start_typed.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + (*end_typed.inferred).clone() + } + _ => (*start_typed.inferred).clone(), } - _ => start_typed.inferred.clone(), } - } - _ => base_typed.inferred.clone(), - }; + _ => (*base_typed.inferred).clone(), + }; let slc_inferred = match slice_check.clone() { - Some(checked) => checked.inferred.clone(), + Some(checked) => (*checked.inferred).clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid slice access".to_string(), span.clone(), )), }; - let slice_access_diags = match slice_check.clone() { + let slice_access_diags = match slice_check { Some(checked) => checked.diagnostics.clone(), None => Rc::new(vec![]), }; let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![ - base_typed.clone(), - start_typed.clone(), - end_typed.clone(), - ]), + Rc::new(vec![base_typed, start_typed, end_typed]), slc_inferred, - span.clone(), + span, ); Rc::new(InferResult { typed: slc_texpr, @@ -5161,9 +5058,9 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![inner_result.typed.clone()]), - inner_result.typed.clone().inferred.clone(), - span.clone(), + Rc::new(vec![(*inner_result.typed).clone()]), + (*(*inner_result.typed).clone().inferred).clone(), + span, ); Rc::new(InferResult { typed: ret_texpr, @@ -5180,7 +5077,7 @@ match bare_s { ), diagnostics: Rc::new(vec![inference_error( "unhandled expression variant in infer_expr".to_string(), - span.clone(), + span, scope.module_name.clone(), )]), }) @@ -5199,34 +5096,31 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), parent_enum) { Some(parent_node) => { - match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { + match find_child_named(parent_node, func_name.clone(), si.clone()) { Some(variant_node) => { - if variant_has_positional_payload_shape( - variant_node.clone(), - si.clone(), - ) { + if variant_has_positional_payload_shape(variant_node, si.clone()) { if ((call_args.clone().len() as i64) == 1) { match call_args.clone().first().cloned() { - Some(arg) => match arg_name_at(arg.clone(), si.clone()) { + Some(arg) => match arg_name_at(arg.clone(), si) { Some(arg_name) => { - let msg = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("positional variant constructor '".to_string(), func_name.clone()), "' does not accept named arguments (got '".to_string()), arg_name.clone()), ": ...')".to_string()); + let msg = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("positional variant constructor '".to_string(), func_name.clone()), "' does not accept named arguments (got '".to_string()), arg_name), ": ...')".to_string()); Some(Rc::new(InferResult { typed: semantic_expr_error_node( msg.clone(), arg.span.clone(), ), diagnostics: Rc::new(vec![inference_error( - msg.clone(), + msg, arg.span.clone(), scope.module_name.clone(), )]), })) } None => { - let payload_expr = arg_value(arg.clone()); + let payload_expr = arg_value(arg); let payload_init = make_field_init_node( "0".to_string(), payload_expr.clone(), @@ -5260,7 +5154,7 @@ pub fn infer_variant_constructor_call( span.clone(), ), diagnostics: Rc::new(vec![inference_error( - arity_msg.clone(), + arity_msg, span.clone(), scope.module_name.clone(), )]), @@ -5281,12 +5175,13 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { + if (((*n.inferred).clone() != None) && is_type_variable((*n.inferred).clone().clone().unwrap())) + { true } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (n.inferred.clone() == None)) + && ((*n.inferred).clone() == None)) { { let name = authored_name_at(env.source_indices.clone(), n.clone()); @@ -5312,7 +5207,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() == None)) + && ((*n.inferred).clone() == None)) { is_user_generic_use_site(n.clone(), env.clone()) } else { @@ -5326,7 +5221,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((binding.connective.clone() == Connective::NoConnective) && ((binding.children.clone().len() as i64) == 0)) - && (binding.inferred.clone() != None)) + && ((*binding.inferred).clone() != None)) { true } else { @@ -5334,7 +5229,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { && ((binding.children.clone().len() as i64) > 0)) { (is_user_generic_use_site(binding.clone(), env.clone()) - || (binding.inferred.clone() != None)) + || ((*binding.inferred).clone() != None)) } else { false } @@ -5354,9 +5249,7 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = resolve_node(n, env.clone(), module_name.clone()) - .resolved - .clone(); + let once = (*resolve_node(n.clone(), env.clone(), module_name.clone()).resolved).clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { @@ -5364,7 +5257,7 @@ pub fn peel_alias_once_for_field_access( } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) - && (once.inferred.clone() == None)) + && ((*once.inferred).clone() == None)) { { let __tco_0 = once.clone(); @@ -5380,15 +5273,15 @@ pub fn peel_alias_once_for_field_access( pub fn structural_from_expanded_type(normed: Rc) -> Rc { match normed.connective.clone() { - Connective::Conj => normed.clone(), - Connective::Disj => normed.clone(), - _ => match normed.inferred.clone().as_deref().cloned() { + Connective::Conj => normed, + Connective::Disj => normed, + _ => match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => match target.connective.clone() { - Connective::Conj => target.clone(), - Connective::Disj => target.clone(), - _ => normed.clone(), + Connective::Conj => target, + Connective::Disj => target, + _ => normed, }, - _ => normed.clone(), + _ => normed, }, } } @@ -5403,10 +5296,10 @@ pub fn record_field_type_is_unresolved_param( if ((ft.connective.clone() == Connective::NoConnective) && ((ft.children.clone().len() as i64) == 0)) { - match ft.inferred.clone() { - Some(inf) => is_type_variable(inf.clone()), + match (*ft.inferred).clone() { + Some(inf) => is_type_variable(inf), None => { - let fname = authored_name_at(env.source_indices.clone(), ft.clone()); + let fname = authored_name_at(env.source_indices.clone(), ft); let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { @@ -5417,7 +5310,7 @@ pub fn record_field_type_is_unresolved_param( } __found }; - let conv = is_type_variable_name(fname.clone()); + let conv = is_type_variable_name(fname); (in_params || conv) } } @@ -5457,7 +5350,7 @@ pub fn record_has_unresolved_param_field(record: Rc, env: Rc) -> pub fn alias_chain_generic_decl(env: Rc, carrier: Rc, target: Rc) -> Rc { if ((target.params.clone().len() as i64) > 0) { - target.clone() + target } else { resolve_generic_use_decl(env, carrier) } @@ -5507,7 +5400,7 @@ pub fn alias_chain_target_after_args( { let type_args = carrier.children.clone(); if ((type_args.clone().len() as i64) == 0) { - target.clone() + target } else { { let decl = alias_chain_generic_decl(env.clone(), carrier.clone(), target.clone()); @@ -5515,24 +5408,20 @@ pub fn alias_chain_target_after_args( env.clone(), carrier.clone(), target.clone(), - type_args.clone(), + type_args, ); - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = ((((*decl.inferred).clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { - match decl.inferred.clone().as_deref().cloned() { + match (*decl.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: alias_body, .. - }) => substitute_generics( - alias_body.clone(), - subst, - env.source_indices.clone(), - ), - _ => target.clone(), + }) => substitute_generics(alias_body, subst, env.source_indices.clone()), + _ => target, } } else { - substitute_generics(decl.clone(), subst, env.source_indices.clone()) + substitute_generics(decl, subst, env.source_indices.clone()) } } } @@ -5541,9 +5430,9 @@ pub fn alias_chain_target_after_args( pub fn alias_chain_carrier(n: Rc) -> Rc { if ((n.connective.clone() == Connective::NoConnective) && (n.name.clone() != "".to_string())) { - n.clone() + n } else { - structural_from_expanded_type(n.clone()) + structural_from_expanded_type(n) } } @@ -5566,7 +5455,7 @@ pub fn expand_alias_chain_for_field_access( structural_from_expanded_type(resolve_scrutinee_type_node(env.clone(), peeled.clone())); let is_record = ((structural.connective.clone() == Connective::Conj) || (structural.connective.clone() == Connective::Disj)); - if is_record { + if is_record.clone() { let resolved_record = if ((record_has_unresolved_param_field(structural.clone(), env.clone()) && ((carrier.children.clone().len() as i64) > 0)) @@ -5582,7 +5471,7 @@ pub fn expand_alias_chain_for_field_access( ); substitute_generics( structural.clone(), - subst, + subst.clone(), env.source_indices.clone(), ) } @@ -5591,19 +5480,19 @@ pub fn expand_alias_chain_for_field_access( } else { structural.clone() }; - let fail_closed = - (lossy && record_has_unresolved_param_field(resolved_record.clone(), env.clone())); - if fail_closed { - break nominal_type_ref(origin_name); + let fail_closed = (lossy.clone() + && record_has_unresolved_param_field(resolved_record.clone(), env.clone())); + if fail_closed.clone() { + break nominal_type_ref(origin_name.clone()); } else { break resolved_record.clone(); } } else { let next_name = carrier.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone() == "".to_string())) + let stop = ((is_optional.clone() || (next_name.clone() == "".to_string())) || emit_map_has(seen.clone(), next_name.clone())); - if stop { + if stop.clone() { break structural.clone(); } else { match lookup_type_by_name(env.clone(), next_name.clone()) { @@ -5616,7 +5505,7 @@ pub fn expand_alias_chain_for_field_access( let dropped_args = (((type_arg_count.clone() > 0) && (param_count.clone() > 0)) && (param_count.clone() != type_arg_count.clone())); - let next_lossy = (lossy || dropped_args.clone()); + let next_lossy = (lossy.clone() || dropped_args.clone()); let next_n = if ((type_arg_count.clone() > 0) && !dropped_args.clone()) { alias_chain_target_after_args( target.clone(), @@ -5627,9 +5516,9 @@ pub fn expand_alias_chain_for_field_access( target.clone() }; { - let __tco_0 = next_n; - let __tco_1 = next_seen; - let __tco_2 = next_lossy; + let __tco_0 = next_n.clone(); + let __tco_1 = next_seen.clone(); + let __tco_2 = next_lossy.clone(); n = __tco_0; seen = __tco_1; lossy = __tco_2; @@ -5645,17 +5534,13 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) +pub fn expand_type_for_field_access_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn expand_type_for_field_access_with_seen( @@ -5667,38 +5552,53 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) + { + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) + } } } +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) +} + pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) - && (decl.inferred.clone() != None)) + && ((*decl.inferred).clone() != None)) { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => target.clone(), - _ => decl.clone(), + match (*decl.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => target, + _ => decl, } } else { - decl.clone() + decl }; let expanded = expand_type_for_field_access( to_expand, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5718,8 +5618,8 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), type_name) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5743,73 +5643,50 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); - { - let mut __found = false; - for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( - scope.type_env.clone(), - ))) - .iter() - .cloned() - { - if { - let node = binding.resolved.clone(); - if (node.connective.clone() == Connective::Disj) { + let si = (*scope.type_env).clone().source_indices.clone(); + match variant_owner_node(scope.clone(), type_name.clone()) { + Some(owner) => { + let mut __found = false; + for arm in owner.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { { - let mut __found = false; - for arm in node.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) - == type_name.clone()) - { - { - let ea = expand_type_for_field_access( - arm.clone(), - scope.type_env.clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) - { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) - == field.clone()) - { - __found = true; - break; - } - } - __found - } + let ea = expand_type_for_field_access( + arm.clone(), + (*scope.type_env).clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) == field.clone()) { + __found = true; + break; } - } else { - false - } { - __found = true; - break; } + __found } - __found } } else { false + } { + __found = true; + break; } - } { - __found = true; - break; } + __found } - __found + None => false, } } } pub fn type_has_sole_constructor(type_name: String, scope: Rc) -> bool { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5833,50 +5710,40 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { - // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is - // deleted; the ladder is instantiate -> expected -> declaration/ - // binding-edge only. Regen replaces this with the dag source's true - // emission. let struct_fields = match type_name.clone() { - Some(tn) => { - match record_lit_instantiated_fields( + Some(tn) => match record_lit_instantiated_fields( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields, + None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { - Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => { - match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => { - record_lit_expected_fields(type_name.clone(), scope.clone()) - } - } - } + Some(fields) => fields, + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields, + None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, - } - } + }, + }, None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), scope.clone(), ) { - Some(fields) => fields.clone(), + Some(fields) => fields, None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { - Some(fields) => fields.clone(), + Some(fields) => fields, None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, @@ -5895,7 +5762,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5931,7 +5798,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5944,15 +5811,15 @@ pub fn infer_record_lit( .cloned() { Some(sf) => { - let ft = match sf.inferred.clone().as_deref().cloned() { + let ft = match (*sf.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if ((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone()) + if (((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone())) || field_type_is_optional_coproduct( ft.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), )) { Some(ft.clone()) @@ -5967,7 +5834,7 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = ar.typed.clone(); + let ar_typed = (*ar.typed).clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { @@ -5975,28 +5842,30 @@ pub fn infer_record_lit( if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - scope.type_env.clone().source_indices.clone(), - scope.type_env.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*scope.type_env).clone(), ) { - let expected_for_shape = match lookup_type_for( - scope.type_env.clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape, - scope.type_env.clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - scope.type_env.clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) + { + let expected_for_shape = match lookup_type_for( + (*scope.type_env).clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) + } } else { Rc::new(vec![]) } @@ -6023,7 +5892,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push(fir.typed_field.clone()); + __result.push((*fir.typed_field).clone()); } __result }); @@ -6038,18 +5907,18 @@ pub fn infer_record_lit( { let child_nodes = Rc::new({ let mut __result = Vec::new(); - for fir in fi_infer_results.clone().iter().cloned() { + for fir in fi_infer_results.iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ), - span: fir.typed_field.clone().span.clone(), - ident_span: fir.typed_field.clone().ident_span.clone(), + span: (*fir.typed_field).clone().span.clone(), + ident_span: (*fir.typed_field).clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: fir.infer_result.clone().typed.clone().inferred.clone(), + inferred: (*(*fir.infer_result.clone().typed).clone().inferred).clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6100,24 +5969,24 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); + lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { - Some(_) => type_lookup.clone(), + Some(_) => type_lookup, None => { let local_lookup = lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for(scope.type_env.clone(), local_node.clone()) + lookup_type_for((*scope.type_env).clone(), local_node) } None => None, } } }; let raw_resolved = match effective_lookup.clone() { - Some(tn) => tn.clone(), + Some(tn) => tn, None => error_type(), }; let expected_optional_parent = Some("Optional".to_string()); @@ -6128,10 +5997,10 @@ pub fn infer_record_lit( { let val_field = Rc::new({ let mut __result = Vec::new(); - for fir in fi_infer_results.clone().iter().cloned() { + for fir in fi_infer_results.iter().cloned() { if (field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6143,7 +6012,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - val_fir.infer_result.clone().typed.clone(), + (*val_fir.infer_result.clone().typed).clone(), )), None => raw_resolved, } @@ -6151,10 +6020,7 @@ pub fn infer_record_lit( } else { raw_resolved }; - // HAND-PATCH (§1c): unbound constructor literal is the typed - // UnresolvedType diagnostic, not a generic InternalError message. - // Regen replaces this with the dag source's true emission. - let type_diags = match effective_lookup.clone() { + let type_diags = match effective_lookup { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::UnresolvedType { @@ -6167,7 +6033,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6190,13 +6056,13 @@ pub fn infer_record_lit( }; let typed_field_nodes2 = typed_fields; let rl_name = match type_name.clone() { - Some(tn_val) => tn_val.clone(), + Some(tn_val) => tn_val, None => "".to_string(), }; let texpr = make_named_expr_node( rl_name, Rc::new(ExprData::ExprRecordLit { - parent_enum: local_variant_parent.clone(), + parent_enum: local_variant_parent, }), typed_field_nodes2, Some(Rc::new(InferredNode::Resolved { @@ -6252,7 +6118,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6261,13 +6127,11 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( - receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + receiver, + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { - Some(_) => Some(Rc::new(SizeExpr::ParamSize { - param: rname.clone(), - })), + Some(_) => Some(Rc::new(SizeExpr::ParamSize { param: rname })), None => None, } } @@ -6288,10 +6152,8 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { - let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); + let lname = + expr_var_name_at(left, (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() .cloned() @@ -6305,8 +6167,8 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option 0) { Some(Rc::new(SizeExpr::DividedSize { - param: p.clone(), - divisor: d.clone(), + param: p, + divisor: d, })) } else { None @@ -6339,7 +6201,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6350,14 +6212,14 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { + if (p == param_name.clone()) { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; - if (k.clone() > 0) { - match proportional_divisor_from_int_at_least_two(d.clone()) { + if (k > 0) { + match proportional_divisor_from_int_at_least_two(d) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6369,7 +6231,7 @@ pub fn proportional_skip_alias_plus_literal( Some(Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), + divisor: div_w, }), })) } @@ -6404,7 +6266,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6414,15 +6276,15 @@ pub fn classify_collection_shrink( binding_kind: _, .. } => { let rname = expr_var_name_at( - receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + receiver, + (*ctx.type_env).clone().source_indices.clone(), ); if (rname == param_name.clone()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { Some(arg_node) => { - let arg_val = arg_value(arg_node.clone()); + let arg_val = arg_value(arg_node); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -6433,19 +6295,19 @@ pub fn classify_collection_shrink( if ((k.clone() > 0) && (mname.clone() == "skip".to_string())) { - match positive_descent_amount_from_positive_int(k.clone()) { + match positive_descent_amount_from_positive_int(k) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), variant_name: "".to_string(), - field_name: mname.clone(), + field_name: mname, shape: RecursionShape::ListRecursion, element_type: param_name.clone(), }); Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps.clone(), + steps: steps, }), }) }, @@ -6459,8 +6321,11 @@ Rc::new(SubValueRelation::StrictSubValue { binding_kind: _, .. } => { let aname = expr_var_name_at( - arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + arg_val, + (*ctx.type_env) + .clone() + .source_indices + .clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6474,20 +6339,20 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { - match proportional_divisor_from_int_at_least_two(d.clone()) { + if (p == param_name.clone()) { + match proportional_divisor_from_int_at_least_two(d) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), variant_name: "".to_string(), - field_name: mname.clone(), + field_name: mname, shape: RecursionShape::ListRecursion, element_type: param_name.clone(), }); Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), + divisor: div_w, }), }) }, @@ -6502,37 +6367,32 @@ Rc::new(SubValueRelation::StrictSubValue { ), } } - ExprData::ExprBinOp { op, .. } => { - match op.clone() { - BinOp::Add => { - if (mname.clone() == "skip".to_string()) + ExprData::ExprBinOp { op, .. } => match op { + BinOp::Add => { + if (mname == "skip".to_string()) { { - { - let left = - binop_left(arg_val.clone()); - let right = binop_right( - arg_val.clone(), - ); - match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { - Some(rel) => rel.clone(), - None => match proportional_skip_alias_plus_literal(right.clone(), left.clone(), param_name.clone(), ctx.clone()) { - Some(rel) => rel.clone(), + let left = + binop_left(arg_val.clone()); + let right = binop_right(arg_val); + match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { + Some(rel) => rel, + None => match proportional_skip_alias_plus_literal(right, left, param_name.clone(), ctx.clone()) { + Some(rel) => rel, None => Rc::new(SubValueRelation::SubValueUnknown), }, } - } - } else { - Rc::new(SubValueRelation::SubValueUnknown) } + } else { + Rc::new( + SubValueRelation::SubValueUnknown, + ) } - BinOp::Sub => Rc::new( - SubValueRelation::SubValueUnknown, - ), - _ => Rc::new( - SubValueRelation::SubValueUnknown, - ), } - } + BinOp::Sub => { + Rc::new(SubValueRelation::SubValueUnknown) + } + _ => Rc::new(SubValueRelation::SubValueUnknown), + }, _ => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -6565,7 +6425,7 @@ pub fn method_callback_element_position(semantics: Option>) Some(MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - }) => match at.clone() { + }) => match at { Some(template) => template.callback_element_position.clone(), None => None, }, @@ -6581,7 +6441,7 @@ pub fn maybe_insert_composed_field_relation( match composed { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::SubValueUnknown => acc, - _ => v1_rt::rc_map_insert(acc, fname, rel.clone()), + _ => v1_rt::rc_map_insert(acc, fname, rel), }, None => acc, } @@ -6597,7 +6457,7 @@ pub fn maybe_insert_output_field_relation( ) -> Rc>> { { let composed = match sig.output_provenance.clone().get(idx as usize).cloned() { - Some(param_map) => classify_call_via_provenance(val, param_map.clone(), ctx), + Some(param_map) => classify_call_via_provenance(val, param_map, ctx), None => None, }; maybe_insert_composed_field_relation(acc, fname, composed) @@ -6618,7 +6478,7 @@ pub fn maybe_insert_match_field_relation( let lookup_type = match (*rel.clone()).clone() { SubValueRelation::PreservedValue => { match v1_rt::map_get(¶m_types, pname.clone()) { - Some(t) => t.clone(), + Some(t) => t, None => "".to_string(), } } @@ -6628,7 +6488,7 @@ pub fn maybe_insert_match_field_relation( }; if (lookup_type.clone() != "".to_string()) { { - let ind_fields = inductive_fields_for(type_env, lookup_type.clone()); + let ind_fields = inductive_fields_for(type_env, lookup_type); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -6647,7 +6507,7 @@ pub fn maybe_insert_match_field_relation( Some(ind_field) => v1_rt::rc_map_insert( fp_acc, pname.clone(), - compose_sub_value(rel.clone(), ind_field.clone()), + compose_sub_value(rel, ind_field), ), None => fp_acc, } @@ -6668,12 +6528,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6693,7 +6553,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6710,7 +6570,7 @@ pub fn build_per_field_for_let( v1_rt::rc_map_insert( ctx.per_field_vars.clone(), binding_name, - field_map.clone(), + field_map, ) } else { ctx.per_field_vars.clone() @@ -6728,12 +6588,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6753,7 +6613,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6770,7 +6630,7 @@ pub fn build_per_field_for_let( v1_rt::rc_map_insert( ctx.per_field_vars.clone(), binding_name, - field_map.clone(), + field_map, ) } else { ctx.per_field_vars.clone() @@ -6797,7 +6657,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6805,7 +6665,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6832,7 +6692,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ) .iter() @@ -6871,8 +6731,8 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { + expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); + match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname.clone()) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { match f.shape.clone() { @@ -6907,15 +6767,17 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = - expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_mname = expr_method_name_at( + expr.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) || (inner_mname.clone() == "take".to_string())) || (inner_mname.clone() == "filter".to_string())) || (inner_mname.clone() == "reverse".to_string())); - if is_collection_preserving { + if is_collection_preserving.clone() { { let __tco_0 = method_receiver(expr); expr = __tco_0; @@ -6937,8 +6799,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = - expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let vname = expr_var_name_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6946,23 +6810,23 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = - field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let field = field_access_field_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - scope.type_env.clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base, (*scope.type_env).clone().source_indices.clone()); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -6978,7 +6842,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - compose_sub_value(binding.provenance.clone(), ind_field.clone()) + compose_sub_value(binding.provenance.clone(), ind_field) } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -6998,7 +6862,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + let vname = + expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -7010,41 +6875,36 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), None => None, }; match from_per_field { - Some(rel) => Some(rel.clone()), + Some(rel) => Some(rel), None => { let type_name = match v1_rt::map_get(&ctx.scope_locals.clone(), bname.clone()) { Some(binding) => authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), - None => match v1_rt::map_get( - &ctx.param_names.clone(), - bname.clone(), - ) { - Some(t) => t.clone(), + None => match v1_rt::map_get(&ctx.param_names.clone(), bname) { + Some(t) => t, None => "".to_string(), }, }; if (type_name.clone() != "".to_string()) { { - let fields = inductive_fields_for( - ctx.type_env.clone(), - type_name.clone(), - ); + let fields = + inductive_fields_for((*ctx.type_env).clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7059,7 +6919,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), + field: ind_field, factor: Rc::new(ShrinkFactor::UnitShrink), })) } @@ -7077,45 +6937,44 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { - classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) + classify_call_via_provenance(val.clone(), param_map, ctx.clone()) } None => None, }, None => None, }; match from_provenance.clone() { - Some(_) => from_provenance.clone(), + Some(_) => from_provenance, None => { - if (is_child_accessor_in_model(callee.clone()) - || is_tree_size_reducing(callee.clone())) + if (is_child_accessor_in_model(callee.clone()) || is_tree_size_reducing(callee)) { { let call_args = val.children.clone(); match call_args.first().cloned() { Some(first_arg) => { - let inner = arg_value(first_arg.clone()); + let inner = arg_value(first_arg); match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let iname = expr_var_name_at( - inner.clone(), - ctx.type_env.clone().source_indices.clone(), + inner, + (*ctx.type_env).clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), iname.clone(), ) { - Some(t) => t.clone(), + Some(t) => t, None => match v1_rt::map_get( &ctx.sub_value_vars.clone(), - iname.clone(), + iname, ) { - Some(rel) => match (*rel.clone()).clone() { + Some(rel) => match (*rel).clone() { SubValueRelation::StrictSubValue { field: f, .. @@ -7132,8 +6991,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::StrictSubValue { - field: ind_field.clone(), + field: ind_field, factor: Rc::new( ShrinkFactor::UnitShrink, ), @@ -7177,26 +7036,26 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let type_based = match val.inferred.clone().as_deref().cloned() { + let type_based = match (*val.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if is_container_type(authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - ctx.type_env.clone().source_indices.clone(), - c.clone(), + (*ctx.type_env).clone().source_indices.clone(), + c, ), None => "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) + && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) { { let fields = - inductive_fields_for(ctx.type_env.clone(), elem.clone()); + inductive_fields_for((*ctx.type_env).clone(), elem); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7232,19 +7091,19 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, }; match type_based.clone() { - Some(_) => type_based.clone(), + Some(_) => type_based, None => match (*val.expr_data.clone()).clone() { ExprData::ExprBinOp { op: op, .. } => { let left = binop_left(val.clone()); let right = binop_right(val.clone()); - match op.clone() { + match op { BinOp::Sub => match (*left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), + left, + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7260,15 +7119,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::ArithmeticDescent { - param: lname.clone(), + param: lname, factor: Rc::new( ShrinkFactor::ConstantShrink { - steps: steps.clone(), + steps: steps, }, ), }, @@ -7290,8 +7147,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), + left, + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7302,20 +7159,20 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let inner_left = binop_left(left.clone()); + let inner_left = binop_left(left); match (*inner_left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let lname = expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + inner_left, + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7326,7 +7183,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::ArithmeticDescent { - param: left_name.clone(), + param: left_name, factor: Rc::new( ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), + divisor: div_w, }, ), }, @@ -7376,7 +7231,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7392,7 +7247,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), + field: ind_field, factor: Rc::new(ShrinkFactor::UnitShrink), })) } @@ -7401,7 +7256,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match (*arg_value(a.clone()) + Some(a) => match (*arg_value(a) .expr_data .clone()) .clone() @@ -7417,7 +7272,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option 0) { - k.clone() + k } else { 0 } @@ -7433,8 +7288,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( - receiver.clone(), - ctx.type_env + receiver, + (*ctx.type_env) .clone() .source_indices .clone(), @@ -7448,19 +7303,19 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let synth_field = Rc::new(InductiveField { type_name: rname.clone(), variant_name: "".to_string(), - field_name: mname.clone(), + field_name: mname, shape: RecursionShape::ListRecursion, - element_type: rname.clone(), + element_type: rname, }); Some(Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps.clone(), + steps: steps, }), })) }, @@ -7504,7 +7359,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7551,12 +7406,12 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) } else { - v1_rt::map_get(&ctx.sub_value_vars.clone(), name.clone()) + v1_rt::map_get(&ctx.sub_value_vars.clone(), name) } } _ => classify_let_value(arg_expr.clone(), ctx.clone()), @@ -7576,7 +7431,7 @@ pub fn merge_argument_relations(rels: Rc>>) -> Rc, rel: Rc| meet_sub_value(acc, rel.clone()), ), } @@ -7594,13 +7449,13 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) } else { - match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { - Some(rel) => rel.clone(), + match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname) { + Some(rel) => rel, None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -7609,36 +7464,31 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - ctx.type_env.clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { - Some(t) => t.clone(), - None => { - match v1_rt::map_get(&ctx.sub_value_vars.clone(), bname.clone()) - { - Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::StrictSubValue { - field: f, .. - } => f.element_type.clone(), - SubValueRelation::IteratedSubValue { - field: f, .. - } => f.element_type.clone(), - _ => "".to_string(), - }, - None => "".to_string(), - } - } + Some(t) => t, + None => match v1_rt::map_get(&ctx.sub_value_vars.clone(), bname) { + Some(rel) => match (*rel).clone() { + SubValueRelation::StrictSubValue { field: f, .. } => { + f.element_type.clone() + } + SubValueRelation::IteratedSubValue { field: f, .. } => { + f.element_type.clone() + } + _ => "".to_string(), + }, + None => "".to_string(), + }, }; - let fields = inductive_fields_for(ctx.type_env.clone(), type_name); + let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7652,7 +7502,7 @@ pub fn classify_argument( .cloned(); match matching { Some(ind_field) => Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), + field: ind_field, factor: Rc::new(ShrinkFactor::UnitShrink), }), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -7665,35 +7515,35 @@ pub fn classify_argument( let call_args = arg_expr.children.clone(); match call_args.first().cloned() { Some(first_arg) => { - let inner = arg_value(first_arg.clone()); + let inner = arg_value(first_arg); let inner_rel = classify_argument(inner, param_name.clone(), ctx.clone()); match (*inner_rel.clone()).clone() { - SubValueRelation::StrictSubValue { .. } => inner_rel.clone(), - SubValueRelation::IteratedSubValue { field: _, .. } => { - inner_rel.clone() - } - SubValueRelation::ArithmeticDescent { .. } => inner_rel.clone(), + SubValueRelation::StrictSubValue { .. } => inner_rel, + SubValueRelation::IteratedSubValue { field: _, .. } => inner_rel, + SubValueRelation::ArithmeticDescent { .. } => inner_rel, SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - let from_provenance = - match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, - } + let from_provenance = match lookup_func_sig( + (*ctx.func_env).clone(), + callee.clone(), + ) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map, + ctx.clone(), + ), + None => None, } - None => None, - }; + } + None => None, + }; match from_provenance { - Some(prov_rel) => prov_rel.clone(), + Some(prov_rel) => prov_rel, None => { if (is_child_accessor_in_model(callee.clone()) || is_tree_size_reducing(callee.clone())) @@ -7703,11 +7553,11 @@ pub fn classify_argument( &ctx.param_names.clone(), param_name.clone(), ) { - Some(t) => t.clone(), + Some(t) => t, None => "".to_string(), }; let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), type_name, ); let cf = Rc::new({ @@ -7727,7 +7577,7 @@ pub fn classify_argument( match cf { Some(ind_field) => { Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), + field: ind_field, factor: Rc::new( ShrinkFactor::UnitShrink, ), @@ -7739,7 +7589,7 @@ pub fn classify_argument( } } } else { - if is_property_contraction(callee.clone()) { + if is_property_contraction(callee) { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ConstantShrink { @@ -7777,7 +7627,7 @@ pub fn classify_argument( ExprData::ExprBinOp { op: op, .. } => { let left = binop_left(arg_expr.clone()); let right = binop_right(arg_expr.clone()); - match op.clone() { + match op { BinOp::Sub => { let left_is_param = match (*left.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7785,13 +7635,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), + left, + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7804,12 +7654,12 @@ pub fn classify_argument( else { unreachable!() }; - match positive_descent_amount_from_positive_int(k.clone()) { + match positive_descent_amount_from_positive_int(k) { Some(steps) => { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps.clone(), + steps: steps, }), }) } @@ -7829,31 +7679,31 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), + left, + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } ExprData::ExprBinOp { op: BinOp::Sub, .. } => { - let inner_left = binop_left(left.clone()); + let inner_left = binop_left(left); match (*inner_left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { ((expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + inner_left, + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7869,12 +7719,12 @@ pub fn classify_argument( else { unreachable!() }; - match proportional_divisor_from_int_at_least_two(k.clone()) { + match proportional_divisor_from_int_at_least_two(k) { Some(div_w) => { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), + divisor: div_w, }), }) } @@ -7912,19 +7762,17 @@ pub fn classify_argument( ctx.clone(), ); let else_rel = match if_else_branch(arg_expr.clone()) { - Some(e) => classify_argument(e.clone(), param_name.clone(), ctx.clone()), + Some(e) => classify_argument(e, param_name.clone(), ctx.clone()), None => Rc::new(SubValueRelation::SubValueUnknown), }; merge_argument_relations(Rc::new(vec![then_rel, else_rel])) } ExprData::ExprBlock => match arg_expr.children.clone().last().cloned() { - Some(last_expr) => { - classify_argument(last_expr.clone(), param_name.clone(), ctx.clone()) - } + Some(last_expr) => classify_argument(last_expr, param_name.clone(), ctx.clone()), None => Rc::new(SubValueRelation::SubValueUnknown), }, ExprData::ExprLet => match let_body(arg_expr.clone()) { - Some(body) => classify_argument(body.clone(), param_name.clone(), ctx.clone()), + Some(body) => classify_argument(body, param_name.clone(), ctx.clone()), None => Rc::new(SubValueRelation::SubValueUnknown), }, ExprData::ExprCast => { @@ -7950,7 +7798,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7966,14 +7814,14 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7981,10 +7829,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -7999,10 +7847,9 @@ pub fn read_arg_provenance( .first() .cloned(); match matching { - Some(ind_field) => compose_sub_value( - binding.provenance.clone(), - ind_field.clone(), - ), + Some(ind_field) => { + compose_sub_value(binding.provenance.clone(), ind_field) + } None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -8055,7 +7902,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8074,7 +7921,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8131,10 +7978,10 @@ pub fn build_call_evidence( pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { if (found.clone() != "".to_string()) { - found.clone() + found } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLambda => found.clone(), + ExprData::ExprLambda => found, _ => { let arg_val = arg_value(arg_node.clone()); match (*arg_val.expr_data.clone()).clone() { @@ -8142,11 +7989,11 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( - arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + arg_val, + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { - Some(t) => t.clone(), + Some(t) => t, None => "".to_string(), } } @@ -8181,7 +8028,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8216,11 +8063,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8268,13 +8115,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8288,7 +8135,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8299,7 +8146,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8317,18 +8164,18 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: Rc::new(ExprData::ExprCall { - call_semantics: cs.clone(), + call_semantics: cs, descent_evidence: Some(evidence), }), ident: None, @@ -8342,24 +8189,22 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), - None => { - match v1_rt::map_get(&ctx.sub_value_vars.clone(), sname.clone()) { - Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::StrictSubValue { field: f, .. } => { - f.element_type.clone() - } - SubValueRelation::IteratedSubValue { field: f, .. } => { - f.element_type.clone() - } - _ => "".to_string(), - }, - None => "".to_string(), - } - } + None => match v1_rt::map_get(&ctx.sub_value_vars.clone(), sname) { + Some(rel) => match (*rel).clone() { + SubValueRelation::StrictSubValue { field: f, .. } => { + f.element_type.clone() + } + SubValueRelation::IteratedSubValue { field: f, .. } => { + f.element_type.clone() + } + _ => "".to_string(), + }, + None => "".to_string(), + }, } } _ => "".to_string(), @@ -8369,26 +8214,26 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( - base.clone(), - ctx.type_env.clone().source_indices.clone(), + base, + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { - Some(t) => t.clone(), + Some(t) => t, None => "".to_string(), }; if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - ctx.type_env.clone(), - base_type.clone(), + (*ctx.type_env).clone(), + base_type, ); Rc::new({ let mut __result = Vec::new(); @@ -8415,14 +8260,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - if ((mname.clone() == "first".to_string()) - || (mname.clone() == "last".to_string())) + if ((mname.clone() == "first".to_string()) || (mname == "last".to_string())) { { let receiver = method_receiver(scrut.clone()); - resolve_collection_field(receiver.clone(), ctx.clone()) + resolve_collection_field(receiver, ctx.clone()) } } else { None @@ -8431,7 +8275,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() + && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8439,9 +8283,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - match lookup_func_sig(ctx.func_env.clone(), callee) { + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8477,20 +8321,20 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8502,14 +8346,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: ic.type_env.clone(), + type_env: (*ic.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: ic.func_env.clone(), + func_env: (*ic.func_env).clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8525,9 +8369,9 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8539,14 +8383,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8562,11 +8406,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8575,14 +8419,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8607,32 +8451,32 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: v1_rt::concat(Rc::new(vec![annotated_scrut]), annotated_arms), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = - let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let binding_name = let_binding_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { - Some(se) => v1_rt::rc_map_insert( - ctx.size_aliases.clone(), - binding_name.clone(), - se.clone(), - ), + Some(se) => { + v1_rt::rc_map_insert(ctx.size_aliases.clone(), binding_name.clone(), se) + } None => ctx.size_aliases.clone(), }; let inner_per_field = @@ -8654,13 +8498,13 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), - sub_type.clone(), + sub_type, ) } else { ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8671,12 +8515,12 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.scope_locals.clone(), binding_name.clone(), Rc::new(TypeBinding { - name: binding_name.clone(), + name: binding_name, resolved: resolved_type(val.clone()), - provenance: rel.clone(), + provenance: rel, }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }) } @@ -8684,27 +8528,27 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( ctx.scope_locals.clone(), binding_name.clone(), Rc::new(TypeBinding { - name: binding_name.clone(), + name: binding_name, resolved: resolved_type(val.clone()), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }), }; - let annotated_value = annotate_descent(val.clone(), ctx.clone()); + let annotated_value = annotate_descent(val, ctx.clone()); let annotated_children = match let_body(body.clone()) { Some(body_child) => Rc::new(vec![ annotated_value, - annotate_descent(body_child.clone(), inner_ctx.clone()), + annotate_descent(body_child, inner_ctx), ]), None => Rc::new(vec![annotated_value]), }; @@ -8715,16 +8559,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8742,7 +8586,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8777,7 +8621,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8793,7 +8637,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8801,7 +8645,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8815,7 +8659,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8838,16 +8682,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: threaded.children.clone(), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8856,9 +8700,11 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = - expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); - let elem_position = method_callback_element_position(ms.clone()); + let mname = expr_method_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); + let elem_position = method_callback_element_position(ms); if (elem_position.clone() != None) { { let raw_receiver = method_receiver(body.clone()); @@ -8869,41 +8715,41 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { - method_receiver(raw_receiver.clone()) + method_receiver(raw_receiver) } else { - raw_receiver.clone() + raw_receiver } } - _ => raw_receiver.clone(), + _ => raw_receiver, }; let receiver_field = match (*receiver.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: _, .. } => { let base = field_access_base(receiver.clone()); let fname = field_access_field_at( - receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + receiver, + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( - base.clone(), - ctx.type_env.clone().source_indices.clone(), + base, + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), bname.clone(), ) { - Some(t) => t.clone(), + Some(t) => t, None => match v1_rt::map_get( &ctx.sub_value_vars.clone(), - bname.clone(), + bname, ) { - Some(rel) => match (*rel.clone()).clone() { + Some(rel) => match (*rel).clone() { SubValueRelation::StrictSubValue { field: f, .. @@ -8921,8 +8767,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), - base_type.clone(), + (*ctx.type_env).clone(), + base_type, ) .iter() .cloned() @@ -8946,20 +8792,20 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota binding_kind: _, .. } => { let rname = expr_var_name_at( - receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + receiver, + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { - Some(rel) => match (*rel.clone()).clone() { + Some(rel) => match (*rel).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { match f.shape.clone() { - RecursionShape::ListRecursion => Some(f.clone()), + RecursionShape::ListRecursion => Some(f), _ => None, } } SubValueRelation::IteratedSubValue { field: f, .. } => { match f.shape.clone() { - RecursionShape::ListRecursion => Some(f.clone()), + RecursionShape::ListRecursion => Some(f), _ => None, } } @@ -8987,13 +8833,12 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .cloned(); let lambda_elem_info = match lambda_arg { Some(la) => { - let lambda_node = arg_value(la.clone()); + let lambda_node = arg_value(la); let lparams = lambda_param_names_at( lambda_node, - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); lparams - .clone() .get(elem_position.clone().unwrap() as usize) .cloned() } @@ -9010,34 +8855,34 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - elem_name.clone(), + elem_name, Rc::new(SubValueRelation::IteratedSubValue { - field: ind_field.clone(), + field: ind_field, }), ) } else { v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), - elem_name.clone(), + elem_name, Rc::new(SubValueRelation::IteratedSubValue { - field: ind_field.clone(), + field: ind_field, }), ) }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -9045,7 +8890,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -9066,7 +8911,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9079,7 +8924,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9103,16 +8948,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9126,8 +8971,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = - foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let fe_var = foreach_variable_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9138,50 +8985,48 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - fe_var.clone(), - Rc::new(SubValueRelation::IteratedSubValue { - field: ind_field.clone(), - }), + fe_var, + Rc::new(SubValueRelation::IteratedSubValue { field: ind_field }), ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; - let annotated_coll = annotate_descent(coll.clone(), ctx.clone()); - let annotated_body = annotate_descent(fe_body, inner_ctx.clone()); + let annotated_coll = annotate_descent(coll, ctx.clone()); + let annotated_body = annotate_descent(fe_body, inner_ctx); Rc::new(Node { name: body.name.clone(), span: body.span.clone(), ident_span: body.ident_span.clone(), - children: Rc::new(vec![annotated_coll, annotated_body.clone()]), + children: Rc::new(vec![annotated_coll, annotated_body]), connective: body.connective.clone(), params: body.params.clone(), - inferred: body.inferred.clone(), + inferred: (*body.inferred).clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: body.body.clone(), - transport: body.transport.clone(), + body: (*body.body).clone(), + transport: (*body.transport).clone(), properties: body.properties.clone(), - type_annotation: body.type_annotation.clone(), + type_annotation: (*body.type_annotation).clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: body.match_pattern.clone(), + match_pattern: (*body.match_pattern).clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9197,12 +9042,10 @@ pub fn resolved_type_name( n: Rc, source_indices: Rc>>, ) -> String { - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => { - authored_name_at(source_indices, rt.clone()) - } + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => authored_name_at(source_indices, rt), _ => match n.children.clone().first().cloned() { - Some(c) => authored_name_at(source_indices, c.clone()), + Some(c) => authored_name_at(source_indices, c), None => "".to_string(), }, } @@ -9247,13 +9090,13 @@ pub fn infer_output_provenance( v1_rt::rc_empty_map::>>>(), ); if ((Rc::new(v1_rt::map_keys(&scalar)).len() as i64) > 0) { - Rc::new(vec![scalar.clone()]) + Rc::new(vec![scalar]) } else { { let per_field = classify_body_per_field( body.clone(), - param_names.clone(), - param_types.clone(), + param_names, + param_types, type_env.clone(), func_env.clone(), v1_rt::rc_empty_map::>>>(), @@ -9268,7 +9111,7 @@ pub fn infer_output_provenance( } __found }) { - per_field.clone() + per_field } else { Rc::new(vec![]) } @@ -9292,7 +9135,7 @@ pub fn classify_body_provenance( } => { let vname = expr_var_name_at(expr.clone(), type_env.source_indices.clone()); match v1_rt::map_get(&let_prov, vname.clone()) { - Some(prov) => prov.clone(), + Some(prov) => prov, None => { if { let mut __found = false; @@ -9306,7 +9149,7 @@ pub fn classify_body_provenance( } { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - vname.clone(), + vname, Rc::new(SubValueRelation::PreservedValue), ) } else { @@ -9415,14 +9258,14 @@ pub fn classify_body_provenance( let_prov.clone(), ); if ((Rc::new(v1_rt::map_keys(&callee_result)).len() as i64) > 0) { - callee_result.clone() + callee_result } else { { - let is_shrink = match ms.clone().as_deref().cloned() { + let is_shrink = match ms.as_deref().cloned() { Some(MethodSemantics::AlgebraMethodSemantics { size_effect: se, .. - }) => match se.clone() { + }) => match se { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }, @@ -9430,19 +9273,18 @@ pub fn classify_body_provenance( }; if (is_shrink && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => { - match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = - value.as_ref() - else { - unreachable!() - }; - (n.clone() > 0) - } - _ => false, + Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()) + .clone() + { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = value.as_ref() + else { + unreachable!() + }; + (n > 0) } - } + _ => false, + }, None => false, }) { @@ -9542,7 +9384,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types match if_else_branch(expr.clone()) { Some(else_expr) => { let else_prov = classify_body_provenance( - else_expr.clone(), + else_expr, param_names.clone(), param_types.clone(), type_env.clone(), @@ -9558,18 +9400,17 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types let value = let_value(expr.clone()); let bname = let_binding_name_at(expr.clone(), type_env.source_indices.clone()); let value_prov = classify_body_provenance( - value.clone(), + value, param_names.clone(), param_types.clone(), type_env.clone(), func_env.clone(), let_prov.clone(), ); - let updated = - v1_rt::rc_map_insert(let_prov.clone(), bname.clone(), value_prov.clone()); + let updated = v1_rt::rc_map_insert(let_prov.clone(), bname, value_prov); match let_body(expr.clone()) { Some(body) => classify_body_provenance( - body.clone(), + body, param_names.clone(), param_types.clone(), type_env.clone(), @@ -9648,7 +9489,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types ), ExprData::ExprReturn => match expr.children.clone().first().cloned() { Some(inner) => classify_body_provenance( - inner.clone(), + inner, param_names.clone(), param_types.clone(), type_env.clone(), @@ -9698,11 +9539,11 @@ pub fn method_call_args_by_name( let base = match lookup_func_sig(func_env, mname) { Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { - let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); + let first_pname = param_node_name_at(first_p, source_indices.clone()); if (first_pname.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - first_pname.clone(), + first_pname, recv, ) } else { @@ -9816,7 +9657,7 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = unwrapped.expr.clone(); + let terminal = (*unwrapped.expr).clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( terminal, @@ -9862,11 +9703,15 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { + match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in - arm_unwrapped.expr.clone().children.clone().iter().cloned() + for fi in (*arm_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9893,10 +9738,16 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { + let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { + for fi in (*then_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9913,25 +9764,31 @@ pub fn classify_terminal_per_field( match if_else_branch(expr.clone()) { Some(else_expr) => { let else_unwrapped = - unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() - { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + unwrap_body_terminal(else_expr, let_prov, type_env.clone()); + let else_result = + match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in (*else_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -9955,7 +9812,7 @@ pub fn unwrap_body_terminal( match (*expr.expr_data.clone()).clone() { ExprData::ExprBlock => match expr.children.clone().last().cloned() { Some(last_stmt) => Rc::new(BodyTerminal { - expr: last_stmt.clone(), + expr: last_stmt, let_prov: let_prov, }), None => Rc::new(BodyTerminal { @@ -9997,7 +9854,6 @@ pub fn meet_per_field_results( let mut __result = Vec::new(); for pair in Rc::new( first_result - .clone() .iter() .cloned() .enumerate() @@ -10053,7 +9909,7 @@ pub fn meet_body_provenance_maps( .iter() .cloned() .fold( - first_prov.clone(), + first_prov, |acc: Rc>>, prov: Rc>>| { intersect_prov_maps(acc, prov.clone()) @@ -10096,16 +9952,16 @@ pub fn arm_ctx_from_variant_provenance( name: vname, field_bindings: bindings, .. - } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { + } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); - let extended = bindings.clone().iter().cloned().fold( + call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); + let extended = bindings.iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10123,8 +9979,8 @@ pub fn arm_ctx_from_variant_provenance( call_args.clone(), c.param_order.clone(), c.param_names.clone(), - c.type_env.clone(), - c.func_env.clone(), + (*c.type_env).clone(), + (*c.func_env).clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10152,7 +10008,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10160,7 +10016,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10281,7 +10137,7 @@ pub fn compute_variant_provenance( ); collect_variant_constructors( body, - rt_name.clone(), + rt_name, param_names, param_types, type_env.clone(), @@ -10320,9 +10176,9 @@ pub fn collect_variant_constructors( match (*body.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: pe, .. - } => match pe.clone() { + } => match pe { Some(enum_name) => { - if (enum_name.clone() == parent_enum.clone()) { + if (enum_name == parent_enum) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10359,15 +10215,12 @@ pub fn collect_variant_constructors( ); match v1_rt::map_get(&acc, variant_name.clone()) { Some(existing) => { - let merged = - merge_field_prov_maps(existing.clone(), field_prov_map); - v1_rt::rc_map_insert(acc.clone(), variant_name.clone(), merged) + let merged = merge_field_prov_maps(existing, field_prov_map); + v1_rt::rc_map_insert(acc.clone(), variant_name, merged) + } + None => { + v1_rt::rc_map_insert(acc.clone(), variant_name, field_prov_map) } - None => v1_rt::rc_map_insert( - acc.clone(), - variant_name.clone(), - field_prov_map, - ), } } } else { @@ -10382,8 +10235,8 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - sig.inferred.clone(), - ) == parent_enum.clone()) + (*sig.inferred).clone(), + ) == parent_enum) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10456,13 +10309,13 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { ); match if_else_branch(body.clone()) { Some(eb) => collect_variant_constructors( - eb.clone(), - parent_enum.clone(), + eb, + parent_enum, param_names.clone(), param_types.clone(), type_env.clone(), func_env.clone(), - let_prov.clone(), + let_prov, then_acc, ), None => then_acc, @@ -10479,10 +10332,10 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { func_env.clone(), let_prov.clone(), ); - let new_lp = v1_rt::rc_map_insert(let_prov.clone(), bname.clone(), value_prov); + let new_lp = v1_rt::rc_map_insert(let_prov, bname, value_prov); collect_variant_constructors( - b.clone(), - parent_enum.clone(), + b, + parent_enum, param_names.clone(), param_types.clone(), type_env.clone(), @@ -10511,7 +10364,7 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { .iter() .cloned() .fold( - let_prov.clone(), + let_prov, |lp: Rc>>>>, stmt: Rc| match (*stmt .expr_data @@ -10536,14 +10389,10 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { _ => lp.clone(), }, ); - match stmts - .clone() - .get((stmt_count.clone() - 1) as usize) - .cloned() - { + match stmts.get((stmt_count - 1) as usize).cloned() { Some(last) => collect_variant_constructors( - last.clone(), - parent_enum.clone(), + last, + parent_enum, param_names.clone(), param_types.clone(), type_env.clone(), @@ -10715,7 +10564,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10737,7 +10586,7 @@ pub fn populate_output_provenance( None => acc.clone(), } } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { if !expr_has_self_call( body.clone(), @@ -10756,34 +10605,36 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = - match item.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: rt, - .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, - >, + let variant_prov = match (*item.inferred) + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { + node: rt, .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, >, >, >, - >( - ), - }; + >, + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10798,7 +10649,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10912,19 +10763,19 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: p.inferred.clone(), + inferred: (*p.inferred).clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: p.body.clone(), - transport: p.transport.clone(), + body: (*p.body).clone(), + transport: (*p.transport).clone(), properties: p.properties.clone(), - type_annotation: p.type_annotation.clone(), + type_annotation: (*p.type_annotation).clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: p.match_pattern.clone(), + match_pattern: (*p.match_pattern).clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -10944,7 +10795,7 @@ pub fn infer_property_values( }), diagnostics: Rc::new({ let mut __result = Vec::new(); - for r in results.clone().iter().cloned() { + for r in results.iter().cloned() { __result.extend((*r.1.clone()).iter().cloned()); } __result @@ -10964,7 +10815,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -10975,19 +10826,19 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: p.inferred.clone(), + inferred: (*p.inferred).clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: p.body.clone(), - transport: p.transport.clone(), + body: (*p.body).clone(), + transport: (*p.transport).clone(), properties: p.properties.clone(), - type_annotation: p.type_annotation.clone(), + type_annotation: (*p.type_annotation).clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: p.match_pattern.clone(), + match_pattern: (*p.match_pattern).clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -11011,7 +10862,7 @@ pub fn infer_auth_source_properties( }), diagnostics: Rc::new({ let mut __result = Vec::new(); - for r in results.clone().iter().cloned() { + for r in results.iter().cloned() { __result.extend((*r.1.clone()).iter().cloned()); } __result @@ -11039,16 +10890,16 @@ pub fn infer_transport_node( children: t.children.clone(), connective: t.connective.clone(), params: t.params.clone(), - inferred: t.inferred.clone(), + inferred: (*t.inferred).clone(), return_cardinality: t.return_cardinality.clone(), uses: t.uses.clone(), - body: t.body.clone(), - transport: t.transport.clone(), + body: (*t.body).clone(), + transport: (*t.transport).clone(), properties: prop_result.props.clone(), - type_annotation: t.type_annotation.clone(), + type_annotation: (*t.type_annotation).clone(), is_self_recursive: t.is_self_recursive.clone(), has_non_tail_self_call: t.has_non_tail_self_call.clone(), - match_pattern: t.match_pattern.clone(), + match_pattern: (*t.match_pattern).clone(), expr_data: t.expr_data.clone(), ident: None, })), @@ -11060,20 +10911,20 @@ pub fn infer_transport_node( pub fn infer_item(item: Rc, scope: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let typed_anno = item.type_annotation.clone(); + let typed_anno = (*item.type_annotation).clone(); let transport_scope = if ((item.params.clone().len() as i64) > 0) { build_params_scope(scope.clone(), item.params.clone()) } else { scope.clone() }; - let transport_result = infer_transport_node(item.transport.clone(), transport_scope); - let typed_transport = transport_result.transport.clone(); + let transport_result = infer_transport_node((*item.transport).clone(), transport_scope); + let typed_transport = (*transport_result.transport).clone(); let transport_diags = transport_result.diagnostics.clone(); let props_result = infer_auth_source_properties(item.properties.clone(), scope.clone()); let typed_properties = props_result.props.clone(); let props_diags = props_result.diagnostics.clone(); if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11083,7 +10934,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push(infer_item(c.clone(), scope.clone()).item.clone()); + __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11105,7 +10956,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc diagnostics: v1_rt::concat(transport_diags, props_diags), }) } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) { { let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( @@ -11115,49 +10966,49 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), ) }, ); - let fn_return_expected = if (item.inferred.clone() != None) { + let fn_return_expected = if ((*item.inferred).clone() != None) { Some(resolved_type(item.clone())) } else { None }; let body_result = infer_expr( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), fn_scope.clone(), fn_return_expected, ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); - let inferred_ret = if (item.inferred.clone() != None) { - item.inferred.clone() + let inferred_ret = if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { - body_typed.inferred.clone() + (*body_typed.inferred).clone() }; let is_recursive = expr_has_self_call( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { annotate_descent_evidence( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), item.params.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), fn_scope.locals.clone(), - scope.func_env.clone(), + (*scope.func_env).clone(), ) } else { body_typed.clone() @@ -11171,7 +11022,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push(infer_item(c.clone(), scope.clone()).item.clone()); + .push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11184,15 +11035,15 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc transport: typed_transport, properties: typed_properties, type_annotation: typed_anno, - is_self_recursive: is_recursive.clone(), + is_self_recursive: is_recursive, has_non_tail_self_call: expr_has_non_tail_self_call( - body_typed.clone(), + body_typed, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), true, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11205,17 +11056,17 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() != None)) + if ((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + && ((*item.inferred).clone() != None)) { { let fn_scope = scope.clone(); let body_result = infer_expr( - item.body.clone().clone().unwrap(), - fn_scope.clone(), + (*item.body).clone().clone().unwrap(), + fn_scope, Some(resolved_type(item.clone())), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11224,10 +11075,10 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ident_span: item.ident_span.clone(), children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(body_typed.clone()), + body: Some(body_typed), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11245,26 +11096,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + { { - let data_expected = if (item.type_annotation.clone() != None) { - Some(item.type_annotation.clone().clone().unwrap()) + let data_expected = if ((*item.type_annotation).clone() != None) { + Some((*item.type_annotation).clone().clone().unwrap()) } else { None }; let val_result = infer_expr( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), scope.clone(), data_expected, ); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let inferred_ret = if (item.type_annotation.clone() != None) { + let inferred_ret = if ((*item.type_annotation).clone() != None) { Some(Rc::new(InferredNode::Resolved { - node: item.type_annotation.clone().clone().unwrap(), + node: (*item.type_annotation).clone().clone().unwrap(), })) } else { - val_typed.inferred.clone() + (*val_typed.inferred).clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11276,7 +11128,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(val_typed.clone()), + body: Some(val_typed), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11294,7 +11146,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) + && ((*item.body).clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11305,14 +11158,15 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { - item.inferred.clone() + inferred: if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11341,14 +11195,15 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { - item.inferred.clone() + inferred: if ((*item.inferred).clone() != None) { + (*item.inferred).clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11408,10 +11263,10 @@ pub fn type_node_label( { let authored = authored_name_at(source_indices, n.clone()); if (authored.clone() != "".to_string()) { - authored.clone() + authored } else { - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id.clone(), + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id, _ => n.name.clone(), } } @@ -11426,15 +11281,14 @@ pub fn param_is_generic_decl( let pt = param_node_type_expr(p.clone()); let pname = param_node_name_at(p.clone(), source_indices.clone()); let tname = type_node_label(pt.clone(), source_indices.clone()); - let type_expr_is_var = match pt.inferred.clone() { - Some(inf) => is_type_variable(inf.clone()), + let type_expr_is_var = match (*pt.inferred).clone() { + Some(inf) => is_type_variable(inf), None => false, }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) && (pname.clone() != "".to_string())) - && ((pname.clone() == tname) - || (type_expr_is_var && (pname.clone() == pt.name.clone())))) + && ((pname.clone() == tname) || (type_expr_is_var && (pname == pt.name.clone())))) } } @@ -11449,8 +11303,8 @@ pub fn unify_generics( let bind_name = type_node_label(formal.clone(), source_indices.clone()); let f_bare = (((formal.children.clone().len() as i64) == 0) && (formal.connective.clone() == Connective::NoConnective)); - if ((f_bare - || match formal.inferred.clone().as_deref().cloned() { + if ((f_bare.clone() + || match (*formal.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: _, .. }) => true, _ => false, }) @@ -11518,7 +11372,7 @@ pub fn should_unify_record_lit_generics( let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); (((formal_name.clone() != "".to_string()) && (record_name.clone() != "".to_string())) - && (formal_name.clone() == record_name.clone())) + && (formal_name == record_name)) } } } @@ -11536,13 +11390,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); + authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11555,7 +11409,7 @@ pub fn unify_record_lit_field_walk( { Some(fi) => { let actual_value = field_init_node_value(fi.clone()); - let field_formal = match sf.inferred.clone().as_deref().cloned() { + let field_formal = match (*sf.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -11572,7 +11426,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.clone(), ) } @@ -11593,7 +11447,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11610,7 +11464,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } else { @@ -11618,16 +11472,13 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) - && (formal_name.clone() == record_type_name.clone())) + && (formal_name == record_type_name.clone())) { unify_record_lit_field_walk( - record_lit_expected_fields( - Some(record_type_name.clone()), - scope.clone(), - ), + record_lit_expected_fields(Some(record_type_name), scope.clone()), record.clone(), generic_names.clone(), scope.clone(), @@ -11638,7 +11489,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11648,7 +11499,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11658,7 +11509,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11689,10 +11540,10 @@ pub fn substitute_generics_apply( source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => { - match v1_rt::map_get(&subst, tv_id.clone()) { - Some(c) => c.clone(), + match v1_rt::map_get(&subst, tv_id) { + Some(c) => c, None => n.clone(), } } @@ -11703,7 +11554,7 @@ pub fn substitute_generics_apply( && ((n.params.clone().len() as i64) == 0)); if is_bare { match v1_rt::map_get(&subst, nm) { - Some(c) => c.clone(), + Some(c) => c, None => n.clone(), } } else { @@ -11730,26 +11581,24 @@ pub fn substitute_generics_apply( } __result }); - let new_inferred = match n.inferred.clone().as_deref().cloned() { + let new_inferred = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let new_rt = substitute_generics_apply( rt.clone(), subst.clone(), source_indices.clone(), ); - if v1_rt::rc_ptr_eq(new_rt.clone(), rt.clone()) { - n.inferred.clone() + if v1_rt::rc_ptr_eq(new_rt.clone(), rt) { + (*n.inferred).clone() } else { - Some(Rc::new(InferredNode::Resolved { - node: new_rt.clone(), - })) + Some(Rc::new(InferredNode::Resolved { node: new_rt })) } } - _ => n.inferred.clone(), + _ => (*n.inferred).clone(), }; if ((v1_rt::rc_vec_ptr_eq(new_children.clone(), n.children.clone()) && v1_rt::rc_vec_ptr_eq(new_params.clone(), n.params.clone())) - && (new_inferred.clone() == n.inferred.clone())) + && (new_inferred.clone() == (*n.inferred).clone())) { n.clone() } else { @@ -11757,19 +11606,19 @@ pub fn substitute_generics_apply( name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: new_children.clone(), + children: new_children, connective: n.connective.clone(), - params: new_params.clone(), - inferred: new_inferred.clone(), + params: new_params, + inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -11797,10 +11646,10 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps(b.resolved.clone(), source_indices); - let is_bare_self = ((((b.resolved.clone().connective.clone() + let deps0 = node_type_deps((*b.resolved).clone(), source_indices); + let is_bare_self = (((((*b.resolved).clone().connective.clone() == Connective::NoConnective) - && ((b.resolved.clone().children.clone().len() as i64) == 0)) + && (((*b.resolved).clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11815,7 +11664,7 @@ pub fn deps_excluding_leaf_self( if is_bare_self { Rc::new(vec![]) } else { - deps0.clone() + deps0 } } } @@ -11867,14 +11716,6 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { - if resolved_imports.len() == 1 { - if let Some(imp) = resolved_imports.first().cloned() { - if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - return parent.type_env_cache.clone(); - } - } - return empty_type_env_cache(); - } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11887,58 +11728,29 @@ pub fn union_parent_type_env_caches( ) } -pub fn union_parent_variant_locals( - resolved_imports: Rc>>, - parent_index: Rc>>, -) -> Rc>> { - resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, imp: Rc| match v1_rt::map_get( - &parent_index, - imp.module_path.clone(), - ) { - Some(parent) => v1_rt::rc_map_merge( - acc.clone(), - parent.type_env_cache.clone().variant_locals.clone(), - ), - None => acc.clone(), - }, - ) -} - -pub fn fold_local_coproduct_variant_locals( - bindings: Rc>>, - imported_variants: Rc>, - source_indices: Rc>>, - init_locals: Rc>>, -) -> Rc { - Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - Rc::new(VariantFoldState { - locals: init_locals, - collision_errors: Rc::new(vec![]), - }), - |acc: Rc, binding: Rc| { - let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - { - let binding_enum_name = - authored_name_at(source_indices.clone(), binding.resolved.clone()); - binding - .resolved +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, binding: Rc| { + let is_coproduct = + ((*binding.resolved).clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + (*binding.resolved) .clone() .children .clone() @@ -11946,70 +11758,28 @@ pub fn fold_local_coproduct_variant_locals( .cloned() .fold( acc.clone(), - |vacc: Rc, child: Rc| { + |vacc: Rc>>, child: Rc| { let child_name = - authored_name_at(source_indices.clone(), child.clone()); - let curr_child_is_imported = is_imported_variant_owned_by( - imported_variants.clone(), - child_name.clone(), - binding_enum_name.clone(), - ); - match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { - Some(_prev) => { - if curr_child_is_imported.clone() { - Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }) - } else { - vacc.clone() - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }), + authored_name_at(env.source_indices.clone(), child.clone()); + match v1_rt::map_get(&vacc, child_name.clone()) { + Some(_prev) => vacc.clone(), + None => v1_rt::rc_map_insert( + vacc.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: (*binding.resolved).clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), } }, ) + } else { + acc.clone() } - } else { - acc.clone() - } - }, - ) -} - -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => fold_local_coproduct_variant_locals( - kernel.bindings.clone(), - v1_rt::rc_empty_map::(), - env.source_indices.clone(), - v1_rt::rc_empty_map::>(), - ) - .locals - .clone(), + }, + ), None => v1_rt::rc_empty_map::>(), } } @@ -12066,9 +11836,26 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ); + let filtered_ancestry = + Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) .iter() .cloned() .fold( @@ -12077,8 +11864,10 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -12088,30 +11877,11 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get( - &parent_env.ancestry_str_bindings.clone(), - name.clone(), - ) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ), + ); + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: filtered_str, + ancestry_str_bindings: filtered_ancestry, parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12125,247 +11895,47 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, + parent_index: Rc>>, source_indices: Rc>>, intern_table: Rc, -) -> Rc { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> Rc { + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }) -} - -pub fn build_type_env( - module: Rc, - parent_index: Rc>>, - source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - record_build_type_env_call(); - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, v1_rt::concat( @@ -12383,13 +11953,200 @@ pub fn build_type_env( }, ); let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); - let kernel_cache = type_env_cache_from_bindings( - kernel.bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), ); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let kernel = Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12397,7 +12154,7 @@ pub fn build_type_env( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12407,7 +12164,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12430,7 +12187,7 @@ pub fn build_type_env( ), "'".to_string(), ), - span: imp.target_module.clone().clone().unwrap().span.clone(), + span: (*imp.target_module).clone().clone().unwrap().span.clone(), }), module_name_str.clone(), )]), @@ -12441,7 +12198,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12484,9 +12241,9 @@ pub fn build_type_env( ) } } else { - if (((item.inferred.clone() != None) + if ((((*item.inferred).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && ((*item.body).clone() == None)) { { let alias_node = Rc::new(Node { @@ -12496,7 +12253,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12520,7 +12277,7 @@ pub fn build_type_env( ) } } else { - if ((item.transport.clone() == None) + if (((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12545,8 +12302,8 @@ pub fn build_type_env( } else { if (((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) + && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) { { let bare_node = Rc::new(Node { @@ -12556,7 +12313,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: item.params.clone(), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12585,8 +12342,8 @@ pub fn build_type_env( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -12606,7 +12363,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items(module.module.clone()).iter().cloned().fold( + let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12657,11 +12414,16 @@ pub fn build_type_env( v1_rt::rc_map_insert(acc, ident.clone(), true) }, ); - let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); + let all_local_bindings = v1_rt::rc_map_merge(local_bindings, param_bindings); + let kernel_cache = type_env_cache_from_bindings( + kernel_bindings, + source_indices.clone(), + compiler_recursive_name_set(), + ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12702,52 +12464,53 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -12755,9 +12518,9 @@ pub fn build_type_env( let visible_str_bindings = v1_rt::rc_map_merge(ancestry_str_bindings.clone(), local_str_bindings.clone()); let unresolved_env = Rc::new(TypeEnv { - bindings: all_local_bindings.clone(), - str_bindings: local_str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), + bindings: all_local_bindings, + str_bindings: local_str_bindings, + ancestry_str_bindings: ancestry_str_bindings, parents: scope_parents.clone(), recursive_types: cycle_set, recursive_type_set: cross_type_set, @@ -12767,17 +12530,17 @@ pub fn build_type_env( }); let resolved = resolve_env_bindings( unresolved_env, - module_name_str.clone(), + module_name_str, local_name_set, all_deps_map.clone(), ); - let resolved_env_out = resolved.env.clone(); + let resolved_env_out = (*resolved.env).clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), str_bindings: resolved_env_out.str_bindings.clone(), ancestry_str_bindings: resolved_env_out.ancestry_str_bindings.clone(), - parents: scope_parents.clone(), + parents: scope_parents, recursive_types: resolved_env_out.recursive_types.clone(), recursive_type_set: resolved_env_out.recursive_type_set.clone(), inductive_fields: resolved_env_out.inductive_fields.clone(), @@ -12785,9 +12548,9 @@ pub fn build_type_env( intern_table: intern_table.clone(), }); let type_env_cache = Rc::new(TypeEnvCache { - deps_map: all_deps_map.clone(), + deps_map: all_deps_map, str_bindings: visible_str_bindings, - cycle_set_str: cycle_set_str.clone(), + cycle_set_str: cycle_set_str, variant_locals: v1_rt::rc_empty_map::>(), }); Rc::new(BuildTypeEnvResult { @@ -12804,7 +12567,6 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { - record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12959,7 +12721,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12967,7 +12729,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12978,7 +12740,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -13021,9 +12783,9 @@ pub fn build_type_env_unresolved( ) } } else { - if (((item.inferred.clone() != None) + if ((((*item.inferred).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && ((*item.body).clone() == None)) { { let alias_node = Rc::new(Node { @@ -13033,7 +12795,7 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -13057,7 +12819,7 @@ pub fn build_type_env_unresolved( ) } } else { - if ((item.transport.clone() == None) + if (((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -13082,8 +12844,8 @@ pub fn build_type_env_unresolved( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -13103,14 +12865,14 @@ pub fn build_type_env_unresolved( }, ); let kernel_cache = type_env_cache_from_bindings( - kernel_bindings.clone(), + kernel_bindings, source_indices.clone(), compiler_recursive_name_set(), ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13151,52 +12913,53 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -13204,10 +12967,10 @@ pub fn build_type_env_unresolved( let visible_str_bindings = v1_rt::rc_map_merge(ancestry_str_bindings.clone(), local_str_bindings.clone()); let unresolved_env = Rc::new(TypeEnv { - bindings: local_bindings.clone(), - str_bindings: local_str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - parents: scope_parents.clone(), + bindings: local_bindings, + str_bindings: local_str_bindings, + ancestry_str_bindings: ancestry_str_bindings, + parents: scope_parents, recursive_types: cycle_set, recursive_type_set: cross_type_set, inductive_fields: merged_inductive_fields, @@ -13215,9 +12978,9 @@ pub fn build_type_env_unresolved( intern_table: intern_table.clone(), }); let type_env_cache = Rc::new(TypeEnvCache { - deps_map: all_deps_map.clone(), + deps_map: all_deps_map, str_bindings: visible_str_bindings, - cycle_set_str: cycle_set_str.clone(), + cycle_set_str: cycle_set_str, variant_locals: v1_rt::rc_empty_map::>(), }); Rc::new(BuildTypeEnvResult { @@ -13245,14 +13008,14 @@ pub fn build_item_info( let item_name_str = authored_name_at(source_indices.clone(), item.clone()); match kind.clone() { ItemKind::FuncItem => Rc::new(ItemInfo { - name: item_name_str.clone(), + name: item_name_str, module_name: module_name, - kind: kind.clone(), - service_names: if (item.body.clone() == None) { + kind: kind, + service_names: if ((*item.body).clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), source_indices.clone(), ) }, @@ -13264,41 +13027,41 @@ pub fn build_item_info( ItemKind::FnItem => Rc::new(ItemInfo { name: item_name_str.clone(), module_name: module_name, - kind: kind.clone(), - service_names: if (item.body.clone() == None) { + kind: kind, + service_names: if ((*item.body).clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), source_indices.clone(), ) }, resource_names: res_names, params: item.params.clone(), - is_self_recursive: if (item.body.clone() == None) { + is_self_recursive: if ((*item.body).clone() == None) { false } else { expr_has_self_call( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), item_name_str.clone(), source_indices.clone(), ) }, - has_non_tail_self_call: if (item.body.clone() == None) { + has_non_tail_self_call: if ((*item.body).clone() == None) { false } else { expr_has_non_tail_self_call( - item.body.clone().clone().unwrap(), - item_name_str.clone(), + (*item.body).clone().clone().unwrap(), + item_name_str, true, source_indices.clone(), ) }, }), _ => Rc::new(ItemInfo { - name: item_name_str.clone(), + name: item_name_str, module_name: module_name, - kind: kind.clone(), + kind: kind, service_names: Rc::new(vec![]), resource_names: res_names, params: item.params.clone(), @@ -13312,14 +13075,14 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = resolved.item.clone(); + let ritem = (*resolved.item).clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) - && (ritem.inferred.clone() != None)) - && (ritem.body.clone() != None)); + && ((*ritem.inferred).clone() != None)) + && ((*ritem.body).clone() != None)); let func_sig = if (is_func || is_zero_arg_func) { { - let declared_rt = if (ritem.inferred.clone() != None) { + let declared_rt = if ((*ritem.inferred).clone() != None) { Some(resolved_type(ritem.clone())) } else { None @@ -13339,42 +13102,40 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) + let svc_entries = if (((*ritem.transport).clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } - } else { - None - }; + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = if (((*ritem.transport).clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) + } + } else { + None + }; Rc::new(ItemContribution { resolved_item: ritem.clone(), resolve_diagnostics: resolved.diagnostics.clone(), func_sig: func_sig, svc_entries: svc_entries, svc_local: svc_local, - item_info: build_item_info( - ritem.clone(), - env.source_indices.clone(), - module_name.clone(), - ), + item_info: build_item_info(ritem, env.source_indices.clone(), module_name.clone()), }) } } @@ -13393,36 +13154,40 @@ pub fn fold_module_contributions( match remaining.clone().first().cloned() { None => { break Rc::new(LocalContributionState { - resolved_items: resolved_items, - func_sigs: func_sigs, - svc_registry: svc_registry, - svc_locals: svc_locals, - item_registry: item_registry, - diag_chunks: diag_chunks, + resolved_items: resolved_items.clone(), + func_sigs: func_sigs.clone(), + svc_registry: svc_registry.clone(), + svc_locals: svc_locals.clone(), + item_registry: item_registry.clone(), + diag_chunks: diag_chunks.clone(), }); } Some(contribution) => { - let next_func_sigs = match contribution.func_sig.clone() { - Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), - None => func_sigs, + let next_func_sigs = match (*contribution.func_sig).clone() { + Some(sig) => { + v1_rt::rc_map_insert(func_sigs.clone(), sig.name.clone(), sig.clone()) + } + None => func_sigs.clone(), }; let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { v1_rt::rc_map_insert( - svc_registry, + svc_registry.clone(), authored_name_at( source_indices.clone(), - contribution.resolved_item.clone(), + (*contribution.resolved_item).clone(), ), contribution.svc_entries.clone(), ) } else { - svc_registry + svc_registry.clone() }; let next_svc_locals = match contribution.svc_local.clone() { - Some(binding) => { - v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) - } - None => svc_locals, + Some(binding) => v1_rt::rc_map_insert( + svc_locals.clone(), + binding.name.clone(), + binding.clone(), + ), + None => svc_locals.clone(), }; { let __tco_0 = Rc::new( @@ -13433,10 +13198,10 @@ pub fn fold_module_contributions( .collect::>(), ); let __tco_1 = - v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); - let __tco_2 = next_func_sigs; - let __tco_3 = next_svc_registry; - let __tco_4 = next_svc_locals; + v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); + let __tco_2 = next_func_sigs.clone(); + let __tco_3 = next_svc_registry.clone(); + let __tco_4 = next_svc_locals.clone(); let __tco_5 = v1_rt::rc_map_insert( item_registry, contribution.item_info.clone().name.clone(), @@ -13458,76 +13223,315 @@ pub fn fold_module_contributions( } } -pub fn enum_parents_for_variant_in_items( - variant_name: String, - items: Rc>>, +pub fn constructor_binding_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn insert_variant_owner_checked( + state: Rc, + arm_name: String, + owner: Rc, source_indices: Rc>>, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()) - == variant_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } + module_name: String, +) -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); + let owner_name = authored_name_at(source_indices.clone(), owner.clone()); + let same_owner = (((prev_name.clone() == owner_name.clone()) + && ((*prev.resolved).clone().span.clone().file.clone() + == owner.span.clone().file.clone())) + && ((*prev.resolved).clone().span.clone().start.clone() + == owner.span.clone().start.clone())); + if same_owner { + state.clone() + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name.clone(), + enum1: prev_name, + enum2: owner_name, + span: owner.span.clone(), + }), + module_name, + )]), + ), + }) } - __result - }) - .iter() - .cloned() - { - __result.push(authored_name_at(source_indices.clone(), item.clone())); } - __result - }) + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name.clone(), + resolved: owner.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } } -pub fn unique_imported_variant_owner( - variant_name: String, +pub fn bind_coproduct_item_arms( + state: Rc, + item: Rc, + source_indices: Rc>>, + module_name: String, +) -> Rc { + item.children.clone().iter().cloned().fold( + state, + |vacc: Rc, child: Rc| { + insert_variant_owner_checked( + vacc, + authored_name_at(source_indices.clone(), child.clone()), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + }, + ) +} + +pub fn build_local_variants( items: Rc>>, source_indices: Rc>>, -) -> Option { - { - let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); - if ((parents.clone().len() as i64) == 1) { - parents.clone().first().cloned() - } else { - None + module_name: String, + init: Rc, +) -> Rc { + items + .iter() + .cloned() + .fold(init, |acc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + acc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + acc.clone() + } + }) +} + +pub fn reexport_chain_authority() -> String { + thread_local! { + static CACHED: String = { + "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn owner_of_exported_arm( + mut module_path: String, + mut arm_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path.clone()) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for c in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), c.clone()) + == arm_name.clone()) + { + __found = true; + break; + } + } + __found + } { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own.clone() { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == arm_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport.clone() { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } } } } -pub fn is_imported_variant_owned_by( - imported_variants: Rc>, - variant_name: String, - enum_name: String, -) -> bool { - match v1_rt::map_get(&imported_variants, variant_name) { - Some(unique_parent) => (unique_parent.clone() == enum_name), - None => false, +pub fn exported_coproduct_item( + mut module_path: String, + mut enum_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path.clone()) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if (authored_name_at(source_indices.clone(), item.clone()) + == enum_name.clone()) + { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own.clone() { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == enum_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport.clone() { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } + } } } @@ -13535,35 +13539,70 @@ pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, -) -> Rc> { + module_name: String, + init: Rc, +) -> Rc { resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, imp: Rc| { - imp.specific_names.clone().iter().cloned().fold( - acc, - |inner: Rc>, variant_name: String| { - if v1_rt::map_contains_key(&inner, variant_name.clone()) { - inner.clone() - } else { - { - let source_items = - match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - match unique_imported_variant_owner( - variant_name.clone(), - source_items.clone(), - source_indices.clone(), - ) { - Some(parent) => v1_rt::rc_map_insert( - inner.clone(), - variant_name.clone(), - parent.clone(), - ), - None => inner.clone(), + init, + |acc: Rc, imp: Rc| { + let with_glob = if imp.is_all.clone() { + { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.clone().iter().cloned().fold( + acc.clone(), + |iacc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + iacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + iacc.clone() } - } + }, + ) + } + } else { + acc.clone() + }; + imp.specific_names.clone().iter().cloned().fold( + with_glob.clone(), + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms( + nacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => nacc.clone(), + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked( + after_enum.clone(), + name.clone(), + owner.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => after_enum.clone(), } }, ) @@ -13571,94 +13610,6 @@ pub fn build_imported_variants( ) } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain -// followers — a module re-exports its specific-name imports, so the binder -// walks the acyclic import chain to the defining module's coproduct. Replaced -// by regen's true emission in the convergence commit. -pub fn owner_of_exported_arm( - module_path: String, - arm_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && item - .children - .iter() - .cloned() - .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == arm_name) - }); - match reexport { - Some(imp) => owner_of_exported_arm( - authored_name_at(source_indices.clone(), imp), - arm_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - -pub fn exported_coproduct_item( - module_path: String, - enum_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && authored_name_at(source_indices.clone(), item.clone()) == enum_name - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == enum_name) - }); - match reexport { - Some(imp) => exported_coproduct_item( - authored_name_at(source_indices.clone(), imp), - enum_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - pub fn build_module_context( contributions: Rc>>, parent_index: Rc>>, @@ -13677,134 +13628,21 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional - // realization of the new v1.compiler.infer dag source — replaced - // wholesale by regen output in the convergence commit. Constructor - // namespace is FLAT: local coproduct arms + direct imports' - // contributions; the binding carries the owner NODE; one arm name - // bound to two different owners = VariantCollision (per-file wall). - let insert_variant_owner_checked = |state: Rc, - arm_name: String, - owner: Rc| - -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = - authored_name_at(env.source_indices.clone(), prev.resolved.clone()); - let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); - let same_owner = prev_name == owner_name - && prev.resolved.span.file == owner.span.file - && prev.resolved.span.start == owner.span.start; - if same_owner { - state - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name, - enum1: prev_name, - enum2: owner_name, - span: owner.span.clone(), - }), - module_name.clone(), - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name, - resolved: owner, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } - }; - let bind_coproduct_item_arms = - |state: Rc, item: Rc| -> Rc { - item.children - .clone() - .iter() - .cloned() - .fold(state, |vacc, child| { - insert_variant_owner_checked( - vacc, - authored_name_at(env.source_indices.clone(), child.clone()), - item.clone(), - ) - }) - }; - let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( + let local_variant_fold = build_local_variants( + local.resolved_items.clone(), + env.source_indices.clone(), + module_name.clone(), Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), - |acc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(acc, item) - } else { - acc - } - }, ); - let variant_fold = resolved_imports.clone().iter().cloned().fold( + let variant_fold = build_imported_variants( + resolved_imports.clone(), + parent_index.clone(), + env.source_indices.clone(), + module_name.clone(), local_variant_fold, - |acc: Rc, imp: Rc| { - // Glob (is_all) imports bind the target's OWN coproduct arms only. - let with_glob = if imp.is_all { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.iter().cloned().fold( - acc, - |iacc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(iacc, item) - } else { - iacc - } - }, - ) - } else { - acc - }; - // Specific names resolve through the re-export chain to the - // defining module (owner_of_exported_arm / exported_coproduct_item). - imp.specific_names.iter().cloned().fold( - with_glob, - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms(nacc, item), - None => nacc, - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked(after_enum, name, owner), - None => after_enum, - } - }, - ) - }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13821,7 +13659,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), + Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), None => Rc::new(vec![]), }) .iter() @@ -13834,7 +13672,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name, + module_name.clone(), env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13848,10 +13686,10 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: resolve_result.func_env.clone(), + func_env: (*resolve_result.func_env).clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, - variant_locals: env_variant_locals.clone(), + variant_locals: env_variant_locals, item_registry: local.item_registry.clone(), diagnostics: v1_rt::concat( v1_rt::concat( @@ -13889,7 +13727,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = env_result.env.clone(); + let env = (*env_result.env).clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13905,7 +13743,7 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: resolved.module.clone(), + module: (*resolved.module).clone(), items: Rc::new(vec![]), type_env: env.clone(), type_env_cache: env_cache.clone(), @@ -13919,10 +13757,10 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), resolved.module.clone()); + authored_name_at(source_indices.clone(), (*resolved.module).clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items(resolved.module.clone()).iter().cloned() { + for item in module_items((*resolved.module).clone()).iter().cloned() { __result.push(analyze_item( item.clone(), env.clone(), @@ -13941,16 +13779,16 @@ pub fn typecheck_module( let data_locals = ctx.resolved_items.clone().iter().cloned().fold( ctx.locals.clone(), |acc: Rc>>, item: Rc| { - if ((((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() == None)) - && (item.type_annotation.clone() != None)) + if (((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + && ((*item.inferred).clone() == None)) + && ((*item.type_annotation).clone() != None)) { v1_rt::rc_map_insert( acc.clone(), authored_name_at(source_indices.clone(), item.clone()), Rc::new(TypeBinding { name: authored_name_at(source_indices.clone(), item.clone()), - resolved: item.type_annotation.clone().clone().unwrap(), + resolved: (*item.type_annotation).clone().clone().unwrap(), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ) @@ -13961,7 +13799,7 @@ pub fn typecheck_module( ); let infer_scope = Rc::new(InferScope { type_env: env.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13973,39 +13811,39 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push(tir.item.clone()); + __result.push((*tir.item).clone()); } __result }); let infer_diags = Rc::new({ let mut __result = Vec::new(); - for tir in typed_item_results.clone().iter().cloned() { + for tir in typed_item_results.iter().cloned() { __result.extend((*tir.diagnostics.clone()).iter().cloned()); } __result }); let updated_func_env = populate_output_provenance( typed_items.clone(), - ctx.func_env.clone(), + (*ctx.func_env).clone(), env.clone(), data_locals.clone(), ); let reannotated_items = Rc::new({ let mut __result = Vec::new(); - for item in typed_items.clone().iter().cloned() { + for item in typed_items.iter().cloned() { __result.push( - if (item.is_self_recursive.clone() && (item.body.clone() != None)) { + if (item.is_self_recursive.clone() && ((*item.body).clone() != None)) { Rc::new(Node { name: item.name.clone(), span: item.span.clone(), ident_span: item.ident_span.clone(), children: item.children.clone(), params: item.params.clone(), - inferred: item.inferred.clone(), + inferred: (*item.inferred).clone(), return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), body: Some(annotate_descent_evidence( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), authored_name_at(source_indices.clone(), item.clone()), item.params.clone(), env.clone(), @@ -14013,12 +13851,12 @@ pub fn typecheck_module( updated_func_env.clone(), )), connective: item.connective.clone(), - transport: item.transport.clone(), + transport: (*item.transport).clone(), properties: item.properties.clone(), - type_annotation: item.type_annotation.clone(), + type_annotation: (*item.type_annotation).clone(), is_self_recursive: item.is_self_recursive.clone(), has_non_tail_self_call: item.has_non_tail_self_call.clone(), - match_pattern: item.match_pattern.clone(), + match_pattern: (*item.match_pattern).clone(), expr_data: item.expr_data.clone(), ident: None, }) @@ -14030,35 +13868,35 @@ pub fn typecheck_module( __result }); let typed_base = module_node( - resolved_module_name.clone(), - module_imports(resolved.module.clone()), + resolved_module_name, + module_imports((*resolved.module).clone()), ctx.resolved_items.clone(), - resolved.module.clone().span.clone(), + (*resolved.module).clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: resolved.module.clone().ident_span.clone(), + ident_span: (*resolved.module).clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: env.clone(), + type_env: env, type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), cycle_set_str: env_cache.cycle_set_str.clone(), variant_locals: ctx.variant_locals.clone(), }), - func_env: updated_func_env.clone(), + func_env: updated_func_env, item_registry: ctx.item_registry.clone(), }), diagnostics: v1_rt::concat( v1_rt::concat( - v1_rt::concat(env_diags.clone(), ctx.diagnostics.clone()), + v1_rt::concat(env_diags, ctx.diagnostics.clone()), infer_diags, ), - seed_diags.clone(), + seed_diags, ), }) } @@ -14121,7 +13959,7 @@ pub fn resolve_env_bindings( Rc::new(vec![]), local_names.clone(), deps_map, - (remaining.clone().len() as i64), + (remaining.len() as i64), ) } } @@ -14187,12 +14025,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14210,7 +14048,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14251,11 +14089,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14273,7 +14111,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14301,7 +14139,7 @@ pub fn topo_resolve_types( __result }); { - let __tco_0 = next_remaining; + let __tco_0 = next_remaining.clone(); let __tco_1 = Rc::new(TypeEnv { bindings: ready_accum.bindings.clone(), str_bindings: ready_accum.str_bindings.clone(), @@ -14344,7 +14182,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); + let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14367,7 +14205,7 @@ pub fn collect_parent_envs( ), "'".to_string(), ), - span: imp.target_module.clone().clone().unwrap().span.clone(), + span: (*imp.target_module).clone().clone().unwrap().span.clone(), }), resolved_mod_name.clone(), )]), @@ -14391,7 +14229,7 @@ pub fn variant_has_positional_payload_shape( ) -> bool { (((variant.children.clone().len() as i64) == 1) && match variant.children.clone().first().cloned() { - Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), + Some(f) => (field_node_name_at(f, source_indices) == "0".to_string()), None => false, }) } @@ -14405,7 +14243,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items .clone() .iter() @@ -14470,7 +14308,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14525,9 +14363,11 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().source_indices.clone(), + )) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14558,7 +14398,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>(), }); let built_raw = modules.clone().iter().cloned().fold( - init.clone(), + init, |state: Rc, typed_module: Rc| { typed_module.items.clone().iter().cloned().fold( state, @@ -14566,7 +14406,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &m.type_env.clone().recursive_type_set.clone(), + &(*m.type_env).clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), + intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14679,13 +14519,13 @@ pub fn typecheck_modules( match remaining.clone().first().cloned() { None => { let expanded_registry = - expand_transitive_services(modules.clone(), item_registry, 5); + expand_transitive_services(modules.clone(), item_registry.clone(), 5); break Rc::new(TypedGraph { modules: modules.clone(), - item_registry: expanded_registry, + item_registry: expanded_registry.clone(), diagnostics: Rc::new({ let mut __result = Vec::new(); - for c in diag_chunks.iter().cloned() { + for c in diag_chunks.clone().iter().cloned() { __result.extend((*c.clone()).iter().cloned()); } __result @@ -14717,13 +14557,13 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), typed.module.clone()), + authored_name_at(source_indices.clone(), (*typed.module).clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); let __tco_4 = v1_rt::rc_list_push( v1_rt::rc_list_push(diag_chunks, parent_result.diagnostics.clone()), - tc_diags, + tc_diags.clone(), ); remaining = __tco_0; modules = __tco_1; @@ -14733,201 +14573,516 @@ pub fn typecheck_modules( continue; } } - } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct StrBindingsRewireAccum { + pub str_bindings: Rc>>, + pub ancestry_str_bindings: Rc>>, +} + +pub fn import_module_path_at( + imp: Rc, + source_indices: Rc>>, +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn local_authority_binding(owner: Rc, name: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values( + &(*owner.type_env).clone().bindings.clone(), + )) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .first() + .cloned() + { + Some(binding) => Some(binding), + None => None, + } +} + +pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if module_exports_type_name(m.clone(), name.clone()) { + __result.push(m); + } + } + __result + }) + .len() as i64) +} + +pub fn local_authority_for_name_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn local_authority_for_name( + modules: Rc>>, + name: String, +) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) + { + __result.push(m); + } + } + __result + }) + .last() + .cloned() + { + Some(owner) => Some(owner), + None => None, + } +} + +pub fn module_exports_type_name(m: Rc, name: String) -> bool { + ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) +} + +pub fn direct_import_exporter_count( + m: Rc, + name: String, + index: Rc>>, + source_indices: Rc>>, +) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*m.module).clone()).iter().cloned() { + if { + let path = import_module_path_at(imp.clone(), source_indices.clone()); + match v1_rt::map_get(&index, path.clone()) { + Some(parent) => module_exports_type_name(parent.clone(), name.clone()), + None => false, + } + } { + __result.push(imp); + } + } + __result + }) + .len() as i64) +} + +pub fn rewire_inherited_str_binding( + modules: Rc>>, + module_index: Rc>>, + consumer: Rc, + source_indices: Rc>>, + local_names: Rc>, + str_bindings: Rc>>, + ancestry_str_bindings: Rc>>, + name: String, +) -> Rc { + if ((v1_rt::set_contains(&local_names, name.clone()) + || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) + > 1)) + || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) + { + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } else { + match local_authority_for_name(modules.clone(), name.clone()) { + Some(owner) => match local_authority_binding(owner, name.clone()) { + Some(canonical) => { + let ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings.clone(), + name.clone(), + canonical.clone(), + ); + let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { + Some(_) => { + v1_rt::rc_map_insert(str_bindings.clone(), name.clone(), canonical) + } + None => str_bindings.clone(), + }; + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + }, + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + } + } +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + { + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), (*m.module).clone()), + m.clone(), + ) + }, + ); + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + __result.push({ + let local_names = + Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { + v1_rt::rc_set_insert(acc, b.name.clone()) + }); + let ancestry_keys = Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().ancestry_str_bindings.clone(), + )); + let str_keys = + Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); + let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); + let rewired = inherited_keys.clone().iter().cloned().fold( + Rc::new(StrBindingsRewireAccum { + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + }), + |acc: Rc, name: String| { + rewire_inherited_str_binding( + modules.clone(), + index.clone(), + m.clone(), + source_indices.clone(), + local_names.clone(), + acc.str_bindings.clone(), + acc.ancestry_str_bindings.clone(), + name.clone(), + ) + }, + ); + Rc::new(TypedModule { + module: (*m.module).clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: rewired.str_bindings.clone(), + ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), + parents: (*m.type_env).clone().parents.clone(), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: (*m.func_env).clone(), + item_registry: m.item_registry.clone(), + }) + }); + } + __result + }) } } -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, -) -> Rc>> { - record_rewire_type_env_import_str_binding_call(); - fn local_authority_binding(owner: Rc, name: String) -> Option> { - owner - .type_env - .bindings - .values() - .find(|b| b.name.clone() == name) - .cloned() - } - - fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { - modules - .iter() - .filter(|m| module_exports_type_name((**m).clone(), name)) - .count() - } - - fn local_authority_for_name( - modules: Rc>>, - name: String, - ) -> Option> { - // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) - modules + intern_table: Rc, +) -> Rc { + { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() - .rev() - .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - } - - fn module_exports_type_name(m: Rc, name: &str) -> bool { - m.type_env - .bindings - .values() - .any(|b| b.name.as_str() == name) - } - - fn direct_import_exporter_count( - m: Rc, - name: &str, - index: &HashMap>, - source_indices: Rc>>, - ) -> usize { - module_imports(m.module.clone()) - .iter() - .filter(|imp| { - let path = import_module_path_at((*imp).clone(), source_indices.clone()); - index.get(&path).map_or(false, |parent| { - module_exports_type_name(parent.clone(), name) - }) - }) - .count() - } - - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), m.module.clone()), - m.clone(), - ) - }, - ); - - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - let local_names: std::collections::HashSet = m - .type_env - .bindings - .values() - .map(|b| b.name.clone()) - .collect(); - let mut str_bindings = m.type_env.str_bindings.clone(); - let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); - let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() - .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - .filter(|name| !local_names.contains(name)) - .collect(); - inherited_names.sort(); - for name in inherited_names { - if direct_import_exporter_count( - m.clone(), - name.as_str(), - &index, - source_indices.clone(), - ) > 1 - || global_type_exporter_count(modules.clone(), name.as_str()) > 1 - { - continue; - } - if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { - if let Some(canonical) = local_authority_binding(owner, name.clone()) { - if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { - Some(existing) => { - Rc::ptr_eq(&existing.resolved, &canonical.resolved) - && existing.name == canonical.name - } - None => false, - } { - continue; - } - ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings, - name.clone(), - canonical.clone(), - ); - if v1_rt::map_contains_key(&str_bindings, name.clone()) { - str_bindings = - v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); - } - } - } + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } - __result.push(Rc::new(TypedModule { - module: m.module.clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: m.type_env.bindings.clone(), - str_bindings, - ancestry_str_bindings, - parents: m.type_env.parents.clone(), - recursive_types: m.type_env.recursive_types.clone(), - recursive_type_set: m.type_env.recursive_type_set.clone(), - inductive_fields: m.type_env.inductive_fields.clone(), - source_indices: m.type_env.source_indices.clone(), - intern_table: m.type_env.intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), - item_registry: m.item_registry.clone(), - })); - } - __result - }) + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices, + intern_table: intern_table.clone(), + }) + } } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { - record_rewire_type_env_parent_links_call(); { - let intern_table = modules - .first() - .map(|m| m.type_env.intern_table.clone()) - .unwrap_or_else(empty_intern_table); - let shared_kernel = modules - .iter() - .find_map(|m| { - m.type_env.parents.last().and_then(|kernel| { - if kernel.bindings.is_empty() { - None - } else { - Some(kernel.clone()) - } - }) - }) - .unwrap_or_else(|| { - compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) - }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, ); + let shared_kernel = match modules.clone().iter().cloned().fold( + None, + |acc: Optional, m: Rc| match acc.clone() { + Some(_) => acc.clone(), + None => match (*m.type_env).clone().parents.clone().last().cloned() { + Some(kernel) => Some(kernel.clone()), + None => None, + }, + }, + ) { + Some(kernel) => kernel, + None => match modules.clone().first().cloned() { + Some(m) => compiler_kernel_type_env( + source_indices.clone(), + (*m.type_env).clone().intern_table.clone(), + ), + None => compiler_kernel_type_env(source_indices.clone(), empty_intern_table()), + }, + }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = @@ -14935,7 +15090,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - parent.type_env.clone(), + (*parent.type_env).clone(), )]), None => Rc::new(vec![]), } @@ -14946,23 +15101,28 @@ pub fn rewire_type_env_parent_links( } __result }); - let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: m.type_env.clone().bindings.clone(), - str_bindings: m.type_env.clone().str_bindings.clone(), - ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), - parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), - recursive_types: m.type_env.clone().recursive_types.clone(), - recursive_type_set: m.type_env.clone().recursive_type_set.clone(), - inductive_fields: m.type_env.clone().inductive_fields.clone(), - source_indices: m.type_env.clone().source_indices.clone(), - intern_table: m.type_env.clone().intern_table.clone(), + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + parents: v1_rt::concat( + import_parents.clone(), + Rc::new(vec![shared_kernel.clone()]), + ), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), + func_env: (*m.func_env).clone(), item_registry: m.item_registry.clone(), }) }); @@ -14982,7 +15142,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, @@ -14993,13 +15153,13 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![parent.func_env.clone()]), + Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), None => Rc::new(vec![]), } }) @@ -15010,12 +15170,12 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), - type_env: m.type_env.clone(), + type_env: (*m.type_env).clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: m.func_env.clone().local.clone(), + local: (*m.func_env).clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), @@ -15040,7 +15200,7 @@ pub fn reconcile( let modules = rewire_func_env_parent_links(modules.clone(), source_indices.clone()); let emit_info = build_emit_graph_info(modules.clone()); Rc::new(ResolvedGraph { - modules: modules.clone(), + modules: modules, item_registry: typed.item_registry.clone(), diagnostics: typed.diagnostics.clone(), emit_graph_info: emit_info, diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index c3d02096a6e..0a3eab54410 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -83,8 +83,8 @@ pub fn keyed_collection_parts( match n.children.clone().first().cloned() { Some(key_child) => match n.children.clone().get(1 as usize).cloned() { Some(value_child) => Some(Rc::new(KeyedCollectionParts { - key_type: resolved_type(key_child.clone()), - value_type: resolved_type(value_child.clone()), + key_type: resolved_type(key_child), + value_type: resolved_type(value_child), })), None => None, }, @@ -131,8 +131,8 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - parts.key_type.clone(), - normed_index.clone(), + (*parts.key_type).clone(), + normed_index, source_indices.clone(), ) { Rc::new(vec![]) @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality(parts.value_type.clone()), + with_optional_cardinality((*parts.value_type).clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), @@ -171,10 +171,8 @@ pub fn check_index_access_node( )) && index_is_int) { { - let elem = for_each_element_type_node( - normed.clone(), - source_indices.clone(), - ); + let elem = + for_each_element_type_node(normed, source_indices.clone()); access_result( with_optional_cardinality(elem), Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 0dc55228a93..bcd9d672ab4 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -110,7 +110,7 @@ pub fn kahn_remove_loop( }); let final_state = kahn_cycle_drain( initial_queue, - in_degree.clone(), + in_degree, reverse_adj, 0, (remaining.clone().len() as i64), @@ -160,7 +160,7 @@ pub fn kahn_cycle_drain( removed_count: removed_count.clone(), }), |state: Rc, node: String| { - let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); + let state = v1_rt::take_owned_counted(state, "src/v1/04_cycle.dag:2601:state"); { let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { Some(v) => v.clone(), @@ -210,7 +210,7 @@ pub fn kahn_cycle_drain( }) }); { - let __tco_0 = next_queue; + let __tco_0 = next_queue.clone(); let __tco_1 = result.in_degree.clone(); let __tco_2 = result.removed_count.clone(); let __tco_3 = (fuel - 1); @@ -229,11 +229,10 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .map(|b| b.name.clone()) - .collect(); - __result.sort(); + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { + __result.push(b.name.clone()); + } __result }); let name_set = all_names @@ -280,7 +279,7 @@ pub fn detect_type_cycles_kahn( }); let result = Rc::new({ let mut __result = Vec::new(); - for n in all_names.clone().iter().cloned() { + for n in all_names.iter().cloned() { if v1_rt::set_contains(&cm_set, n.clone()) { __result.push(n); } diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b19d756df6d..b46b0e46826 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -284,7 +284,7 @@ pub fn build_struct_field_summaries( |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); - if (child.inferred.clone() == None) { + if ((*child.inferred).clone() == None) { acc.clone() } else { { @@ -321,8 +321,8 @@ pub fn find_first_enum_field_node( source_indices: Rc>>, ) -> Option> { match variants.first().cloned() { - Some(variant) => match find_child_named(variant.clone(), field_name, source_indices) { - Some(field_child) => Some(field_child.clone()), + Some(variant) => match find_child_named(variant, field_name, source_indices) { + Some(field_child) => Some(field_child), None => None, }, None => None, @@ -452,8 +452,7 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child - .inferred + |acc: Rc>, child: Rc| match (*child.inferred) .clone() .as_deref() .cloned() @@ -463,8 +462,8 @@ pub fn build_field_type_map( source_indices.clone(), normalize_access_type_node(ft.clone()), ); - let ft_is_type_var = if (ft.inferred.clone() != None) { - is_type_variable(ft.inferred.clone().clone().unwrap()) + let ft_is_type_var = if ((*ft.inferred).clone() != None) { + is_type_variable((*ft.inferred).clone().clone().unwrap()) } else { false }; @@ -489,7 +488,7 @@ pub fn build_type_summary( { if (((item.connective.clone() == Connective::NoConnective) || (item.connective.clone() == Connective::Arrow)) - || (item.transport.clone() != None)) + || ((*item.transport).clone() != None)) { return None; } @@ -504,7 +503,7 @@ pub fn build_type_summary( let has_fn = { let mut __found = false; for child in item.children.clone().iter().cloned() { - if match child.inferred.clone().as_deref().cloned() { + if match (*child.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.connective.clone() == Connective::Arrow) } @@ -664,7 +663,7 @@ pub fn add_emit_item_summary( let v_has_fn = { let mut __found = false; for vc in variant.children.clone().iter().cloned() { - if match vc.inferred.clone().as_deref().cloned() { + if match (*vc.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => (rt.connective.clone() == Connective::Arrow), @@ -708,8 +707,7 @@ pub fn add_emit_item_summary( } _ => state.type_summaries.clone(), }; - let next_summaries = - v1_rt::rc_map_insert(with_variants, summary.name.clone(), summary.clone()); + let next_summaries = v1_rt::rc_map_insert(with_variants, summary.name.clone(), summary); Rc::new(EmitInfoBuildState { type_summaries: next_summaries, }) diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index dc7b6acbab3..481902244d0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,82 +17,12 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -use std::sync::atomic::{AtomicU64, Ordering}; - -// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). -static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); -static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); -static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); - -pub fn flatten_visible_parent_recurses() -> u64 { - FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) -} - -pub fn build_type_env_calls() -> u64 { - BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) -} - -pub fn merge_type_env_cache_calls() -> u64 { - MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_parent_links_calls() -> u64 { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_import_str_binding_calls() -> u64 { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) -} - -pub fn reset_flatten_visible_profile() { - FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); -} - -pub fn reset_type_env_lookup_profile() { - reset_flatten_visible_profile(); - BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); - MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); -} - -pub fn maybe_print_type_env_lookup_profile() { - if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { - eprintln!( - "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", - flatten_visible_parent_recurses(), - build_type_env_calls(), - merge_type_env_cache_calls(), - rewire_type_env_parent_links_calls(), - rewire_type_env_import_str_binding_calls(), - ); - } -} - -pub fn record_flatten_visible_parent_recurse() { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_build_type_env_call() { - BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_parent_links_call() { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_import_str_binding_call() { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); -} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, - #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -101,10 +31,6 @@ pub struct TypeEnv { pub intern_table: Rc, } -fn empty_type_env_parents() -> Rc>> { - Rc::new(vec![]) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -120,6 +46,60 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } +pub fn type_env_compositional_authority_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_work_count_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_key_determinism_authority() -> String { + thread_local! { + static CACHED: String = { + "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn flatten_visible_bindings_invariant() -> String { + thread_local! { + static CACHED: String = { + "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -129,16 +109,34 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn record_merge_type_env_cache_call() { - MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); +pub fn build_type_env_calls() -> i64 { + 0 +} + +pub fn merge_type_env_cache_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_parent_links_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_import_str_binding_calls() -> i64 { + 0 +} + +pub fn type_env_counter_dissolution() -> String { + thread_local! { + static CACHED: String = { + "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { - record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), - // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at - // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -153,8 +151,8 @@ pub fn merge_type_env_cache(base: Rc, overlay: Rc) - pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option> { match intern_find(env.intern_table.clone(), name) { - Some(ident) => match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { - Some(binding) => Some(binding.clone()), + Some(ident) => match v1_rt::map_get(&env.bindings.clone(), ident) { + Some(binding) => Some(binding), None => None, }, None => None, @@ -164,42 +162,21 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - let mut pairs: Vec<(String, Rc)> = bindings - .values() - .map(|binding| (binding.name.clone(), binding.clone())) - .collect(); - pairs.sort_by(|a, b| a.0.cmp(&b.0)); - pairs.into_iter().fold( + Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, (name, binding)| { - v1_rt::rc_map_insert(acc, name, binding) - }, - ) -} - -// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value -// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). -#[allow(dead_code)] -pub fn deterministic_str_binding_map( - m: Rc>>, -) -> Rc>> { - let mut keys: Vec = m.keys().cloned().collect(); - keys.sort(); - keys.iter().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, key: &String| { - v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) + |acc: Rc>>, binding: Rc| { + v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings, name.clone()) { - Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { - Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name) { - Some(id) => v1_rt::map_get(&env.bindings, id), + match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { + Some(binding) => Some(binding), + None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { + Some(binding) => Some(binding), + None => match intern_find(env.intern_table.clone(), name.clone()) { + Some(id) => v1_rt::map_get(&env.bindings.clone(), id), None => None, }, }, @@ -208,10 +185,10 @@ pub fn lookup_binding_by_name(env: Rc, name: String) -> Option, ident: i64) -> Option> { match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { - Some(binding) => Some(binding.clone()), + Some(binding) => Some(binding), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env, name) + lookup_binding_by_name(env.clone(), name) } } } @@ -224,22 +201,22 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name.clone()) { - Some(id) => is_recursive_type(env.clone(), id.clone()), + match intern_find(env.intern_table.clone(), name) { + Some(id) => is_recursive_type(env.clone(), id), None => false, } } pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -250,31 +227,39 @@ pub fn authored_name(env: Rc, node: Rc) -> String { pub fn lookup_type_for(env: Rc, node: Rc) -> Option> { match node.ident.clone() { - Some(id) => lookup_type(env.clone(), id.clone()), + Some(id) => lookup_type(env.clone(), id), None => lookup_type_by_name(env.clone(), authored_name(env.clone(), node.clone())), } } pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { match node.ident.clone() { - Some(id) => is_recursive_type(env.clone(), id.clone()), + Some(id) => is_recursive_type(env.clone(), id), None => is_recursive_type_by_name(env.clone(), authored_name(env.clone(), node.clone())), } } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) if !fields.is_empty() => fields.clone(), - _ => { - for parent in env.parents.iter() { - let fields = inductive_fields_for(parent.clone(), type_name.clone()); - if !fields.is_empty() { - return fields; - } - } - Rc::new(vec![]) + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) => fields, + None => Rc::new(vec![]), + }; + if ((local.clone().len() as i64) > 0) { + local + } else { + env.parents.clone().iter().cloned().fold( + Rc::new(vec![]), + |acc: Rc>>, parent: Rc| { + if ((acc.clone().len() as i64) > 0) { + acc.clone() + } else { + inductive_fields_for(parent.clone(), type_name.clone()) + } + }, + ) } - } + }) } pub fn is_inductive_field( @@ -306,7 +291,7 @@ pub fn put_inductive_field( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { - Some(fs) => fs.clone(), + Some(fs) => fs, None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -336,7 +321,7 @@ pub fn put_inductive_field_cross( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { - Some(fs) => fs.clone(), + Some(fs) => fs, None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -361,7 +346,7 @@ pub fn merge_inductive_fields( right: Rc>>>>, ) -> Rc>>>> { Rc::new(v1_rt::map_keys(&right)).iter().cloned().fold( - left.clone(), + left, |acc: Rc>>>>, type_name: String| { match v1_rt::map_get(&right, type_name.clone()) { Some(incoming) => { @@ -400,12 +385,27 @@ pub fn inductive_fields_list_to_map( ) } +pub fn flatten_visible_parent_recurses() -> i64 { + 0 +} + +pub fn reset_flatten_visible_profile() -> () { + {} +} + +pub fn reset_type_env_lookup_profile() -> () { + reset_flatten_visible_profile() +} + +pub fn maybe_print_type_env_lookup_profile() -> () { + {} +} + pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -476,7 +476,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { recursive_type_set: merged_recursive_set, inductive_fields: merged_inductive_fields, source_indices: merged_source_indices, - intern_table: merged_intern_table.clone(), + intern_table: merged_intern_table, }) } } diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 02b08953fa8..739ca5e4f80 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,12 +2,10 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; -pub use crate::std_induction::SubValueRelation; -use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -121,22 +119,22 @@ pub fn inferred_to_outputs( } else { Rc::new(vec![make_field_node( "value".to_string(), - rt.clone(), + rt, Cardinality::Required, None, None, - span.clone(), + span, no_span(), )]) } } else { Rc::new(vec![make_field_node( "value".to_string(), - rt.clone(), + rt, Cardinality::Required, None, None, - span.clone(), + span, no_span(), )]) } @@ -149,11 +147,11 @@ pub fn inferred_to_outputs( } else { Rc::new(vec![make_field_node( "value".to_string(), - rt.clone(), + rt, Cardinality::Required, None, None, - span.clone(), + span, no_span(), )]) } @@ -166,23 +164,26 @@ pub fn inferred_to_outputs( pub fn item_kind(item: Rc) -> ItemKind { { let kind = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { ItemKind::TypeItem } else { - if (item.transport.clone() != None) { + if ((*item.transport).clone() != None) { ItemKind::ServiceItem } else { - if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) + { ItemKind::FnItem } else { - if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { + if (((*item.body).clone() != None) + && ((*item.type_annotation).clone() != None)) + { ItemKind::DataItem } else { - if (item.body.clone() != None) { + if ((*item.body).clone() != None) { ItemKind::FnItem } else { ItemKind::OtherItem @@ -196,38 +197,6 @@ pub fn item_kind(item: Rc) -> ItemKind { } } -pub fn variant_locals_from_items( - items: Rc>>, - init: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - items.iter().cloned().fold( - init, - |acc: Rc>>, item: Rc| { - let is_coproduct = (item.connective.clone() == Connective::Disj); - if is_coproduct.clone() { - item.children.clone().iter().cloned().fold( - acc.clone(), - |vacc: Rc>>, child: Rc| { - let child_name = authored_name_at(source_indices.clone(), child.clone()); - v1_rt::rc_map_insert( - vacc, - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: item.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ) - } else { - acc.clone() - } - }, - ) -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index ac704dae929..fbc036619f9 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -98,7 +98,7 @@ pub fn lookup_field_type_node( } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) { - Some(inner_result) => Some(with_optional_cardinality(inner_result.clone())), + Some(inner_result) => Some(with_optional_cardinality(inner_result)), None => None, } } @@ -122,20 +122,20 @@ pub fn lookup_field_type_node( { let value_child = match n.children.clone().get(1 as usize).cloned() { - Some(child) => child_type_node(child.clone()), + Some(child) => child_type_node(child), None => nominal_type_ref("V".to_string()), }; Some( - make_container_type( + (*make_container_type( "Witness".to_string(), value_child, ) - .ty - .clone(), + .ty) + .clone(), ) } } else { - Some(child_type_node(field_child.clone())) + Some(child_type_node(field_child)) } } None => None, @@ -149,10 +149,10 @@ pub fn lookup_field_type_node( } } } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { lookup_field_type_node( - target.clone(), + target, field_name.clone(), source_indices.clone(), ) @@ -183,18 +183,16 @@ pub fn lookup_coproduct_common_field_node( }; let first_field = if found_in_all { match variants.clone().first().cloned() { - Some(first_variant) => find_child_named( - first_variant.clone(), - field_name.clone(), - source_indices.clone(), - ), + Some(first_variant) => { + find_child_named(first_variant, field_name.clone(), source_indices.clone()) + } None => None, } } else { None }; match first_field { - Some(field_child) => Some(child_type_node(field_child.clone())), + Some(field_child) => Some(child_type_node(field_child)), None => None, } } @@ -210,25 +208,21 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - if ((receiver_type.connective.clone() == Connective::Conj) || is_declared_container_alias_spelling(raw_name.clone())) { - receiver_type.clone() + receiver_type } else { { let resolved = reground_alias_carrier_identity( resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - if (resolved.connective.clone() == Connective::Conj) { - resolved.clone() + let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved.connective.clone() == Connective::Conj) + || ((resolved_name.clone() != raw_name) + && is_declared_container_alias_spelling(resolved_name))) + { + resolved } else { - let resolved_name = - authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone())) - { - resolved.clone() - } else { - receiver_type.clone() - } + receiver_type } } } @@ -241,24 +235,24 @@ pub fn resolve_scrutinee_type_node_seen( seen: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; if n_is_type_var { return n.clone(); } - let normed = normalize_access_type_node(n.clone()); + let normed = normalize_access_type_node(n); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) - && (normed.inferred.clone() != None)) + && ((*normed.inferred).clone() != None)) { - match normed.inferred.clone().as_deref().cloned() { + match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - resolve_scrutinee_type_node_seen(env.clone(), target.clone(), seen.clone()) + resolve_scrutinee_type_node_seen(env.clone(), target, seen.clone()) } - _ => normed.clone(), + _ => normed, } } else { if ((normed.connective.clone() == Connective::NoConnective) @@ -266,38 +260,38 @@ pub fn resolve_scrutinee_type_node_seen( { { let canonical = authored_name(env.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if ((*normed.inferred).clone() != None) { { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; - match normed.inferred.clone().as_deref().cloned() { + match (*normed.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { if ((((authored_name(env.clone(), target.clone()) - == canonical.clone()) - && (target.inferred.clone() == None)) + == canonical) + && ((*target.inferred).clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { - normed.clone() + normed } else { resolve_scrutinee_type_node_seen( env.clone(), - target.clone(), + target, next_seen, ) } } - _ => normed.clone(), + _ => normed, } } } else { if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { - nominal_type_ref(canonical.clone()) + nominal_type_ref(canonical) } else { { let next_seen = if (canonical.clone() == "".to_string()) { @@ -308,18 +302,18 @@ pub fn resolve_scrutinee_type_node_seen( match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) - == canonical.clone()) - && (resolved.inferred.clone() == None)) + == canonical) + && ((*resolved.inferred).clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) { - normed.clone() + normed } else { { let result = resolve_scrutinee_type_node_seen( env.clone(), - resolved.clone(), + resolved, next_seen, ); let is_optional = @@ -333,14 +327,14 @@ pub fn resolve_scrutinee_type_node_seen( } } } - None => normed.clone(), + None => normed, } } } } } } else { - normed.clone() + normed } } }) @@ -355,7 +349,7 @@ pub fn map_value_type_in_env(type_node: Rc, env: Rc) -> Option= 2)) { match map_type.children.clone().get(1 as usize).cloned() { - Some(value_type) => Some(value_type.clone()), + Some(value_type) => Some(value_type), None => None, } } else { @@ -373,7 +367,7 @@ pub fn map_key_type_in_env(type_node: Rc, env: Rc) -> Option= 1)) { match map_type.children.clone().first().cloned() { - Some(key_type) => Some(key_type.clone()), + Some(key_type) => Some(key_type), None => None, } } else { @@ -391,7 +385,7 @@ pub fn set_element_type_in_env(type_node: Rc, env: Rc) -> Option< && ((set_type.children.clone().len() as i64) >= 1)) { match set_type.children.clone().first().cloned() { - Some(elem_type) => Some(elem_type.clone()), + Some(elem_type) => Some(elem_type), None => None, } } else { @@ -415,9 +409,9 @@ pub fn field_summary_for_type( value_shape: FieldValueShape::PlainValue, })) } else { - if normed_opt.clone() { + if normed_opt { { - let inner = with_required_cardinality(normed.clone()); + let inner = with_required_cardinality(normed); match field_summary_for_type(inner, env.clone(), field.clone()) { Some(inner_summary) => Some(Rc::new(FieldSummary { access_style: inner_summary.access_style.clone(), @@ -437,7 +431,7 @@ pub fn field_summary_for_type( if is_product { v1_rt::map_get( &build_struct_field_summaries( - resolved.clone(), + resolved, env.source_indices.clone(), ), field.clone(), @@ -475,17 +469,17 @@ pub struct StructuralMethodLookup { } pub fn product_field_result_type(field: Rc) -> Option> { - match field.inferred.clone().as_deref().cloned() { + match (*field.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match rt.inferred.clone().as_deref().cloned() { + match (*rt.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. - }) => Some(return_type.clone()), - _ => Some(rt.clone()), + }) => Some(return_type), + _ => Some(rt), } } else { - Some(rt.clone()) + Some(rt) } } _ => None, @@ -501,13 +495,9 @@ pub fn map_lookup_result_type( match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { - Some(raw.clone()) + Some(raw) } else { - Some( - make_container_type("Witness".to_string(), raw.clone()) - .ty - .clone(), - ) + Some((*make_container_type("Witness".to_string(), raw).ty).clone()) } } None => None, @@ -539,16 +529,16 @@ pub fn lookup_field_in_product( None } { Some(lookup_rt) => Some(Rc::new(MethodFieldResult { - field_node: field.clone(), - result_type: lookup_rt.clone(), + field_node: field, + result_type: lookup_rt, size_effect: None, cost_shape: None, algebra_template: None, })), None => match product_field_result_type(field.clone()) { Some(rt) => Some(Rc::new(MethodFieldResult { - field_node: field.clone(), - result_type: rt.clone(), + field_node: field, + result_type: rt, size_effect: None, cost_shape: None, algebra_template: None, @@ -587,12 +577,12 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if ((enriched.ty.clone().connective.clone() == Connective::Conj) - && ((enriched.ty.clone().children.clone().len() as i64) > 0)) + if (((*enriched.ty).clone().connective.clone() == Connective::Conj) + && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( - enriched.ty.clone(), + (*enriched.ty).clone(), method_name.clone(), source_indices.clone(), ); @@ -604,7 +594,7 @@ pub fn lookup_structural_method( ); let template_match = match profile { Some(p) => { - let templates = algebra_templates_for_profile(p.clone()); + let templates = algebra_templates_for_profile(p); Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { @@ -621,13 +611,13 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: mfr.field_node.clone(), - result_type: mfr.result_type.clone(), + field_node: (*mfr.field_node).clone(), + result_type: (*mfr.result_type).clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), - algebra_template: Some(t.clone()), + algebra_template: Some(t), })), - None => base_result.clone(), + None => base_result, }; Rc::new(StructuralMethodLookup { resolution: resolution, @@ -668,7 +658,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: mfr.field_node.clone(), + method_def: (*mfr.field_node).clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -676,7 +666,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some(mfr.result_type.clone()), + result_type: Some((*mfr.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -694,7 +684,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some(svc_result.result_type.clone()), + result_type: Some((*svc_result.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 96d9884ceb1..aea21c02675 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,28 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - make_map_type( + (*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty - .clone() + .ty) + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)) - .ty - .clone() + (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() } pub fn list_of_element(element: Rc) -> Rc { - make_container_type("List".to_string(), element).ty.clone() + (*make_container_type("List".to_string(), element).ty).clone() } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element) - .ty - .clone() + (*make_container_type("Witness".to_string(), element).ty).clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -127,15 +123,15 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = make_container_type( + let set_ty = (*make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty - .clone(); + .ty) + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); @@ -254,41 +250,6 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_loc".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_test_fns".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_names".to_string(), - list_of_type_variable("test_migration_debt_module_name_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_known_covered_module_is_not_debt".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_holds".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_uncovered_deletes".to_string(), - list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), - ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), @@ -418,7 +379,7 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "is_xid_start".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "is_xid_continue".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "is_emoji_ident".to_string(), bool_type()); - m.clone() + m } } @@ -428,7 +389,7 @@ pub fn infer_builtin_call_type(name: String) -> Option> { pub fn resolve_builtin_call_type(name: String) -> Rc { match infer_builtin_call_type(name) { - Some(v) => v.clone(), + Some(v) => v, None => unit_type(), } } diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 1dd9fc95134..2ead641ed2f 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,6 +37,138 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), + None => acc.clone(), + } + }, + ) + } +} + +pub fn expand_scrut_from_decl( + decl: Rc, + scrut_node: Rc, + name: String, + env: Rc, +) -> Rc { + { + let decl_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_alias = ((((*decl.inferred).clone() != None) + && (decl.connective.clone() == Connective::NoConnective)) + && ((decl.children.clone().len() as i64) == 0)); + if decl_is_disj { + decl + } else { + if has_inferred_alias { + match (*decl.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node, env.clone()); + substitute_type_slots(target, subst, name, env.source_indices.clone()) + } + _ => scrut_node, + } + } else { + scrut_node + } + } + } +} + +pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { + { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())); + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if is_generic_use { + expand_scrut_from_decl(decl, scrut_node.clone(), name, env.clone()) + } else { + { + let def_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_body = (((*decl.inferred).clone() != None) + && (decl.connective.clone() == Connective::NoConnective)); + if def_is_disj { + decl + } else { + if has_inferred_body { + match (*decl.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let target_is_disj = + (target.connective.clone() == Connective::Disj); + if target_is_disj { + target + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + } + } + } + None => scrut_node.clone(), + } + } +} + +pub fn expand_scrut_type_for_variant_lookup( + mut scrut_node: Rc, + mut env: Rc, +) -> Rc { + loop { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_disj = (scrut_node.connective.clone() == Connective::Disj); + let is_witness = is_witness_type_name(name.clone()); + if (is_disj.clone() || is_witness.clone()) { + break scrut_node.clone(); + } else { + match (*scrut_node.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let __tco_0 = target.clone(); + scrut_node = __tco_0; + continue; + } + _ => { + break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); + } + } + } + } +} + pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -127,7 +259,7 @@ pub fn synthesize_optional_present_variant(scrut: Rc) -> Rc { pub fn synthesize_witness_holds_variant(scrut: Rc) -> Rc { { let inner = match scrut.children.clone().first().cloned() { - Some(child) => child_type_node(child.clone()), + Some(child) => child_type_node(child), None => error_type(), }; let value_field = Rc::new(Node { @@ -242,19 +374,19 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { pub fn pattern_subject_from_node(mut n: Rc) -> Rc { loop { - let is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; - if is_error { + if is_error.clone() { break Rc::new(PatternSubject::PatternLookupBlocked); } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() != None)) + && ((*n.inferred).clone() != None)) { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); n = __tco_0; @@ -273,9 +405,7 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { pub fn pattern_subject_from_inferred(n: Option>) -> Rc { match n.as_deref().cloned() { - Some(InferredNode::Resolved { node: resolved, .. }) => { - pattern_subject_from_node(resolved.clone()) - } + Some(InferredNode::Resolved { node: resolved, .. }) => pattern_subject_from_node(resolved), _ => Rc::new(PatternSubject::PatternLookupBlocked), } } @@ -297,7 +427,7 @@ pub fn node_lookup_failed(diagnostics: Rc>>) -> Rc) -> Rc { match (*result.status.clone()).clone() { NodeLookupStatus::LookupResolved { node: resolved, .. } => { - pattern_subject_from_node(resolved.clone()) + pattern_subject_from_node(resolved) } NodeLookupStatus::LookupFailed => Rc::new(PatternSubject::PatternLookupBlocked), } @@ -305,7 +435,7 @@ pub fn lookup_result_subject(result: Rc) -> Rc pub fn pattern_binding_type(subject: Rc) -> Rc { match (*subject).clone() { - PatternSubject::PatternResolved { node: resolved, .. } => resolved.clone(), + PatternSubject::PatternResolved { node: resolved, .. } => resolved, PatternSubject::PatternDynamic { span: _, .. } => error_type(), PatternSubject::PatternLookupBlocked => error_type(), } @@ -327,102 +457,6 @@ pub fn variant_not_found_result( )])) } -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), - None => acc, - } - }, - ) -} - -pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { - return scrut_node.clone(); - } - if (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())) - { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if (((decl.inferred.clone() != None) - && ((decl.children.clone().len() as i64) == 0)) - && (decl.connective.clone() == Connective::NoConnective)) - { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); - let expanded = substitute_type_slots( - target, - subst, - name.clone(), - env.source_indices.clone(), - ); - return expanded; - } - _ => scrut_node.clone(), - } - } else if (decl.connective.clone() == Connective::Disj) { - decl.clone() - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } else { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(def) => { - if (def.connective.clone() == Connective::Disj) { - def.clone() - } else if ((def.inferred.clone() != None) - && (def.connective.clone() == Connective::NoConnective)) - { - match def.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - if (target.connective.clone() == Connective::Disj) { - target - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } -} - pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, @@ -438,7 +472,7 @@ pub fn lookup_variant_in_type( Rc::new(CompilerDiagnostic::VariantNotFound { variant: variant_name.clone(), type_name: "unresolved".to_string(), - span: dynamic_span.clone(), + span: dynamic_span, }), module_name, )])), @@ -455,7 +489,7 @@ pub fn lookup_variant_in_type( node_lookup_failed(Rc::new(vec![])) } else { { - let optional_cardinality_subject = (scrut_opt.clone() + let optional_cardinality_subject = (scrut_opt && (authored_name_at(source_indices.clone(), scrut_node.clone()) != "Optional".to_string())); let witness_subject = (is_witness_type_name(authored_name_at( @@ -465,11 +499,9 @@ pub fn lookup_variant_in_type( if (optional_cardinality_subject.clone() && (variant_name.clone() == "Present".to_string())) { - node_lookup_resolved(synthesize_optional_present_variant( - scrut_node.clone(), - )) + node_lookup_resolved(synthesize_optional_present_variant(scrut_node)) } else { - if (optional_cardinality_subject.clone() + if (optional_cardinality_subject && (variant_name.clone() == "Absent".to_string())) { node_lookup_resolved(none_type()) @@ -477,15 +509,13 @@ pub fn lookup_variant_in_type( if (witness_subject.clone() && (variant_name.clone() == "Holds".to_string())) { - node_lookup_resolved(synthesize_witness_holds_variant( - scrut_node.clone(), - )) + node_lookup_resolved(synthesize_witness_holds_variant(scrut_node)) } else { - if (witness_subject.clone() + if (witness_subject && (variant_name.clone() == "Violates".to_string())) { node_lookup_resolved(synthesize_witness_violates_variant( - scrut_node.clone(), + scrut_node, )) } else { { @@ -505,36 +535,34 @@ pub fn lookup_variant_in_type( let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) - && (scrut_name.clone() == variant_name.clone())); + && (scrut_name == variant_name.clone())); let fallback = if record_destructure { - node_lookup_resolved(scrut_node.clone()) + node_lookup_resolved(scrut_node) } else { if (optional_coproduct_subject.clone() && (variant_name.clone() == "Present".to_string())) { node_lookup_resolved( - synthesize_optional_present_variant( - scrut_node.clone(), - ), + synthesize_optional_present_variant(scrut_node), ) } else { - if (optional_coproduct_subject.clone() + if (optional_coproduct_subject && (variant_name.clone() == "Absent".to_string())) { node_lookup_resolved(none_type()) } else { variant_not_found_result( - scrut_node.clone(), + scrut_node, variant_name.clone(), module_name, - source_indices.clone(), + source_indices, ) } } }; match direct_match { - Some(v) => node_lookup_resolved(v.clone()), + Some(v) => node_lookup_resolved(v), None => fallback, } } @@ -562,7 +590,7 @@ pub fn lookup_field_in_variant( Rc::new(CompilerDiagnostic::FieldNotFound { field: field_name.clone(), type_name: "unresolved".to_string(), - span: dynamic_span.clone(), + span: dynamic_span, }), module_name, )])), @@ -574,7 +602,7 @@ pub fn lookup_field_in_variant( source_indices.clone(), ) { Some(field_child) => { - let resolved = child_type_node(field_child.clone()); + let resolved = child_type_node(field_child); node_lookup_resolved(resolved) } None => node_lookup_failed(Rc::new(vec![make_error_node( @@ -607,7 +635,7 @@ pub fn check_match_exhaustiveness( env.clone(), authored_name_at(env.source_indices.clone(), scrutinee_type.clone()), ) { - Some(def) => def.clone(), + Some(def) => def, None => scrutinee_type.clone(), } }; @@ -625,10 +653,10 @@ pub fn check_match_exhaustiveness( )) && ((resolved.children.clone().len() as i64) == 1)); if ((is_coproduct || resolved_is_optional.clone()) || resolved_is_witness.clone()) { { - let variant_names = if resolved_is_optional.clone() { + let variant_names = if resolved_is_optional { Rc::new(vec!["Present".to_string(), "Absent".to_string()]) } else { - if resolved_is_witness.clone() { + if resolved_is_witness { Rc::new(vec!["Holds".to_string(), "Violates".to_string()]) } else { Rc::new({ @@ -704,7 +732,7 @@ pub fn check_match_exhaustiveness( if ((uncovered.clone().len() as i64) > 0) { Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::NonExhaustiveMatch { - missing: uncovered.clone(), + missing: uncovered, span: span, }), module_name, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 84f1b36551f..8630b2b4999 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, - is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, + lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -90,13 +90,13 @@ pub fn unit_variant_in_coproduct( } pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc { - if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { - match ty.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => target.clone(), - _ => ty.clone(), + if ((ty.connective.clone() == Connective::NoConnective) && ((*ty.inferred).clone() != None)) { + match (*ty.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => target, + _ => ty, } } else { - ty.clone() + ty } } @@ -107,8 +107,8 @@ pub fn lookup_unit_variant_phantom_type( { let matches = collect_unit_variant_phantom_matches(env, variant_name); if ((matches.clone().len() as i64) == 1) { - match matches.clone().first().cloned() { - Some(variant) => Some(variant.clone()), + match matches.first().cloned() { + Some(variant) => Some(variant), None => None, } } else { @@ -117,24 +117,41 @@ pub fn lookup_unit_variant_phantom_type( } } +pub fn phantom_match_flat_scope() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), + { + let direct_bindings = env.parents.clone().iter().cloned().fold( + env.str_bindings.clone(), + |acc: Rc>>, parent: Rc| { + v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) }, - ) + ); + Rc::new(v1_rt::map_values(&direct_bindings)) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), + }, + ) + } } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -165,27 +182,36 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { + thread_local! { + static CACHED: String = { + "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) + && is_kernel_type(authored_name_at(source_indices, structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -194,9 +220,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone() != "".to_string()) + if ((((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone()) + && !is_declared_container_alias_spelling(brand_name.clone())) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -213,62 +239,61 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S Some(resolved) => { let structural = if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved - .clone(), - _ => resolve_node_bounded( + match (*resolved.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + (*resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved) + .clone() + } + _ => (*resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved - .clone(), + .resolved) + .clone(), } } else { - resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved + (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved) .clone() }; - if (((brand.clone() != "".to_string()) + if ((((brand.clone() != "".to_string()) && (brand.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand.clone()) - && !is_transparent_primitive_alias_rhs( - structural.clone(), - source_indices.clone(), - )) + && !is_declared_container_alias_spelling(brand)) + && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices)) { - with_authored_identity(n.clone(), structural.clone()) + with_authored_identity(n.clone(), structural) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved.inferred.clone().as_deref().cloned() { + match (*resolved.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = resolve_node_bounded( - target.clone(), + let target_resolved = (*resolve_node_bounded( + target, env.clone(), module_name.clone(), 0, ) - .resolved - .clone(); + .resolved) + .clone(); with_authored_identity(n.clone(), target_resolved) } - _ => resolved.clone(), + _ => resolved, } } else { - resolved.clone() + resolved } } } @@ -347,57 +372,75 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { + thread_local! { + static CACHED: String = { + "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for parent in env.parents.clone().iter().cloned() { + if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), + None => false, + } { + __result.push(parent); + } + } + __result + }) + .first() + .cloned() + { + Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => Some((*b.resolved).clone()), + None => None, + }, + None => None, + } +} + +pub fn resolve_paramless_generic_use_decl( + env: Rc, + n: Rc, + decl: Rc, + brand: String, +) -> Rc { + match ((n.children.clone().len() as i64) > 0) { + true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { + Some(user_decl) => user_decl, + None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) + { + true => match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural, + None => decl, + }, + false => decl, + }, + }, + false => decl, + } +} + pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); match lookup_type_for(env.clone(), n.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { - decl.clone() - } else if ((n.children.clone().len() as i64) > 0) { - // HAND-PATCH (parameterized use site prefers parameterized - // decl; replaced at regen): a use site WITH type args whose - // primary lookup lands paramless (kernel prelude shadowing - // an imported user generic, e.g. Optional) retries the - // ancestry binding for a parameterized decl. - let ancestry_generic = env.parents.iter().fold( - None, - |acc: Option>, parent: &Rc| { - if acc.is_some() { - return acc; - } - match v1_rt::map_get(&parent.str_bindings, brand.clone()) { - Some(b) => { - if ((b.resolved.params.clone().len() as i64) > 0) { - Some(b.resolved.clone()) - } else { - acc - } - } - None => acc, - } - }, - ); - match ancestry_generic { - Some(user_decl) => user_decl, - None => { - if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { - match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl.clone(), - } - } else { - decl.clone() - } - } - } + decl } else { - decl.clone() + resolve_paramless_generic_use_decl(env.clone(), n, decl, brand) } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(decl) => decl.clone(), - None => n.clone(), + Some(decl) => decl, + None => n, }, } } @@ -415,7 +458,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { if is_container_type(n.name.clone()) { false } else { - if (decl.inferred.clone() != None) { + if ((*decl.inferred).clone() != None) { true } else { true @@ -438,14 +481,14 @@ pub fn substitute_type_slots( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_slot = (((((n.children.clone().len() as i64) == 0) && (n.connective.clone() == Connective::NoConnective)) - && (n.body.clone() == None)) - && (n.inferred.clone() == None)); + && ((*n.body).clone() == None)) + && ((*n.inferred).clone() == None)); if is_slot { match v1_rt::map_get( &slot_bindings, authored_name_at(source_indices.clone(), n.clone()), ) { - Some(concrete) => concrete.clone(), + Some(concrete) => concrete, None => n.clone(), } } else { @@ -477,18 +520,18 @@ pub fn substitute_type_slots( children: substituted_args.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: child.inferred.clone(), + inferred: (*child.inferred).clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: child.properties.clone(), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation).clone(), is_self_recursive: child.is_self_recursive.clone(), has_non_tail_self_call: child .has_non_tail_self_call .clone(), - match_pattern: child.match_pattern.clone(), + match_pattern: (*child.match_pattern).clone(), expr_data: child.expr_data.clone(), ident: None, }) @@ -505,18 +548,18 @@ pub fn substitute_type_slots( } __result }); - let new_inferred = match n.inferred.clone().as_deref().cloned() { + let new_inferred = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Some(Rc::new(InferredNode::Resolved { node: substitute_type_slots( - rt.clone(), + rt, slot_bindings.clone(), decl_name.clone(), source_indices.clone(), ), })) } - _ => n.inferred.clone(), + _ => (*n.inferred).clone(), }; Rc::new(Node { name: n.name.clone(), @@ -528,13 +571,13 @@ pub fn substitute_type_slots( inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -559,7 +602,7 @@ pub fn classify_alias(target: Rc) -> AliasKind { if (((target.children.clone().len() as i64) > 0) && nc.clone()) { AliasKind::AliasParameterized } else { - if ((((target.children.clone().len() as i64) == 0) && nc.clone()) + if ((((target.children.clone().len() as i64) == 0) && nc) && (target.ident_span.clone() != None)) { AliasKind::AliasLeaf @@ -578,27 +621,25 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) - .resolved - .clone() + (*resolve_node_bounded(target, env.clone(), module_name, (depth + 1)).resolved).clone() } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), authored_name_at(env.source_indices.clone(), target.clone()), ) { - Some(env_target) => env_target.clone(), - None => target.clone(), + Some(env_target) => env_target, + None => target, }, - AliasKind::AliasPassthrough => target.clone(), + AliasKind::AliasPassthrough => target, } } pub fn is_parametric_type_alias_decl(item: Rc) -> bool { ((((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) - && (item.inferred.clone() != None)) + && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) + && ((*item.inferred).clone() != None)) } pub fn resolve_nominal_alias_rhs( @@ -625,13 +666,13 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for ar in arg_results.clone().iter().cloned() { + for ar in arg_results.iter().cloned() { __result.extend((*ar.diagnostics.clone()).iter().cloned()); } __result @@ -646,13 +687,13 @@ pub fn resolve_nominal_alias_rhs( children: resolved_args, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -697,16 +738,16 @@ pub fn resolve_node_bounded( { let is_product = (n.connective.clone() == Connective::Conj); if is_product { - if (n.type_annotation.clone() != None) { + if ((*n.type_annotation).clone() != None) { match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( - base.clone(), + base, env.clone(), module_name.clone(), (depth.clone() + 1), ); - let base_resolved = base_result.resolved.clone(); + let base_resolved = (*base_result.resolved).clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -716,13 +757,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![base_resolved]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -742,7 +783,7 @@ pub fn resolve_node_bounded( let child_results = Rc::new({ let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { - __result.push(if (child.inferred.clone() == None) { + __result.push(if ((*child.inferred).clone() == None) { Rc::new(NodeResolveResult { resolved: child.clone(), diagnostics: Rc::new(vec![]), @@ -756,7 +797,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = rt_result.resolved.clone(); + let rt_resolved = (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -775,13 +816,14 @@ pub fn resolve_node_bounded( .return_cardinality .clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: v1_rt::concat( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation) + .clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -798,13 +840,13 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.resolved.clone()); + __result.push((*cr.resolved).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.clone().iter().cloned() { + for cr in child_results.iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result @@ -817,13 +859,13 @@ pub fn resolve_node_bounded( children: resolved_children, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -847,7 +889,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = inner_result.resolved.clone(); + let inner_resolved = (*inner_result.resolved).clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: with_optional_cardinality(inner_resolved), @@ -866,7 +908,8 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) { + if ((*field_child.inferred).clone() == None) + { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -907,7 +950,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - rt_result.resolved.clone(); + (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -923,10 +966,10 @@ pub fn resolve_node_bounded( })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), - body: field_child.body.clone(), - transport: field_child.transport.clone(), + body: (*field_child.body).clone(), + transport: (*field_child.transport).clone(), properties: v1_rt::concat(field_child.properties.clone(), rt_resolved.properties.clone()), - type_annotation: field_child.type_annotation.clone(), + type_annotation: (*field_child.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -944,7 +987,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.resolved.clone()); + __result.push((*fr.resolved).clone()); } __result }); @@ -965,16 +1008,16 @@ pub fn resolve_node_bounded( children: resolved_fields.clone(), connective: variant_child.connective.clone(), params: variant_child.params.clone(), - inferred: variant_child.inferred.clone(), + inferred: (*variant_child.inferred).clone(), return_cardinality: variant_child .return_cardinality .clone(), uses: variant_child.uses.clone(), - body: variant_child.body.clone(), - transport: variant_child.transport.clone(), + body: (*variant_child.body).clone(), + transport: (*variant_child.transport).clone(), properties: variant_child.properties.clone(), - type_annotation: variant_child - .type_annotation + type_annotation: (*variant_child + .type_annotation) .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -991,13 +1034,13 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push(vr.resolved.clone()); + __result.push((*vr.resolved).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for vr in variant_results.clone().iter().cloned() { + for vr in variant_results.iter().cloned() { __result.extend((*vr.diagnostics.clone()).iter().cloned()); } __result @@ -1010,13 +1053,13 @@ pub fn resolve_node_bounded( children: resolved_variants, connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1043,8 +1086,8 @@ pub fn resolve_node_bounded( Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::ArityMismatch { name: type_name.clone(), - expected: expected_arity.clone(), - got: actual_arity.clone(), + expected: expected_arity, + got: actual_arity, span: n.span.clone(), }), module_name.clone(), @@ -1067,13 +1110,13 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for ar in arg_results.clone().iter().cloned() { + for ar in arg_results.iter().cloned() { __result.extend((*ar.diagnostics.clone()).iter().cloned()); } __result @@ -1136,16 +1179,16 @@ pub fn resolve_node_bounded( } }, ); - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = ((((*decl.inferred).clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { { - let alias_target = match decl.inferred.clone().as_deref().cloned() { + let alias_target = match (*decl.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { substitute_type_slots( - target.clone(), - slot_bindings.clone(), + target, + slot_bindings, type_name.clone(), env.source_indices.clone(), ) @@ -1164,27 +1207,27 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: target_result.resolved.clone().children.clone(), - connective: target_result.resolved.clone().connective.clone(), + children: (*target_result.resolved).clone().children.clone(), + connective: (*target_result.resolved).clone().connective.clone(), params: Rc::new(vec![]), - inferred: target_result.resolved.clone().inferred.clone(), + inferred: (*(*target_result.resolved).clone().inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), - type_annotation: n.type_annotation.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), + properties: (*target_result.resolved).clone().properties.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); let resolved_node = Rc::new(Node { - name: type_name.clone(), + name: type_name, span: n.span.clone(), ident_span: n.ident_span.clone(), - children: resolved_args.clone(), + children: resolved_args, connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { @@ -1192,13 +1235,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), - type_annotation: n.type_annotation.clone(), - is_self_recursive: is_recursive.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), + properties: (*target_result.resolved).clone().properties.clone(), + type_annotation: (*n.type_annotation).clone(), + is_self_recursive: is_recursive, has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1233,25 +1276,25 @@ pub fn resolve_node_bounded( children: substituted_children, connective: decl.connective.clone(), params: Rc::new(vec![]), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: decl.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }); let result = Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name.clone(), + name: type_name, span: n.span.clone(), ident_span: n.ident_span.clone(), - children: resolved_args.clone(), + children: resolved_args, connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { @@ -1259,13 +1302,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: decl.properties.clone(), - type_annotation: n.type_annotation.clone(), - is_self_recursive: is_recursive.clone(), + type_annotation: (*n.type_annotation).clone(), + is_self_recursive: is_recursive, has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -1282,11 +1325,11 @@ pub fn resolve_node_bounded( { let type_name = authored_name(env.clone(), n.clone()); let key_child_node = match n.children.clone().first().cloned() { - Some(k) => k.clone(), + Some(k) => k, None => unit_type(), }; let val_child_node = match n.children.clone().get(1 as usize).cloned() { - Some(v) => v.clone(), + Some(v) => v, None => unit_type(), }; let key_type = child_type_node(key_child_node.clone()); @@ -1297,7 +1340,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = key_result.resolved.clone(); + let key_resolved = (*key_result.resolved).clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1305,9 +1348,9 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = val_result.resolved.clone(); + let val_resolved = (*val_result.resolved).clone(); let val_diags = val_result.diagnostics.clone(); - let key_param_name = if (key_child_node.inferred.clone() != None) { + let key_param_name = if ((*key_child_node.inferred).clone() != None) { authored_name(env.clone(), key_child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { @@ -1315,11 +1358,11 @@ pub fn resolve_node_bounded( None => authored_name(env.clone(), key_child_node.clone()), } }; - let val_param_name = if (val_child_node.inferred.clone() != None) { + let val_param_name = if ((*val_child_node.inferred).clone() != None) { authored_name(env.clone(), val_child_node.clone()) } else { match container_param_name(type_name.clone(), 1) { - Some(pn) => pn.clone(), + Some(pn) => pn, None => authored_name(env.clone(), val_child_node.clone()), } }; @@ -1369,19 +1412,19 @@ pub fn resolve_node_bounded( }); Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name.clone(), + name: type_name, span: n.span.clone(), ident_span: n.ident_span.clone(), children: Rc::new(vec![resolved_key_child, resolved_val_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1404,14 +1447,15 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = el_result.resolved.clone(); + let el_resolved = (*el_result.resolved).clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() != None) + let el_param_name = if ((*child_node.inferred).clone() + != None) { authored_name(env.clone(), child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { - Some(pn) => pn.clone(), + Some(pn) => pn, None => { authored_name(env.clone(), child_node.clone()) } @@ -1441,19 +1485,19 @@ pub fn resolve_node_bounded( }); Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name.clone(), + name: type_name, span: n.span.clone(), ident_span: n.ident_span.clone(), children: Rc::new(vec![resolved_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1472,26 +1516,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: target, .. - }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) - > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = match (*n.inferred) + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { node: target, .. }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1508,10 +1552,9 @@ pub fn resolve_node_bounded( == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && ((*resolved.inferred).clone() != None)) { - match resolved - .inferred + match (*resolved.inferred) .clone() .as_deref() .cloned() @@ -1539,22 +1582,22 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - resolve_node_bounded( - target.clone(), + (*resolve_node_bounded( + target, env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved - .clone() + .resolved) + .clone() } else { - target.clone() + target } } - _ => resolved.clone(), + _ => resolved, } } else { - resolved.clone() + resolved }; let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); @@ -1569,23 +1612,24 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) { + let n_is_error = if ((*n.inferred).clone() != None) + { is_compiler_error( - n.inferred.clone().clone().unwrap(), + (*n.inferred).clone().clone().unwrap(), ) } else { false }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = if (n.inferred.clone() != None) - { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = + if ((*n.inferred).clone() != None) { + is_type_variable( + (*n.inferred).clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1602,7 +1646,7 @@ pub fn resolve_node_bounded( } else { match lookup_unit_variant_phantom_type(env.clone(), authored_name(env.clone(), n.clone())) { Some(phantom) => Rc::new(NodeResolveResult { - resolved: phantom.clone(), + resolved: phantom, diagnostics: Rc::new(vec![]), }), None => Rc::new(NodeResolveResult { @@ -1643,7 +1687,7 @@ pub fn missing_generic_args_diagnostics( { let type_name = authored_name(env.clone(), n.clone()); let decl = match lookup_type_for(env.clone(), n.clone()) { - Some(d) => d.clone(), + Some(d) => d, None => n.clone(), }; Rc::new(vec![make_error_node( @@ -1673,9 +1717,7 @@ pub fn resolve_optional_node( }) } else { match (*n.clone().unwrap()).clone() { - InferredNode::Resolved { node: inner, .. } => { - resolve_node(inner.clone(), env, module_name) - } + InferredNode::Resolved { node: inner, .. } => resolve_node(inner, env, module_name), InferredNode::CompilerError { message: msg, span: sp, @@ -1688,8 +1730,8 @@ pub fn resolve_optional_node( ), diagnostics: Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::InternalError { - message: msg.clone(), - span: sp.clone(), + message: msg, + span: sp, }), module_name, )]), @@ -1702,7 +1744,7 @@ pub fn resolve_optional_node( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { id: tv.clone() })), + inferred: Some(Rc::new(InferredNode::TypeVariable { id: tv })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -1725,18 +1767,14 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), - missing_generic_args_diagnostics( - authored_type.clone(), - env.clone(), - module_name.clone(), - ), + missing_generic_args_diagnostics(authored_type, env.clone(), module_name.clone()), ); let default_resolved = match field_node_default_value(field.clone()) { Some(default_value) => Some(resolve_expr_types( - default_value.clone(), + default_value, env.clone(), module_name.clone(), )), @@ -1751,8 +1789,8 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> field_node_name_at(field.clone(), env.source_indices.clone()), type_resolved, field_node_cardinality(field.clone()), - match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + match default_resolved { + Some(result) => Some((*result.expr).clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1768,7 +1806,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1782,13 +1820,13 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), - body: authored_type.body.clone(), - transport: authored_type.transport.clone(), + body: (*authored_type.body).clone(), + transport: (*authored_type.transport).clone(), properties: type_resolved.properties.clone(), - type_annotation: authored_type.type_annotation.clone(), + type_annotation: (*authored_type.type_annotation).clone(), is_self_recursive: authored_type.is_self_recursive.clone(), has_non_tail_self_call: authored_type.has_non_tail_self_call.clone(), - match_pattern: authored_type.match_pattern.clone(), + match_pattern: (*authored_type.match_pattern).clone(), expr_data: authored_type.expr_data.clone(), ident: None, }) @@ -1797,15 +1835,11 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), - missing_generic_args_diagnostics( - authored_type.clone(), - env.clone(), - module_name.clone(), - ), + missing_generic_args_diagnostics(authored_type, env.clone(), module_name.clone()), ); let default_resolved = match param_node_default_value(param.clone()) { Some(default_value) => Some(resolve_expr_types( - default_value.clone(), + default_value, env.clone(), module_name.clone(), )), @@ -1815,8 +1849,8 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> Some(result) => result.diagnostics.clone(), None => Rc::new(vec![]), }; - let default_expr = match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + let default_expr = match default_resolved { + Some(result) => Some((*result.expr).clone()), None => None, }; Rc::new(ParamResult { @@ -1840,7 +1874,7 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( @@ -1861,7 +1895,7 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( @@ -1886,7 +1920,7 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( @@ -1908,11 +1942,7 @@ pub fn resolve_match_arm( { let arm_g = arm_guard(arm.clone()); let guard_result = match arm_g { - Some(guard) => Some(resolve_expr_types( - guard.clone(), - env.clone(), - module_name.clone(), - )), + Some(guard) => Some(resolve_expr_types(guard, env.clone(), module_name.clone())), None => None, }; let guard_diags = match guard_result.clone() { @@ -1921,13 +1951,13 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = body_result.expr.clone(); + let body_expr = (*body_result.expr).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( arm_pattern(arm.clone()), - match guard_result.clone() { - Some(result) => Some(result.expr.clone()), + match guard_result { + Some(result) => Some((*result.expr).clone()), None => None, }, body_expr, @@ -1945,14 +1975,12 @@ pub fn resolve_string_part( ) -> Rc { match (*part).clone() { StringPart::Text { value: value, .. } => Rc::new(StringPartResolveResult { - part: Rc::new(StringPart::Text { - value: value.clone(), - }), + part: Rc::new(StringPart::Text { value: value }), diagnostics: Rc::new(vec![]), }), StringPart::Interpolation { expr: expr, .. } => { - let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = expr_result.expr.clone(); + let expr_result = resolve_expr_types(expr, env, module_name); + let resolved_expr = (*expr_result.expr).clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { @@ -1988,7 +2016,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - val_result.expr.clone(), + (*val_result.expr).clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2001,13 +2029,13 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); let prop_diags = Rc::new({ let mut __result = Vec::new(); - for pr in prop_results.clone().iter().cloned() { + for pr in prop_results.iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result @@ -2026,13 +2054,13 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.expr.clone()); + __result.push((*cr.expr).clone()); } __result }); let child_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.clone().iter().cloned() { + for cr in child_results.iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result @@ -2054,7 +2082,7 @@ pub fn resolve_transport_binding( transport: make_transport_node( resolved_props, resolved_children, - transport.body.clone(), + (*transport.body).clone(), transport.span.clone(), ), diagnostics: v1_rt::concat(v1_rt::concat(prop_diags, child_diags), body_diags), @@ -2075,10 +2103,10 @@ pub fn resolve_expr_types( diagnostics: Rc::new(vec![]), }), ExprData::ExprError { kind, message, .. } => Rc::new(ExprResolveResult { - expr: make_expr_error_node(kind.clone(), message.clone(), texpr.span.clone()), + expr: make_expr_error_node(kind, message.clone(), texpr.span.clone()), diagnostics: Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::InternalError { - message: message.clone(), + message: message, span: texpr.span.clone(), }), module_name.clone(), @@ -2092,16 +2120,14 @@ pub fn resolve_expr_types( }), ExprData::ExprFieldAccess { summary: _, .. } => { let r = match texpr.children.clone().first().cloned() { - Some(base) => { - resolve_expr_types(base.clone(), env.clone(), module_name.clone()) - } + Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| r.expr.clone()), + expr: map_children(texpr.clone(), |child| (*r.expr).clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2127,7 +2153,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - vr.expr.clone(), + (*vr.expr).clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2140,13 +2166,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.clone().iter().cloned() { + for r in arg_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2155,11 +2181,11 @@ pub fn resolve_expr_types( expr: make_named_expr_node( expr_call_func_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprCall { - call_semantics: cs.clone(), - descent_evidence: de.clone(), + call_semantics: cs, + descent_evidence: de, }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2196,7 +2222,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: rr.expr.clone(), + expr: (*rr.expr).clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2221,7 +2247,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - vr.expr.clone(), + (*vr.expr).clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2236,13 +2262,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.clone().iter().cloned() { + for r in mc_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2251,10 +2277,10 @@ pub fn resolve_expr_types( expr: make_named_expr_node( expr_method_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprMethodCall { - method_semantics: ms.clone(), + method_semantics: ms, }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2288,7 +2314,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: sr.expr.clone(), + expr: (*sr.expr).clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2323,12 +2349,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match child.match_pattern.clone() { + match (*child.match_pattern).clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some(guard_r.expr.clone()), - body_r.expr.clone(), + Some((*guard_r.expr).clone()), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2352,12 +2378,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match child.match_pattern.clone() { + match (*child.match_pattern).clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, None, - body_r.expr.clone(), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2373,13 +2399,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.clone().iter().cloned() { + for r in match_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2388,7 +2414,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprMatch), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2397,41 +2423,41 @@ pub fn resolve_expr_types( ExprData::ExprIf => { let ch = texpr.children.clone(); let cr = match ch.clone().first().cloned() { - Some(c) => resolve_expr_types(c.clone(), env.clone(), module_name.clone()), + Some(c) => resolve_expr_types(c, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; let tr = match ch.clone().get(1 as usize).cloned() { - Some(t) => resolve_expr_types(t.clone(), env.clone(), module_name.clone()), + Some(t) => resolve_expr_types(t, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let er = match ch.clone().get(2 as usize).cloned() { - Some(e) => Some(resolve_expr_types( - e.clone(), - env.clone(), - module_name.clone(), - )), + let er = match ch.get(2 as usize).cloned() { + Some(e) => Some(resolve_expr_types(e, env.clone(), module_name.clone())), None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), + Some(r) => Rc::new(vec![ + (*cr.expr).clone(), + (*tr.expr).clone(), + (*r.expr).clone(), + ]), + None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( v1_rt::concat(cr.diagnostics.clone(), tr.diagnostics.clone()), - match er.clone() { + match er { Some(r) => r.diagnostics.clone(), None => Rc::new(vec![]), }, @@ -2441,36 +2467,32 @@ pub fn resolve_expr_types( ExprData::ExprLet => { let ch = texpr.children.clone(); let vr = match ch.clone().first().cloned() { - Some(v) => resolve_expr_types(v.clone(), env.clone(), module_name.clone()), + Some(v) => resolve_expr_types(v, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let br = match ch.clone().get(1 as usize).cloned() { - Some(bd) => Some(resolve_expr_types( - bd.clone(), - env.clone(), - module_name.clone(), - )), + let br = match ch.get(1 as usize).cloned() { + Some(bd) => Some(resolve_expr_types(bd, env.clone(), module_name.clone())), None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![vr.expr.clone()]), + Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), + None => Rc::new(vec![(*vr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( let_binding_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprLet), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat( vr.diagnostics.clone(), - match br.clone() { + match br { Some(r) => r.diagnostics.clone(), None => Rc::new(vec![]), }, @@ -2493,7 +2515,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - vr.expr.clone(), + (*vr.expr).clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2506,13 +2528,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.clone().iter().cloned() { + for r in fi_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2520,11 +2542,9 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_named_expr_node( authored_name_at(env.source_indices.clone(), texpr.clone()), - Rc::new(ExprData::ExprRecordLit { - parent_enum: pe.clone(), - }), + Rc::new(ExprData::ExprRecordLit { parent_enum: pe }), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2546,13 +2566,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in el_results.clone().iter().cloned() { + for r in el_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2561,7 +2581,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprListLit), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2574,14 +2594,14 @@ pub fn resolve_expr_types( } => { let ch = texpr.children.clone(); let lr = match ch.clone().first().cloned() { - Some(l) => resolve_expr_types(l.clone(), env.clone(), module_name.clone()), + Some(l) => resolve_expr_types(l, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let rr = match ch.clone().get(1 as usize).cloned() { - Some(r) => resolve_expr_types(r.clone(), env.clone(), module_name.clone()), + let rr = match ch.get(1 as usize).cloned() { + Some(r) => resolve_expr_types(r, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2590,11 +2610,11 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprBinOp { - op: op.clone(), - algebra_field: af.clone(), + op: op, + algebra_field: af, }), - Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(lr.diagnostics.clone(), rr.diagnostics.clone()), @@ -2602,7 +2622,7 @@ pub fn resolve_expr_types( } ExprData::ExprUnaryOp { op: op, .. } => { let r = match texpr.children.clone().first().cloned() { - Some(o) => resolve_expr_types(o.clone(), env.clone(), module_name.clone()), + Some(o) => resolve_expr_types(o, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2610,9 +2630,9 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_expr_node( - Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![r.expr.clone()]), - texpr.inferred.clone(), + Rc::new(ExprData::ExprUnaryOp { op: op }), + Rc::new(vec![(*r.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2629,7 +2649,7 @@ pub fn resolve_expr_types( .collect::>(), ); let r = match texpr.children.clone().first().cloned() { - Some(b) => resolve_expr_types(b.clone(), env.clone(), module_name.clone()), + Some(b) => resolve_expr_types(b, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2638,8 +2658,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), - texpr.inferred.clone(), + v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2663,7 +2683,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - r.expr.clone(), + (*r.expr).clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2681,13 +2701,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.clone().iter().cloned() { + for r in part_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2696,7 +2716,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2717,13 +2737,13 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in stmt_results.clone().iter().cloned() { + for r in stmt_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2732,7 +2752,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprBlock), resolved_children, - texpr.inferred.clone(), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2741,16 +2761,14 @@ pub fn resolve_expr_types( ExprData::ExprCast => { let ch = texpr.children.clone(); let r = match ch.clone().first().cloned() { - Some(inner) => { - resolve_expr_types(inner.clone(), env.clone(), module_name.clone()) - } + Some(inner) => resolve_expr_types(inner, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let tr = match ch.clone().get(1 as usize).cloned() { - Some(target) => resolve_node(target.clone(), env.clone(), module_name.clone()), + let tr = match ch.get(1 as usize).cloned() { + Some(target) => resolve_node(target, env.clone(), module_name.clone()), None => Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), @@ -2759,8 +2777,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(r.diagnostics.clone(), tr.diagnostics.clone()), @@ -2769,14 +2787,14 @@ pub fn resolve_expr_types( ExprData::ExprForEach => { let ch = texpr.children.clone(); let cr = match ch.clone().first().cloned() { - Some(c) => resolve_expr_types(c.clone(), env.clone(), module_name.clone()), + Some(c) => resolve_expr_types(c, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let br = match ch.clone().get(1 as usize).cloned() { - Some(b) => resolve_expr_types(b.clone(), env.clone(), module_name.clone()), + let br = match ch.get(1 as usize).cloned() { + Some(b) => resolve_expr_types(b, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2786,8 +2804,8 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![cr.expr.clone(), br.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2797,18 +2815,14 @@ pub fn resolve_expr_types( ExprData::ExprIndex => { let ch = texpr.children.clone(); let br = match ch.clone().first().cloned() { - Some(base) => { - resolve_expr_types(base.clone(), env.clone(), module_name.clone()) - } + Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let ir = match ch.clone().get(1 as usize).cloned() { - Some(index) => { - resolve_expr_types(index.clone(), env.clone(), module_name.clone()) - } + let ir = match ch.get(1 as usize).cloned() { + Some(index) => resolve_expr_types(index, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2817,8 +2831,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![br.expr.clone(), ir.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(br.diagnostics.clone(), ir.diagnostics.clone()), @@ -2827,27 +2841,21 @@ pub fn resolve_expr_types( ExprData::ExprSlice => { let ch = texpr.children.clone(); let br = match ch.clone().first().cloned() { - Some(base) => { - resolve_expr_types(base.clone(), env.clone(), module_name.clone()) - } + Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; let sr = match ch.clone().get(1 as usize).cloned() { - Some(start) => { - resolve_expr_types(start.clone(), env.clone(), module_name.clone()) - } + Some(start) => resolve_expr_types(start, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let er = match ch.clone().get(2 as usize).cloned() { - Some(end_e) => { - resolve_expr_types(end_e.clone(), env.clone(), module_name.clone()) - } + let er = match ch.get(2 as usize).cloned() { + Some(end_e) => resolve_expr_types(end_e, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2856,8 +2864,12 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![ + (*br.expr).clone(), + (*sr.expr).clone(), + (*er.expr).clone(), + ]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2868,9 +2880,7 @@ pub fn resolve_expr_types( } ExprData::ExprReturn => { let r = match texpr.children.clone().first().cloned() { - Some(inner) => { - resolve_expr_types(inner.clone(), env.clone(), module_name.clone()) - } + Some(inner) => resolve_expr_types(inner, env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2879,8 +2889,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![r.expr.clone()]), - texpr.inferred.clone(), + Rc::new(vec![(*r.expr).clone()]), + (*texpr.inferred).clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2970,7 +2980,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -2990,9 +3000,10 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) } else { Rc::new(vec![]) }; - let env = tp_names.clone().iter().cloned().fold( - env.clone(), - |e: Rc, tp_name: String| { + let env = tp_names + .iter() + .cloned() + .fold(env.clone(), |e: Rc, tp_name: String| { let tp_binding = Rc::new(TypeBinding { name: tp_name.clone(), resolved: Rc::new(Node { @@ -3028,7 +3039,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding, + tp_binding.clone(), ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3038,8 +3049,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) source_indices: e.source_indices.clone(), intern_table: e.intern_table.clone(), }) - }, - ); + }); let param_results = Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { @@ -3050,34 +3060,34 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push(pr.param.clone()); + __result.push((*pr.param).clone()); } __result }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for pr in param_results.clone().iter().cloned() { + for pr in param_results.iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result }); let ret_result = if is_parametric_type_alias_decl(item.clone()) { - match item.inferred.clone().as_deref().cloned() { + match (*item.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: authored_rhs, .. - }) => resolve_nominal_alias_rhs( - authored_rhs.clone(), + }) => resolve_nominal_alias_rhs(authored_rhs, env.clone(), module_name.clone()), + _ => resolve_optional_node( + (*item.inferred).clone(), env.clone(), module_name.clone(), ), - _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), } } else { - resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) + resolve_optional_node((*item.inferred).clone(), env.clone(), module_name.clone()) }; - let ret_resolved = ret_result.resolved.clone(); + let ret_resolved = (*ret_result.resolved).clone(); let ret_diags = ret_result.diagnostics.clone(); - let resolved_ret = if (item.inferred.clone() == None) { + let resolved_ret = if ((*item.inferred).clone() == None) { None } else { Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) @@ -3096,73 +3106,73 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push(ur.resource_use.clone()); + __result.push((*ur.resource_use).clone()); } __result }); let use_diags = Rc::new({ let mut __result = Vec::new(); - for ur in use_results.clone().iter().cloned() { + for ur in use_results.iter().cloned() { __result.extend((*ur.diagnostics.clone()).iter().cloned()); } __result }); - let body_resolved = if (item.body.clone() == None) { + let body_resolved = if ((*item.body).clone() == None) { Rc::new(ExprResolveResult { expr: item.clone(), diagnostics: Rc::new(vec![]), }) } else { resolve_expr_types( - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_body = if (item.body.clone() == None) { + let resolved_body = if ((*item.body).clone() == None) { None } else { - Some(body_resolved.expr.clone()) + Some((*body_resolved.expr).clone()) }; - let body_diags = if (item.body.clone() == None) { + let body_diags = if ((*item.body).clone() == None) { Rc::new(vec![]) } else { body_resolved.diagnostics.clone() }; - let anno_resolved = if (item.type_annotation.clone() == None) { + let anno_resolved = if ((*item.type_annotation).clone() == None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), }) } else { resolve_node( - item.type_annotation.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_anno = if (item.type_annotation.clone() == None) { + let resolved_anno = if ((*item.type_annotation).clone() == None) { None } else { - Some(anno_resolved.resolved.clone()) + Some((*anno_resolved.resolved).clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); - let transport_resolved = if (item.transport.clone() == None) { + let transport_resolved = if ((*item.transport).clone() == None) { Rc::new(TransportResolveResult { transport: local_transport_node(no_span()), diagnostics: Rc::new(vec![]), }) } else { resolve_transport_binding( - item.transport.clone().clone().unwrap(), + (*item.transport).clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_transport = if (item.transport.clone() == None) { + let resolved_transport = if ((*item.transport).clone() == None) { None } else { - Some(transport_resolved.transport.clone()) + Some((*transport_resolved.transport).clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3179,19 +3189,19 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); let prop_diags = Rc::new({ let mut __result = Vec::new(); - for pr in prop_results.clone().iter().cloned() { + for pr in prop_results.iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result }); let child_results = if ((item.connective.clone() == Connective::Conj) - && (item.transport.clone() == None)) + && ((*item.transport).clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3216,16 +3226,16 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: child.children.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: child.inferred.clone(), + inferred: (*child.inferred).clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), + body: (*child.body).clone(), + transport: (*child.transport).clone(), properties: v1_rt::concat( child.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), - type_annotation: child.type_annotation.clone(), + type_annotation: (*child.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3239,7 +3249,9 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { + if ((item.connective.clone() == Connective::Disj) + && ((*item.transport).clone() == None)) + { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3270,18 +3282,18 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: field.children.clone(), connective: field.connective.clone(), params: field.params.clone(), - inferred: field.inferred.clone(), + inferred: (*field.inferred).clone(), return_cardinality: field .return_cardinality .clone(), uses: field.uses.clone(), - body: field.body.clone(), - transport: field.transport.clone(), + body: (*field.body).clone(), + transport: (*field.transport).clone(), properties: v1_rt::concat( field.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), - type_annotation: field.type_annotation.clone(), + type_annotation: (*field.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3297,7 +3309,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.item.clone()); + __result.push((*fr.item).clone()); } __result }); @@ -3316,13 +3328,13 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: resolved_fields.clone(), connective: variant.connective.clone(), params: variant.params.clone(), - inferred: variant.inferred.clone(), + inferred: (*variant.inferred).clone(), return_cardinality: variant.return_cardinality.clone(), uses: variant.uses.clone(), - body: variant.body.clone(), - transport: variant.transport.clone(), + body: (*variant.body).clone(), + transport: (*variant.transport).clone(), properties: variant.properties.clone(), - type_annotation: variant.type_annotation.clone(), + type_annotation: (*variant.type_annotation).clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3352,13 +3364,13 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.item.clone()); + __result.push((*cr.item).clone()); } __result }); let child_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.clone().iter().cloned() { + for cr in child_results.iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 76923b77bc0..acc831618e4 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -60,7 +60,7 @@ pub fn is_typed_service_call_receiver( .first() .cloned() { - Some(ch) => ((ch.clone() >= 65) && (ch.clone() <= 90)), + Some(ch) => ((ch.clone() >= 65) && (ch <= 90)), None => false, }, _ => false, @@ -82,7 +82,7 @@ pub fn extract_typed_service_name( ExprData::ExprVar { binding_kind: _, .. } => { - let ns = expr_var_name_at(b.clone(), source_indices.clone()); + let ns = expr_var_name_at(b, source_indices.clone()); Some(v1_rt::concat(v1_rt::concat(ns, ".".to_string()), f)) } _ => None, @@ -122,7 +122,7 @@ pub fn collect_typed_service_calls_into( } => { let r = method_receiver(texpr.clone()); if is_typed_service_call_receiver(r.clone(), source_indices.clone()) { - match extract_typed_service_name(r.clone(), source_indices.clone()) { + match extract_typed_service_name(r, source_indices.clone()) { Some(service_name) => { if emit_map_has(acc.seen.clone(), service_name.clone()) { acc.clone() @@ -133,10 +133,7 @@ pub fn collect_typed_service_calls_into( service_name.clone(), true, ), - result: v1_rt::rc_list_push( - acc.result.clone(), - service_name.clone(), - ), + result: v1_rt::rc_list_push(acc.result.clone(), service_name), }) } } @@ -149,7 +146,7 @@ pub fn collect_typed_service_calls_into( _ => acc.clone(), }; let result = texpr.children.clone().iter().cloned().fold( - this_acc.clone(), + this_acc, |a: Rc, child: Rc| { collect_typed_service_calls_into(child.clone(), a, source_indices.clone()) }, @@ -172,14 +169,14 @@ pub fn collect_called_func_names_into( } else { Rc::new(UniqueAccum { seen: v1_rt::rc_map_insert(acc.seen.clone(), f.clone(), true), - result: v1_rt::rc_list_push(acc.result.clone(), f.clone()), + result: v1_rt::rc_list_push(acc.result.clone(), f), }) } } _ => acc.clone(), }; let result = texpr.children.clone().iter().cloned().fold( - this_acc.clone(), + this_acc, |a: Rc, child: Rc| { collect_called_func_names_into(child.clone(), a, source_indices.clone()) }, @@ -209,16 +206,16 @@ pub fn expand_transitive_services_once( modules: Rc>>, registry: Rc>>, ) -> Rc>> { - modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); + modules.iter().cloned().fold(registry, |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { + let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { - let has_no_body = (item.body.clone() == None); + let has_no_body = ((*item.body).clone() == None); if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); + let called = collect_called_func_names((*item.body).clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), @@ -272,7 +269,7 @@ pub fn expand_transitive_services( let before = total_service_count(registry.clone()); let next = expand_transitive_services_once(modules.clone(), registry.clone()); let after = total_service_count(next.clone()); - if (before == after) { + if (before.clone() == after.clone()) { break registry.clone(); } else { { @@ -305,7 +302,7 @@ pub fn check_service_field_access_node( field, ); match v1_rt::map_get(&service_registry, path.clone()) { - Some(_) => Some(nominal_type_ref(path.clone())), + Some(_) => Some(nominal_type_ref(path)), None => None, } } @@ -330,7 +327,7 @@ pub fn check_service_method_call_node( Some(ops) => { let matching = Rc::new({ let mut __result = Vec::new(); - for op in ops.clone().iter().cloned() { + for op in ops.iter().cloned() { if (op.name.clone() == method.clone()) { __result.push(op); } @@ -414,7 +411,7 @@ pub fn service_op_entry( Rc::new(OpEntry { name: authored_name_at(source_indices.clone(), child.clone()), outputs: inferred_to_outputs( - child.inferred.clone(), + (*child.inferred).clone(), child.span.clone(), source_indices.clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index ef23eba9abf..3de114c6872 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -85,7 +85,7 @@ pub fn lookup_in_parent_chain( pub fn lookup_resolved_sig(env: Rc, name: String) -> Option> { match v1_rt::map_get(&env.local.clone(), name.clone()) { - Some(sig) => Some(sig.clone()), + Some(sig) => Some(sig), None => lookup_in_parent_chain(env.parents.clone(), name.clone()), } } @@ -99,10 +99,10 @@ pub fn collect_func_call_edges( let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( - (*if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + (*if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) { collect_calls_in_expr( authored_name_at(source_indices.clone(), item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), local_func_set.clone(), source_indices.clone(), ) @@ -130,7 +130,7 @@ pub fn collect_calls_in_expr( if emit_map_has(local_func_set.clone(), f.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: f.clone(), + callee: f, })]) } else { Rc::new(vec![]) @@ -226,7 +226,7 @@ pub fn declared_to_resolved(dsig: Rc) -> Rc { Rc::new(ResolvedFuncSig { name: dsig.name.clone(), params: dsig.params.clone(), - inferred: dsig.inferred.clone().clone().unwrap(), + inferred: (*dsig.inferred).clone().clone().unwrap(), is_async: dsig.is_async.clone(), output_provenance: dsig.output_provenance.clone(), variant_provenance: dsig.variant_provenance.clone(), @@ -243,7 +243,7 @@ pub fn merge_remaining_declared( .fold( resolved, |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -277,7 +277,7 @@ pub fn topo_resolve_loop( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -358,7 +358,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -394,7 +394,7 @@ pub fn topo_resolve_loop( cycle_accum.signatures.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -427,7 +427,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if ((*dsig.inferred).clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -472,7 +472,7 @@ pub fn topo_resolve_loop( __result }); { - let __tco_0 = next_remaining; + let __tco_0 = next_remaining.clone(); let __tco_1 = ready_accum.signatures.clone(); let __tco_2 = ready_accum.diagnostics.clone(); let __tco_3 = (fuel - 1); @@ -498,7 +498,8 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) + { __result.push(item); } } @@ -522,11 +523,11 @@ pub fn resolve_func_sigs( v1_rt::rc_empty_map::>(), declared_sigs, call_edges, - local_func_set.clone(), + local_func_set, module_name, Rc::new(vec![]), parent_envs, - (local_func_names.clone().len() as i64), + (local_func_names.len() as i64), ) } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 27e0642597b..a7c06ff5980 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -83,14 +83,14 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn resolved_type(n: Rc) -> Rc { - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => error_type(), } } pub fn child_type_node(ch: Rc) -> Rc { - if (ch.inferred.clone() != None) { + if ((*ch.inferred).clone() != None) { resolved_type(ch.clone()) } else { ch.clone() @@ -99,7 +99,7 @@ pub fn child_type_node(ch: Rc) -> Rc { pub fn child_type_at(n: Rc, index: i64) -> Option> { match n.children.clone().get(index as usize).cloned() { - Some(ch) => Some(child_type_node(ch.clone())), + Some(ch) => Some(child_type_node(ch)), None => None, } } @@ -142,8 +142,8 @@ pub fn canonical_template_name( { let nm = authored_name_at(source_indices, n); match container_template_algebra(nm.clone()) { - Some(algebra) => algebra.clone(), - None => nm.clone(), + Some(algebra) => algebra, + None => nm, } } } @@ -170,16 +170,16 @@ pub fn reground_alias_carrier_identity( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -201,16 +201,16 @@ pub fn structural_carrier_template_name( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -242,8 +242,8 @@ pub fn is_fully_resolved( source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_is_type_var = match n.inferred.clone() { - Some(inf) => is_type_variable(inf.clone()), + let self_is_type_var = match (*n.inferred).clone() { + Some(inf) => is_type_variable(inf), None => false, }; if self_is_type_var { @@ -254,7 +254,7 @@ pub fn is_fully_resolved( source_indices.clone(), n.clone(), )) { - Some(expected) => ((n.children.clone().len() as i64) < expected.clone()), + Some(expected) => ((n.children.clone().len() as i64) < expected), None => false, }; if under_param { @@ -295,7 +295,7 @@ pub fn bare_map_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(key_id.clone()), + node: type_variable_node(key_id), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -317,7 +317,7 @@ pub fn bare_map_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(val_id.clone()), + node: type_variable_node(val_id), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -367,7 +367,7 @@ pub fn bare_set_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(elem_id.clone()), + node: type_variable_node(elem_id), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -438,7 +438,7 @@ pub fn missing_kernel_container_profile_type(kind_name: String) -> Rc { match_pattern: None, expr_data: Rc::new(ExprData::ExprError { kind: ExprErrorKind::InternalExprError, - message: msg.clone(), + message: msg, }), ident: None, }) @@ -461,7 +461,7 @@ pub fn make_container_type(kind_name: String, element: Rc) -> Rc, value: Rc) -> Rc { Rc::new(Node { name: key_name.clone(), span: kernel_span(key_name.clone()), - ident_span: Some(kernel_span(key_name.clone())), + ident_span: Some(kernel_span(key_name)), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -536,7 +536,7 @@ pub fn make_map_type(key: Rc, value: Rc) -> Rc { Rc::new(Node { name: val_name.clone(), span: kernel_span(val_name.clone()), - ident_span: Some(kernel_span(val_name.clone())), + ident_span: Some(kernel_span(val_name)), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -752,16 +752,16 @@ pub fn enrich_base_with_fields( children: fields, connective: Connective::Conj, params: base.params.clone(), - inferred: base.inferred.clone(), + inferred: (*base.inferred).clone(), return_cardinality: base.return_cardinality.clone(), uses: base.uses.clone(), - body: base.body.clone(), - transport: base.transport.clone(), + body: (*base.body).clone(), + transport: (*base.transport).clone(), properties: base.properties.clone(), - type_annotation: base.type_annotation.clone(), + type_annotation: (*base.type_annotation).clone(), is_self_recursive: base.is_self_recursive.clone(), has_non_tail_self_call: base.has_non_tail_self_call.clone(), - match_pattern: base.match_pattern.clone(), + match_pattern: (*base.match_pattern).clone(), expr_data: base.expr_data.clone(), ident: None, }) @@ -812,7 +812,7 @@ pub fn algebra_child_or_placeholder( .first() .cloned() { - Some(child) => child_type_node(child.clone()), + Some(child) => child_type_node(child), None => type_variable_node(placeholder), } } @@ -844,12 +844,12 @@ pub fn instantiate_algebra_type( diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::NamedTemplate { name: n, .. } => Rc::new(KernelTypeBuild { - ty: nominal_type_ref(n.clone()), + ty: nominal_type_ref(n), diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { Rc::new(KernelTypeBuild { - ty: type_variable_node(var_id.clone()), + ty: type_variable_node(var_id), diagnostics: Rc::new(vec![]), }) } @@ -858,17 +858,16 @@ pub fn instantiate_algebra_type( element: inner, .. } => { - let kind_name = match (*src.clone()).clone() { + let kind_name = match (*src).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), base.clone()) } - ContainerSource::Named { name: n, .. } => n.clone(), + ContainerSource::Named { name: n, .. } => n, }; - let inner_b = - instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, inner_b.ty.clone()); + let inner_b = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); + let built = make_container_type(kind_name, (*inner_b.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -876,29 +875,25 @@ pub fn instantiate_algebra_type( }) } AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => { - let ib = - instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); + let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { - let ib = - instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } AlgebraTypeTemplate::TupleOf { first, second, .. } => { - let fb = - instantiate_algebra_type(first.clone(), base.clone(), source_indices.clone()); - let sb = - instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); + let fb = instantiate_algebra_type(first, base.clone(), source_indices.clone()); + let sb = instantiate_algebra_type(second, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -909,7 +904,7 @@ pub fn instantiate_algebra_type( } => { let param_bs = Rc::new({ let mut __result = Vec::new(); - for tp in p.clone().iter().cloned() { + for tp in p.iter().cloned() { __result.push(instantiate_algebra_type( tp.clone(), base.clone(), @@ -927,14 +922,14 @@ pub fn instantiate_algebra_type( }); let param_nodes = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + for b in param_bs.iter().cloned() { + __result.push((*b.ty).clone()); } __result }); - let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); + let rb = instantiate_algebra_type(r, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, rb.ty.clone()), + ty: make_callable_type(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,30 +957,26 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.clone().iter().cloned() { + for b in param_bs.iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result }); let return_b = instantiate_algebra_type( - template.return_type.clone(), + (*template.return_type).clone(), base.clone(), source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - algebra_method_field( - template.name.clone(), - param_types.clone(), - return_b.ty.clone(), - ) + algebra_method_field(template.name.clone(), param_types, (*return_b.ty).clone()) } else { - algebra_value_field(template.name.clone(), return_b.ty.clone()) + algebra_value_field(template.name.clone(), (*return_b.ty).clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1005,7 +996,7 @@ pub fn enrich_kernel_type( Some(p) => { let field_bs = Rc::new({ let mut __result = Vec::new(); - for template in algebra_templates_for_profile(p.clone()).iter().cloned() { + for template in algebra_templates_for_profile(p).iter().cloned() { __result.push(instantiate_algebra_field( template.clone(), base.clone(), @@ -1017,13 +1008,13 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); let field_diags = Rc::new({ let mut __result = Vec::new(); - for b in field_bs.clone().iter().cloned() { + for b in field_bs.iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result @@ -1051,70 +1042,62 @@ pub fn unify_template( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*template).clone() { AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { if (v1_rt::map_get(&subst, var_id.clone()) != None) { - subst.clone() + subst } else { - v1_rt::rc_map_insert(subst.clone(), var_id.clone(), concrete.clone()) + v1_rt::rc_map_insert(subst, var_id, concrete.clone()) } } AlgebraTypeTemplate::ReceiverSelf => { let s1 = match concrete.children.clone().first().cloned() { Some(k) => { if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { - subst.clone() + subst } else { - v1_rt::rc_map_insert( - subst.clone(), - "__key__".to_string(), - child_type_node(k.clone()), - ) + v1_rt::rc_map_insert(subst, "__key__".to_string(), child_type_node(k)) } } - None => subst.clone(), + None => subst, }; match concrete.children.clone().get(1 as usize).cloned() { Some(v) => { if (v1_rt::map_get(&s1, "__value__".to_string()) != None) { - s1.clone() + s1 } else { - v1_rt::rc_map_insert( - s1.clone(), - "__value__".to_string(), - child_type_node(v.clone()), - ) + v1_rt::rc_map_insert(s1, "__value__".to_string(), child_type_node(v)) } } - None => s1.clone(), + None => s1, } } AlgebraTypeTemplate::ReceiverKey => { if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { - subst.clone() + subst } else { - v1_rt::rc_map_insert(subst.clone(), "__key__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst, "__key__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverValue => { if (v1_rt::map_get(&subst, "__value__".to_string()) != None) { - subst.clone() + subst } else { - v1_rt::rc_map_insert(subst.clone(), "__value__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst, "__value__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverElement => { if (v1_rt::map_get(&subst, "__element__".to_string()) != None) { - subst.clone() + subst } else { - v1_rt::rc_map_insert(subst.clone(), "__element__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst, "__element__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::CallableOf { return_type: ret_template, .. } => unify_template( - ret_template.clone(), + ret_template, concrete.clone(), receiver.clone(), - subst.clone(), + subst, source_indices.clone(), ), AlgebraTypeTemplate::ContainerOf { @@ -1122,24 +1105,24 @@ pub fn unify_template( element: elem_template, .. } => { - let expected_name = match (*src.clone()).clone() { + let expected_name = match (*src).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), receiver.clone()) } - ContainerSource::Named { name: n, .. } => n.clone(), + ContainerSource::Named { name: n, .. } => n, }; if (authored_name_at(source_indices.clone(), concrete.clone()) != expected_name) { - subst.clone() + subst } else { match concrete.children.clone().first().cloned() { Some(child) => unify_template( - elem_template.clone(), - child_type_node(child.clone()), + elem_template, + child_type_node(child), receiver.clone(), - subst.clone(), + subst, source_indices.clone(), ), - None => subst.clone(), + None => subst, } } } @@ -1148,13 +1131,13 @@ pub fn unify_template( .. } => match concrete.children.clone().first().cloned() { Some(child) => unify_template( - inner_template.clone(), - child_type_node(child.clone()), + inner_template, + child_type_node(child), receiver.clone(), - subst.clone(), + subst, source_indices.clone(), ), - None => subst.clone(), + None => subst, }, AlgebraTypeTemplate::TupleOf { first: ft, @@ -1163,18 +1146,18 @@ pub fn unify_template( } => { let s2 = match concrete.children.clone().first().cloned() { Some(c) => unify_template( - ft.clone(), + ft, child_type_node(c.clone()), receiver.clone(), - subst.clone(), + subst, source_indices.clone(), ), - None => subst.clone(), + None => subst, }; match concrete.children.clone().get(1 as usize).cloned() { Some(c) => unify_template( - st.clone(), - child_type_node(c.clone()), + st, + child_type_node(c), receiver.clone(), s2, source_indices.clone(), @@ -1182,7 +1165,7 @@ pub fn unify_template( None => s2, } } - _ => subst.clone(), + _ => subst, }) } @@ -1202,7 +1185,7 @@ pub fn build_type_substitution( ) -> Rc>> { { let first_is_self = match param_templates.clone().first().cloned() { - Some(t) => is_receiver_self(t.clone()), + Some(t) => is_receiver_self(t), None => false, }; let non_receiver_templates = if first_is_self { @@ -1237,7 +1220,7 @@ pub fn build_type_substitution( __result }); pairs.iter().cloned().fold( - base_subst.clone(), + base_subst, |subst: Rc>>, pair: (i64, Rc)| { let arg_type = match Rc::new({ let mut __result = Vec::new(); @@ -1296,11 +1279,11 @@ pub fn apply_type_substitution( AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { match v1_rt::map_get(&subst, var_id.clone()) { Some(resolved) => Rc::new(KernelTypeBuild { - ty: resolved.clone(), + ty: resolved, diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { - ty: type_variable_node(var_id.clone()), + ty: type_variable_node(var_id), diagnostics: Rc::new(vec![]), }), } @@ -1312,8 +1295,8 @@ pub fn apply_type_substitution( for ch in receiver.children.clone().iter().cloned() { if !({ let inner = child_type_node(ch.clone()); - if (inner.inferred.clone() != None) { - is_type_variable(inner.inferred.clone().clone().unwrap()) + if ((*inner.inferred).clone() != None) { + is_type_variable((*inner.inferred).clone().clone().unwrap()) } else { ((inner.ident_span.clone() == None) || !is_kernel_type(authored_name_at( @@ -1335,10 +1318,10 @@ pub fn apply_type_substitution( match v1_rt::map_get(&subst, "__key__".to_string()) { Some(key) => { let val = match v1_rt::map_get(&subst, "__value__".to_string()) { - Some(v) => v.clone(), + Some(v) => v, None => type_variable_node("V".to_string()), }; - make_map_type(key.clone(), val) + make_map_type(key, val) } None => Rc::new(KernelTypeBuild { ty: receiver.clone(), @@ -1346,11 +1329,9 @@ pub fn apply_type_substitution( }), } } else { - if (arity.clone() == Some(1)) { + if (arity == Some(1)) { match v1_rt::map_get(&subst, "__element__".to_string()) { - Some(elem) => { - make_container_type(receiver_name_str.clone(), elem.clone()) - } + Some(elem) => make_container_type(receiver_name_str, elem), None => Rc::new(KernelTypeBuild { ty: receiver.clone(), diagnostics: Rc::new(vec![]), @@ -1373,25 +1354,25 @@ pub fn apply_type_substitution( } AlgebraTypeTemplate::ReceiverElement => match receiver.children.clone().first().cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child.clone()), + ty: child_type_node(child), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__element__".to_string()) { Some(elem) => Rc::new(KernelTypeBuild { - ty: elem.clone(), + ty: elem, diagnostics: Rc::new(vec![]), }), None => { let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 0) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n.clone()), + ty: type_variable_node(n), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![kernel_container_profile_miss_diagnostic( - rname.clone(), + rname, )]), }), } @@ -1400,25 +1381,25 @@ pub fn apply_type_substitution( }, AlgebraTypeTemplate::ReceiverKey => match receiver.children.clone().first().cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child.clone()), + ty: child_type_node(child), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__key__".to_string()) { Some(key) => Rc::new(KernelTypeBuild { - ty: key.clone(), + ty: key, diagnostics: Rc::new(vec![]), }), None => { let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 0) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n.clone()), + ty: type_variable_node(n), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![kernel_container_profile_miss_diagnostic( - rname.clone(), + rname, )]), }), } @@ -1428,7 +1409,7 @@ pub fn apply_type_substitution( AlgebraTypeTemplate::ReceiverValue => { match receiver.children.clone().get(1 as usize).cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child.clone()), + ty: child_type_node(child), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__value__".to_string()) { @@ -1440,13 +1421,13 @@ pub fn apply_type_substitution( let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 1) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n.clone()), + ty: type_variable_node(n), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![ - kernel_container_profile_miss_diagnostic(rname.clone()), + kernel_container_profile_miss_diagnostic(rname), ]), }), } @@ -1455,7 +1436,7 @@ pub fn apply_type_substitution( } } AlgebraTypeTemplate::NamedTemplate { name: n, .. } => Rc::new(KernelTypeBuild { - ty: nominal_type_ref(n.clone()), + ty: nominal_type_ref(n), diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::ContainerOf { @@ -1463,21 +1444,21 @@ pub fn apply_type_substitution( element: inner, .. } => { - let kind_name = match (*src.clone()).clone() { + let kind_name = match (*src).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), receiver.clone()) } - ContainerSource::Named { name: n, .. } => n.clone(), + ContainerSource::Named { name: n, .. } => n, }; let inner_applied = apply_type_substitution( - inner.clone(), + inner, subst.clone(), receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, inner_applied.ty.clone()); + let built = make_container_type(kind_name, (*inner_applied.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1486,26 +1467,26 @@ pub fn apply_type_substitution( } AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => { let ib = apply_type_substitution( - inner.clone(), + inner, subst.clone(), receiver.clone(), source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = apply_type_substitution( - inner.clone(), + inner, subst.clone(), receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1515,19 +1496,19 @@ pub fn apply_type_substitution( .. } => { let fb = apply_type_substitution( - ft.clone(), + ft, subst.clone(), receiver.clone(), source_indices.clone(), ); let sb = apply_type_substitution( - st.clone(), + st, subst.clone(), receiver.clone(), source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1538,7 +1519,7 @@ pub fn apply_type_substitution( } => { let param_bs = Rc::new({ let mut __result = Vec::new(); - for tp in p.clone().iter().cloned() { + for tp in p.iter().cloned() { __result.push(apply_type_substitution( tp.clone(), subst.clone(), @@ -1551,23 +1532,19 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.clone().iter().cloned() { + for b in param_bs.iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result }); - let rb = apply_type_substitution( - r.clone(), - subst.clone(), - receiver.clone(), - source_indices.clone(), - ); + let rb = + apply_type_substitution(r, subst.clone(), receiver.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { ty: make_callable_type( Rc::new({ @@ -1583,7 +1560,7 @@ pub fn apply_type_substitution( } __result }), - rb.ty.clone(), + (*rb.ty).clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1592,25 +1569,25 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self(template.return_type.clone()) + is_receiver_self((*template.return_type).clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable(template.return_type.clone()) + has_type_variable((*template.return_type).clone()) } pub fn has_type_variable(t: Rc) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*t).clone() { AlgebraTypeTemplate::AlgebraTypeVariable { id: _, .. } => true, - AlgebraTypeTemplate::ContainerOf { element: inner, .. } => has_type_variable(inner.clone()), - AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => has_type_variable(inner.clone()), - AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => has_type_variable(inner.clone()), + AlgebraTypeTemplate::ContainerOf { element: inner, .. } => has_type_variable(inner), + AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => has_type_variable(inner), + AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => has_type_variable(inner), AlgebraTypeTemplate::TupleOf { first: f, second: s, .. - } => (has_type_variable(f.clone()) || has_type_variable(s.clone())), - AlgebraTypeTemplate::CallableOf { return_type: r, .. } => has_type_variable(r.clone()), + } => (has_type_variable(f) || has_type_variable(s)), + AlgebraTypeTemplate::CallableOf { return_type: r, .. } => has_type_variable(r), _ => false, }) } @@ -1631,7 +1608,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - template.return_type.clone(), + (*template.return_type).clone(), subst, receiver_type.clone(), source_indices.clone(), @@ -1643,8 +1620,8 @@ pub fn callable_inferred(n: Rc) -> Rc { { let is_callable = ((n.params.clone().len() as i64) > 0); if is_callable { - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: ret, .. }) => ret.clone(), + match (*n.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: ret, .. }) => ret, None => error_type(), _ => error_type(), } @@ -1657,19 +1634,19 @@ pub fn callable_inferred(n: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if ((n.type_annotation.clone() != None) && has_structure) { + let unwrapped = if (((*n.type_annotation).clone() != None) && has_structure.clone()) { n.children.clone().first().cloned() } else { None }; - match unwrapped { + match unwrapped.clone() { Some(base) => { let __tco_0 = base.clone(); n = __tco_0; continue; } None => { - break n.clone(); + break n; } } } @@ -1686,17 +1663,15 @@ pub fn node_type_shape( let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_leaf { { - let __is_named_ref = match n.inferred.clone().as_deref().cloned() { + let __is_named_ref = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) && (authored_name_at(source_indices.clone(), rt.clone()) != "None".to_string())) - && (is_kernel_type(authored_name_at( - source_indices.clone(), - rt.clone(), - )) == false)) + && (is_kernel_type(authored_name_at(source_indices.clone(), rt)) + == false)) } _ => false, }; @@ -1744,7 +1719,7 @@ pub fn node_type_shape( { let elem_shape = match n.children.clone().first().cloned() { Some(el) => node_type_shape( - child_type_node(el.clone()), + child_type_node(el), source_indices.clone(), ), None => "?".to_string(), @@ -1797,23 +1772,23 @@ pub fn node_type_compatible( mut source_indices: Rc>>, ) -> bool { loop { - let left_err = if (left.inferred.clone() != None) { - is_compiler_error(left.inferred.clone().clone().unwrap()) + let left_err = if ((*left.inferred).clone() != None) { + is_compiler_error((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { - is_compiler_error(right.inferred.clone().clone().unwrap()) + let right_err = if ((*right.inferred).clone() != None) { + is_compiler_error((*right.inferred).clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { - is_type_variable(left.inferred.clone().clone().unwrap()) + let left_tv = if ((*left.inferred).clone() != None) { + is_type_variable((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { - is_type_variable(right.inferred.clone().clone().unwrap()) + let right_tv = if ((*right.inferred).clone() != None) { + is_type_variable((*right.inferred).clone().clone().unwrap()) } else { false }; @@ -1821,23 +1796,23 @@ pub fn node_type_compatible( let right_opt = (right.return_cardinality.clone() == Cardinality::CardOptional); let right_is_unit = is_unit_like(right.clone()); let left_is_unit = is_unit_like(left.clone()); - if (left_err || right_err) { + if (left_err.clone() || right_err.clone()) { break true; } else { - if (left_tv || right_tv) { + if (left_tv.clone() || right_tv.clone()) { break true; } else { - if (left_opt.clone() && right_is_unit) { + if (left_opt.clone() && right_is_unit.clone()) { break true; } else { - if (left_is_unit && right_opt.clone()) { + if (left_is_unit.clone() && right_opt.clone()) { break true; } else { let left_is_container = node_is_element_collection(left.clone(), source_indices.clone()); let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); - if (left_is_container && right_is_container) { + if (left_is_container.clone() && right_is_container.clone()) { if (canonical_template_name(left.clone(), source_indices.clone()) != canonical_template_name(right.clone(), source_indices.clone())) { @@ -1852,7 +1827,9 @@ pub fn node_type_compatible( let left_el_is_unit = is_unit_like(left_el.clone()); let right_el_is_unit = is_unit_like(right_el.clone()); - if (left_el_is_unit || right_el_is_unit) { + if (left_el_is_unit.clone() + || right_el_is_unit.clone()) + { break true; } else { { @@ -1932,7 +1909,7 @@ pub fn node_type_compatible( let right_inner = with_required_cardinality(right.clone()); let left_inner_is_unit = is_unit_like(left_inner.clone()); let right_inner_is_unit = is_unit_like(right_inner.clone()); - if (left_inner_is_unit || right_inner_is_unit) { + if (left_inner_is_unit.clone() || right_inner_is_unit.clone()) { break true; } else { { @@ -1978,7 +1955,7 @@ pub fn prefer_specific_type( let left_is_unit_inner = if left_is_container.clone() { match left_first_child { Some(ch) => { - let el = child_type_node(ch.clone()); + let el = child_type_node(ch); let el_is_unit = is_unit_like(el); el_is_unit } @@ -1996,24 +1973,24 @@ pub fn prefer_specific_type( }; let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); - let same_kind = if (left_is_container.clone() && right_is_container) { + let same_kind = if (left_is_container && right_is_container) { (left_norm_name == authored_name_at(source_indices.clone(), right.clone())) } else { - if (left_is_optional.clone() && right_is_optional) { + if (left_is_optional && right_is_optional) { true } else { false } }; if (same_kind && left_is_unit_inner) { - right.clone() + right } else { if (is_fully_resolved(right.clone(), source_indices.clone()) && !is_fully_resolved(left.clone(), source_indices.clone())) { - right.clone() + right } else { - left.clone() + left } } } @@ -2025,23 +2002,23 @@ pub fn node_type_equals( source_indices: Rc>>, ) -> bool { { - let left_err = if (left.inferred.clone() != None) { - is_compiler_error(left.inferred.clone().clone().unwrap()) + let left_err = if ((*left.inferred).clone() != None) { + is_compiler_error((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { - is_compiler_error(right.inferred.clone().clone().unwrap()) + let right_err = if ((*right.inferred).clone() != None) { + is_compiler_error((*right.inferred).clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { - is_type_variable(left.inferred.clone().clone().unwrap()) + let left_tv = if ((*left.inferred).clone() != None) { + is_type_variable((*left.inferred).clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { - is_type_variable(right.inferred.clone().clone().unwrap()) + let right_tv = if ((*right.inferred).clone() != None) { + is_type_variable((*right.inferred).clone().clone().unwrap()) } else { false }; @@ -2055,7 +2032,7 @@ pub fn node_type_equals( if (left_tv.clone() && right_tv.clone()) { true } else { - if (left_tv.clone() || right_tv.clone()) { + if (left_tv || right_tv) { false } else { if (left_opt.clone() && right_is_unit_eq) { @@ -2064,7 +2041,7 @@ pub fn node_type_equals( if (left_is_unit_eq && right_opt.clone()) { true } else { - if (left_opt.clone() && right_opt.clone()) { + if (left_opt && right_opt) { node_type_equals_core( with_required_cardinality(left.clone()), with_required_cardinality(right.clone()), @@ -2151,10 +2128,10 @@ pub fn node_type_equals_core( } } } else { - if (left_leaf.clone() && right_struct.clone()) { + if (left_leaf && right_struct) { (left_name == right_name) } else { - if (left_struct.clone() && right_leaf.clone()) { + if (left_struct && right_leaf) { (left_name == right_name) } else { { @@ -2170,8 +2147,8 @@ pub fn node_type_equals_core( Some(left_ch) => { match right.children.clone().first().cloned() { Some(right_ch) => node_type_equals( - child_type_node(left_ch.clone()), - child_type_node(right_ch.clone()), + child_type_node(left_ch), + child_type_node(right_ch), source_indices.clone(), ), None => false, @@ -2194,46 +2171,41 @@ pub fn node_type_equals_core( && ((right.children.clone().len() as i64) == 2)) { match left.children.clone().first().cloned() { - Some(left_first) => { - match right.children.clone().first().cloned() { - Some(right_first) => match left + Some(left_first) => match right + .children + .clone() + .first() + .cloned() + { + Some(right_first) => match left + .children + .clone() + .get(1 as usize) + .cloned() + { + Some(left_second) => match right .children .clone() .get(1 as usize) .cloned() { - Some(left_second) => match right - .children - .clone() - .get(1 as usize) - .cloned() - { - Some(right_second) => { - (node_type_equals( - child_type_node( - left_first.clone(), - ), - child_type_node( - right_first.clone(), - ), - source_indices.clone(), - ) && node_type_equals( - child_type_node( - left_second.clone(), - ), - child_type_node( - right_second.clone(), - ), - source_indices.clone(), - )) - } - None => false, - }, + Some(right_second) => { + (node_type_equals( + child_type_node(left_first), + child_type_node(right_first), + source_indices.clone(), + ) && node_type_equals( + child_type_node(left_second), + child_type_node(right_second), + source_indices.clone(), + )) + } None => false, }, None => false, - } - } + }, + None => false, + }, None => false, } } else { @@ -2291,8 +2263,7 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left - .inferred + match (*left.inferred) .clone() .as_deref() .cloned() @@ -2300,8 +2271,7 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right - .inferred + }) => match (*right.inferred) .clone() .as_deref() .cloned() @@ -2310,15 +2280,15 @@ pub fn node_type_equals_core( node: right_ret, .. }) => node_type_equals( - left_ret.clone(), - right_ret.clone(), + left_ret, + right_ret, source_indices.clone(), ), None => false, _ => false, }, None => { - (right.inferred.clone() == None) + ((*right.inferred).clone() == None) } _ => false, } @@ -2344,18 +2314,18 @@ pub fn node_type_deps( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { - is_type_variable(n.inferred.clone().clone().unwrap()) + let n_is_type_var = if ((*n.inferred).clone() != None) { + is_type_variable((*n.inferred).clone().clone().unwrap()) } else { false }; if n_is_type_var { return Rc::new(vec![]); } - let __is_named_ref = if (n.inferred.clone() == None) { + let __is_named_ref = if ((*n.inferred).clone() == None) { false } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -2371,9 +2341,9 @@ pub fn node_type_deps( let has_structure = (n.connective.clone() != Connective::NoConnective); let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_named_ref { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - Rc::new(vec![authored_name_at(source_indices.clone(), rt.clone())]) + Rc::new(vec![authored_name_at(source_indices.clone(), rt)]) } _ => Rc::new(vec![]), } @@ -2383,12 +2353,12 @@ pub fn node_type_deps( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.extend( - (*match child.inferred.clone().as_deref().cloned() { + (*match (*child.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } _ => { - if (child.inferred.clone() == None) { + if ((*child.inferred).clone() == None) { node_type_deps(child.clone(), source_indices.clone()) } else { Rc::new(vec![]) @@ -2402,10 +2372,10 @@ pub fn node_type_deps( __result }) } else { - if (n.inferred.clone() != None) { - match n.inferred.clone().as_deref().cloned() { + if ((*n.inferred).clone() != None) { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - node_type_deps(rt.clone(), source_indices.clone()) + node_type_deps(rt, source_indices.clone()) } _ => Rc::new(vec![]), } @@ -2426,7 +2396,7 @@ pub fn node_type_deps( if ((n.ident_span.clone() != None) && (is_kernel_type(n_name.clone()) == false)) { - v1_rt::concat(Rc::new(vec![n_name.clone()]), child_deps) + v1_rt::concat(Rc::new(vec![n_name]), child_deps) } else { child_deps } @@ -2438,7 +2408,7 @@ pub fn node_type_deps( { Rc::new(vec![]) } else { - Rc::new(vec![n_name.clone()]) + Rc::new(vec![n_name]) } } } @@ -2466,7 +2436,7 @@ pub fn method_receiver_element_node( let normed = normalize_access_type_node(receiver_type.clone()); let maybe_element = if node_is_keyed_collection(normed.clone(), source_indices) { match normed.children.clone().get(1 as usize).cloned() { - Some(ch) => Some(child_type_node(ch.clone())), + Some(ch) => Some(child_type_node(ch)), None => None, } } else { @@ -2474,7 +2444,7 @@ pub fn method_receiver_element_node( && ((normed.children.clone().len() as i64) == 1)) { match normed.children.clone().first().cloned() { - Some(ch) => Some(child_type_node(ch.clone())), + Some(ch) => Some(child_type_node(ch)), None => None, } } else { @@ -2482,8 +2452,8 @@ pub fn method_receiver_element_node( } }; match maybe_element { - Some(el) => el.clone(), - None => receiver_type.clone(), + Some(el) => el, + None => receiver_type, } } } @@ -2492,17 +2462,17 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { - with_required_cardinality(n.clone()) + with_required_cardinality(n) } else { if ((n.name.clone() == "Optional".to_string()) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { - Some(inner) => inner.clone(), - None => n.clone(), + Some(inner) => inner, + None => n, } } else { - n.clone() + n } } } @@ -2641,14 +2611,18 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { + Some(m) => match (*(*m.field_node).clone().inferred) + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match rt.inferred.clone().as_deref().cloned() { + match (*rt.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Rc::new(BinOpInferred { - result_type: return_type.clone(), + result_type: return_type, algebra_field: Some(m.field_kind.clone()), }), _ => Rc::new(BinOpInferred { @@ -2658,7 +2632,7 @@ pub fn infer_binop_type_node( } } else { Rc::new(BinOpInferred { - result_type: rt.clone(), + result_type: rt, algebra_field: Some(m.field_kind.clone()), }) } @@ -2693,14 +2667,14 @@ pub fn for_each_element_type_node( && ((normed.children.clone().len() as i64) == 1)); let extracted = if is_single_child { match normed.children.clone().first().cloned() { - Some(ch) => Some(child_type_node(ch.clone())), + Some(ch) => Some(child_type_node(ch)), None => None, } } else { None }; match extracted { - Some(el) => el.clone(), + Some(el) => el, None => { if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) @@ -2709,7 +2683,7 @@ pub fn for_each_element_type_node( { string_type() } else { - normed.clone() + normed } } } diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 8d9415b728c..a2e7bfec996 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -305,7 +305,7 @@ impl ServiceReturnStrategy { pub fn service_self_param(spec: Rc) -> String { match (*spec.service_method.clone()).clone() { - ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp.clone(), + ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp, ServiceMethodStrategy::ExternalReceiver { var_name: _, .. } => "".to_string(), } } @@ -315,7 +315,7 @@ pub fn service_receiver_str(spec: Rc, service_name: String) -> Str ServiceMethodStrategy::SelfInParams { self_param: _, .. } => "".to_string(), ServiceMethodStrategy::ExternalReceiver { var_name: v, .. } => v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat("(".to_string(), v.clone()), " *".to_string()), + v1_rt::concat(v1_rt::concat("(".to_string(), v), " *".to_string()), service_name, ), ") ".to_string(), @@ -345,7 +345,7 @@ pub fn service_return_str(spec: Rc, ret_type: String) -> String { ServiceReturnStrategy::ErrorTupleReturn { error_type: et, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat(v1_rt::concat(" (".to_string(), ret_type), ", ".to_string()), - et.clone(), + et, ), ")".to_string(), ), @@ -1224,18 +1224,18 @@ pub fn language_spec_for_target(target: RenderTarget) -> Rc { pub fn target_keyword(target: RenderTarget, key: String) -> String { match target { RenderTarget::Rust => match v1_rt::lookup(&rust_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), - v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), + v1_rt::Witness::Holds { value: kw, .. } => kw, + v1_rt::Witness::Violates { diagnostic: _, .. } => key, }, RenderTarget::Go => match v1_rt::lookup(&go_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), - v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), + v1_rt::Witness::Holds { value: kw, .. } => kw, + v1_rt::Witness::Violates { diagnostic: _, .. } => key, }, RenderTarget::Python => match v1_rt::lookup(&python_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), - v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), + v1_rt::Witness::Holds { value: kw, .. } => kw, + v1_rt::Witness::Violates { diagnostic: _, .. } => key, }, - RenderTarget::Dag => key.clone(), + RenderTarget::Dag => key, } } @@ -1285,10 +1285,10 @@ pub fn binop_symbol( None => None, }; let result = match specific.clone() { - Some(_) => specific.clone(), + Some(_) => specific, None => Rc::new({ let mut __result = Vec::new(); - for spec in op_matching.clone().iter().cloned() { + for spec in op_matching.iter().cloned() { if (spec.algebra_field.clone() == None) { __result.push(spec); } diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 0da15e2a8e5..823881bcd3d 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -32,7 +32,7 @@ pub fn check_bare_containers( source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let has_structure = ((match n.body.clone() { + let has_structure = ((match (*n.body).clone() { Some(_) => true, None => false, } || ((n.uses.clone().len() as i64) > 0)) @@ -54,8 +54,8 @@ pub fn check_bare_containers( { Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::ArityMismatch { - name: nname.clone(), - expected: expected.clone(), + name: nname, + expected: expected, got: 0, span: n.span.clone(), }), @@ -98,28 +98,22 @@ pub fn check_bare_containers( } __result }); - let type_ann_diags = match n.type_annotation.clone() { - Some(ta) => { - check_bare_containers(ta.clone(), module_name.clone(), source_indices.clone()) - } + let type_ann_diags = match (*n.type_annotation).clone() { + Some(ta) => check_bare_containers(ta, module_name.clone(), source_indices.clone()), None => Rc::new(vec![]), }; - let body_diags = match n.body.clone() { - Some(b) => { - check_bare_containers(b.clone(), module_name.clone(), source_indices.clone()) - } + let body_diags = match (*n.body).clone() { + Some(b) => check_bare_containers(b, module_name.clone(), source_indices.clone()), None => Rc::new(vec![]), }; let inferred_diags = if ((n.params.clone().len() as i64) > 0) { Rc::new(vec![]) } else { - match n.inferred.clone() { - Some(inf) => match (*inf.clone()).clone() { - InferredNode::Resolved { node: rn, .. } => check_bare_containers( - rn.clone(), - module_name.clone(), - source_indices.clone(), - ), + match (*n.inferred).clone() { + Some(inf) => match (*inf).clone() { + InferredNode::Resolved { node: rn, .. } => { + check_bare_containers(rn, module_name.clone(), source_indices.clone()) + } _ => Rc::new(vec![]), }, None => Rc::new(vec![]), @@ -187,14 +181,17 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items(m.module.clone()); + let items = module_items((*m.module).clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { __result.extend( (*check_bare_containers( item.clone(), - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at( + source_indices.clone(), + (*m.module).clone(), + ), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 0c41f844575..5e0e16ca8c2 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -167,7 +167,7 @@ pub fn record_use( span_start: span_start, }); let existing = match v1_rt::map_get(&accum.bindings.clone(), name.clone()) { - Some(usage) => usage.clone(), + Some(usage) => usage, None => Rc::new(BindingUsage { name: name.clone(), binding_kind: None, @@ -193,9 +193,9 @@ pub fn record_use( pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc { if (binding_fan_out(b.clone()) > binding_fan_out(a.clone())) { - b.clone() + b } else { - a.clone() + a } } @@ -208,7 +208,7 @@ pub fn map_usage_merge_at( Some(existing) => v1_rt::rc_map_insert( base.clone(), key.clone(), - max_usage_by_fan_out(existing.clone(), new_val), + max_usage_by_fan_out(existing, new_val), ), None => v1_rt::rc_map_insert(base.clone(), key.clone(), new_val), } @@ -271,13 +271,13 @@ pub fn walk_expr( binding_kind: bk, .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if in_tail.clone() { + if in_tail { record_use( accum, n, EdgeKind::Consumed, "return".to_string(), - bk.clone(), + bk, texpr.span.clone().start.clone(), ) } else { @@ -286,7 +286,7 @@ pub fn walk_expr( n, EdgeKind::Read, "read".to_string(), - bk.clone(), + bk, texpr.span.clone().start.clone(), ) } @@ -298,18 +298,18 @@ pub fn walk_expr( ExprData::ExprVar { binding_kind: bk, .. } => { - let vn = expr_var_name_at(base_node.clone(), si.clone()); + let vn = expr_var_name_at(base_node, si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); record_use( accum, vn, EdgeKind::Projected, v1_rt::concat(".".to_string(), f), - bk.clone(), + bk, texpr.span.clone().start.clone(), ) } - _ => walk_expr(accum, base_node.clone(), false, si.clone()), + _ => walk_expr(accum, base_node, false, si.clone()), } } ExprData::ExprCall { .. } => { @@ -329,7 +329,7 @@ pub fn walk_expr( .cloned(); let threaded_accum = match init_arg { Some(ia) => { - let ia_val = arg_value(ia.clone()); + let ia_val = arg_value(ia); match (*ia_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. @@ -340,11 +340,11 @@ pub fn walk_expr( vn, EdgeKind::Threaded, "fold_init".to_string(), - bk.clone(), + bk, ia_val.span.clone().start.clone(), ) } - _ => walk_expr(accum, ia_val.clone(), false, si.clone()), + _ => walk_expr(accum, ia_val, false, si.clone()), } } None => accum, @@ -359,7 +359,7 @@ pub fn walk_expr( __result }); non_init.iter().cloned().fold( - threaded_accum.clone(), + threaded_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -394,7 +394,7 @@ pub fn walk_expr( .cloned(); let threaded_accum = match init_arg { Some(ia) => { - let ia_val = arg_value(ia.clone()); + let ia_val = arg_value(ia); match (*ia_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. @@ -405,18 +405,18 @@ pub fn walk_expr( vn, EdgeKind::Threaded, "fold_init".to_string(), - bk.clone(), + bk, ia_val.span.clone().start.clone(), ) } - _ => walk_expr(recv_accum, ia_val.clone(), false, si.clone()), + _ => walk_expr(recv_accum, ia_val, false, si.clone()), } } None => recv_accum, }; let non_init = Rc::new({ let mut __result = Vec::new(); - for a in mc_args.clone().iter().cloned() { + for a in mc_args.iter().cloned() { if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } @@ -424,7 +424,7 @@ pub fn walk_expr( __result }); let walked = non_init.iter().cloned().fold( - threaded_accum.clone(), + threaded_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -440,7 +440,7 @@ pub fn walk_expr( } else { { let recv_accum = walk_expr(accum, recv, false, si.clone()); - mc_args.clone().iter().cloned().fold( + mc_args.iter().cloned().fold( recv_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) @@ -465,7 +465,7 @@ pub fn walk_expr( } __result }); - merge_branch_usages(s_accum.clone(), branch_accums) + merge_branch_usages(s_accum, branch_accums) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); @@ -473,16 +473,16 @@ pub fn walk_expr( let c_accum = walk_expr(accum, c, false, si.clone()); let t_accum = walk_expr(c_accum.clone(), t, in_tail.clone(), si.clone()); let e_accum = match if_else_branch(texpr.clone()) { - Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail.clone(), si.clone()), + Some(eb) => walk_expr(c_accum.clone(), eb, in_tail, si.clone()), None => c_accum.clone(), }; - merge_branch_usages(c_accum.clone(), Rc::new(vec![t_accum, e_accum])) + merge_branch_usages(c_accum, Rc::new(vec![t_accum, e_accum])) } ExprData::ExprLet => { let v = let_value(texpr.clone()); let v_accum = walk_expr(accum, v, false, si.clone()); match let_body(texpr.clone()) { - Some(b) => walk_expr(v_accum, b.clone(), in_tail.clone(), si.clone()), + Some(b) => walk_expr(v_accum, b, in_tail, si.clone()), None => v_accum, } } @@ -520,13 +520,10 @@ pub fn walk_expr( walk_expr(acc, p.1.clone(), false, si.clone()) }, ); - match ss.clone().last().cloned() { - Some(last_expr) => walk_expr( - init_accum, - last_expr.clone(), - in_tail.clone(), - si.clone(), - ), + match ss.last().cloned() { + Some(last_expr) => { + walk_expr(init_accum, last_expr, in_tail, si.clone()) + } None => init_accum, } } @@ -579,7 +576,7 @@ pub fn walk_expr( .iter() .cloned() .fold( - coll_accum.clone(), + coll_accum, |acc: Rc, usage: Rc| { let a1 = record_use( acc, @@ -669,7 +666,7 @@ pub fn make_decision(usage: Rc) -> Rc { }); Rc::new(OwnershipDecision::SharedError { binding: usage.name.clone(), - consumer_count: sc.clone(), + consumer_count: sc, sites: sites, }) } @@ -791,7 +788,7 @@ pub fn collect_callable_refs( match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. - } => match bk.clone().as_deref().cloned() { + } => match bk.as_deref().cloned() { Some(VarBindingKind::FunctionValueBinding) => { let n = expr_var_name_at(texpr.clone(), si.clone()); v1_rt::rc_set_insert(v1_rt::rc_empty_set::<_>(), n) @@ -817,7 +814,7 @@ pub fn collect_callable_refs( } => { let recv = collect_callable_refs(method_receiver(texpr.clone()), si.clone()); method_arg_nodes(texpr.clone()).iter().cloned().fold( - recv.clone(), + recv, |acc: Rc>, a: Rc| { v1_rt::rc_set_union( acc, @@ -830,7 +827,7 @@ pub fn collect_callable_refs( let cond = collect_callable_refs(if_condition(texpr.clone()), si.clone()); let then_br = collect_callable_refs(if_then_branch(texpr.clone()), si.clone()); let else_br = match if_else_branch(texpr.clone()) { - Some(eb) => collect_callable_refs(eb.clone(), si.clone()), + Some(eb) => collect_callable_refs(eb, si.clone()), None => v1_rt::rc_empty_set::(), }; v1_rt::rc_set_union(v1_rt::rc_set_union(cond, then_br), else_br) @@ -838,7 +835,7 @@ pub fn collect_callable_refs( ExprData::ExprMatch => { let scrut = collect_callable_refs(match_scrutinee(texpr.clone()), si.clone()); match_arm_nodes(texpr.clone()).iter().cloned().fold( - scrut.clone(), + scrut, |acc: Rc>, arm: Rc| { v1_rt::rc_set_union( acc, @@ -850,9 +847,7 @@ pub fn collect_callable_refs( ExprData::ExprLet => { let val = collect_callable_refs(let_value(texpr.clone()), si.clone()); match let_body(texpr.clone()) { - Some(lb) => { - v1_rt::rc_set_union(val, collect_callable_refs(lb.clone(), si.clone())) - } + Some(lb) => v1_rt::rc_set_union(val, collect_callable_refs(lb, si.clone())), None => val, } } @@ -863,7 +858,7 @@ pub fn collect_callable_refs( }, ), ExprData::ExprReturn => match texpr.children.clone().first().cloned() { - Some(child) => collect_callable_refs(child.clone(), si.clone()), + Some(child) => collect_callable_refs(child, si.clone()), None => v1_rt::rc_empty_set::(), }, ExprData::ExprLambda => collect_callable_refs(lambda_body(texpr.clone()), si.clone()), @@ -949,7 +944,7 @@ pub fn summarize_fold_acc_uses( binding_kind: _, .. } => { if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { - if inside_nested.clone() { + if inside_nested { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -971,11 +966,11 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), + } => (expr_var_name_at(base, si.clone()) == acc_name.clone()), _ => false, }; if is_direct { - if inside_nested.clone() { + if inside_nested { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -1033,7 +1028,7 @@ pub fn summarize_fold_acc_uses( foreach_collection(node.clone()), acc_name.clone(), si.clone(), - inside_nested.clone(), + inside_nested, ); let body_summary = summarize_fold_acc_uses( foreach_body(node.clone()), @@ -1097,7 +1092,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal.clone()) == acc_type_name) + (authored_name_at(si, terminal) == acc_type_name) } _ => false, } @@ -1147,8 +1142,8 @@ pub fn analyze_single_fold( Some(a) => arg_value(a.clone()), None => method_call.clone(), }; - let fold_lambda_node = match args.clone().get(1 as usize).cloned() { - Some(a) => arg_value(a.clone()), + let fold_lambda_node = match args.get(1 as usize).cloned() { + Some(a) => arg_value(a), None => method_call.clone(), }; let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { @@ -1157,19 +1152,19 @@ pub fn analyze_single_fold( .first() .cloned() { - Some(n) => n.clone(), + Some(n) => n, None => "".to_string(), } } _ => "".to_string(), }; - let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { + let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { + let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1185,20 +1180,17 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let cond_safe = fold_body_safe_field_moves( - fold_lambda_node.clone(), - acc_param_name.clone(), - si.clone(), - ); + let cond_safe = + fold_body_safe_field_moves(fold_lambda_node, acc_param_name.clone(), si.clone()); let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), - acc_param_name: acc_param_name.clone(), - acc_type_name: acc_type_name.clone(), - body_constructs_acc: cond_struct.clone(), - whole_acc_single_use: cond_whole_acc.clone(), - safe_field_moves: cond_safe.clone(), + acc_param_name: acc_param_name, + acc_type_name: acc_type_name, + body_constructs_acc: cond_struct, + whole_acc_single_use: cond_whole_acc, + safe_field_moves: cond_safe, eligible: eligible, }) } @@ -1216,7 +1208,7 @@ pub fn analyze_ownership( .iter() .cloned() .fold(empty_usage_accum(), |acc: Rc, p: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:23177:acc"); { let p_name = authored_name_at(si.clone(), p.clone()); Rc::new(UsageAccum { @@ -1290,7 +1282,7 @@ pub fn empty_live_state(name: String) -> Rc { pub fn live_state_of(acc: Rc, name: String) -> Rc { match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st.clone(), + Some(st) => st, None => empty_live_state(name.clone()), } } @@ -1382,7 +1374,7 @@ pub fn merge_branch_licenses(branches: Rc>>) -> Rc(), }), |acc: Rc, br: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:26035:acc"); { let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) .iter() @@ -1443,17 +1435,12 @@ pub fn license_walk( binding_kind: _, .. } => record_field_use_site( acc.clone(), - expr_var_name_at(base_node.clone(), si.clone()), + expr_var_name_at(base_node, si.clone()), field_access_field_at(texpr.clone(), si.clone()), texpr.span.clone().start.clone(), in_capture.clone(), ), - _ => license_walk( - acc.clone(), - base_node.clone(), - in_capture.clone(), - si.clone(), - ), + _ => license_walk(acc.clone(), base_node, in_capture.clone(), si.clone()), } } ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) @@ -1484,9 +1471,7 @@ pub fn license_walk( si.clone(), ); let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => { - license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) - } + Some(eb) => license_walk(acc.clone(), eb, in_capture.clone(), si.clone()), None => acc.clone(), }; let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); @@ -1520,7 +1505,7 @@ pub fn license_walk( } ExprData::ExprLet => { let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), + Some(b) => license_walk(acc.clone(), b, in_capture.clone(), si.clone()), None => acc.clone(), }; license_walk( diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index b2340d2e960..d16159b48d5 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::ParseError; +use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,7 +91,11 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream.all.clone().get(stream.pos.clone() as usize).cloned() + stream + .all + .clone() + .get((stream.pos.clone()) as usize) + .cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -763,7 +767,7 @@ pub fn token_span(tok: Option>) -> Rc { pub fn advance(tokens: Rc) -> Rc { match token_stream_first(tokens.clone()) { Some(t) => Rc::new(AdvanceResult::AdvanceOk { - token: t.clone(), + token: t, tokens: token_stream_advance(tokens.clone(), 1), }), None => Rc::new(AdvanceResult::AdvanceEof), @@ -802,7 +806,7 @@ pub fn parse_string_literal_value(tokens: Rc) -> Rc) -> Rc { let n_opt = v1_rt::parse_int(t.text.clone()); match n_opt { Some(n) => Rc::new(IntLitResult { - value: n.clone(), + value: n, tokens: token_stream_advance(tokens.clone(), 1), err: None, }), @@ -843,7 +847,7 @@ pub fn parse_int_literal_value(tokens: Rc) -> Rc { ), "'".to_string(), ), - token_span(tok.clone()), + token_span(tok), )), }), } @@ -853,7 +857,7 @@ pub fn parse_int_literal_value(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( "expected integer literal".to_string(), - token_span(tok.clone()), + token_span(tok), )), }), }, @@ -1458,10 +1462,9 @@ pub fn token_display_name(token: Rc) -> String { pub fn expected_token_name(expected: Rc) -> String { match (*expected).clone() { - ExpectedToken::ExpectKeyword { text: kw, .. } => v1_rt::concat( - "keyword '".to_string(), - v1_rt::concat(kw.clone(), "'".to_string()), - ), + ExpectedToken::ExpectKeyword { text: kw, .. } => { + v1_rt::concat("keyword '".to_string(), v1_rt::concat(kw, "'".to_string())) + } ExpectedToken::ExpectLBrace => "LBrace".to_string(), ExpectedToken::ExpectRBrace => "RBrace".to_string(), ExpectedToken::ExpectLParen => "LParen".to_string(), @@ -1484,7 +1487,7 @@ pub fn expected_token_name(expected: Rc) -> String { pub fn token_matches_expected(token: Rc, expected: Rc) -> bool { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { - (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw.clone())) + (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw)) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1521,7 +1524,7 @@ pub fn expect(tokens: Rc, expected: Rc) -> Rc token_display_name(t.clone()), + Some(t) => token_display_name(t), None => "EOF".to_string(), }; let wanted = expected_token_name(expected.clone()); @@ -1534,7 +1537,7 @@ pub fn expect(tokens: Rc, expected: Rc) -> Rc) -> Rc { }) } _ => { - let found = match sh.clone() { - Some(shape) => shape_display_name(shape.clone()), + let found = match sh { + Some(shape) => shape_display_name(shape), None => "EOF".to_string(), }; Rc::new(NameResult { @@ -1571,7 +1574,7 @@ pub fn expect_ident(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( v1_rt::concat("expected identifier, found ".to_string(), found), - token_span(tok.clone()), + token_span(tok), )), }) } @@ -1611,7 +1614,7 @@ pub fn expect_name(tokens: Rc) -> Rc { } None => { let found = match tok.clone() { - Some(t) => token_display_name(t.clone()), + Some(t) => token_display_name(t), None => "EOF".to_string(), }; Rc::new(NameResult { @@ -1620,7 +1623,7 @@ pub fn expect_name(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( v1_rt::concat("expected name, found ".to_string(), found), - token_span(tok.clone()), + token_span(tok), )), }) } @@ -1695,7 +1698,7 @@ pub fn eat(tokens: Rc, expected: Rc) -> Rc { if token_matches_expected(t.clone(), expected) { Rc::new(EatResult::EatConsumed { - token: t.clone(), + token: t, tokens: token_stream_advance(tokens.clone(), 1), }) } else { @@ -1719,7 +1722,7 @@ pub fn parser_result_base_var( Some(base) => match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => Some(expr_var_name_at(base.clone(), source_indices)), + } => Some(expr_var_name_at(base, source_indices)), _ => None, }, None => None, @@ -1775,9 +1778,7 @@ pub fn parser_progress_flag_var( match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((field.clone() == "consumed".to_string()) - || (field.clone() == "changed".to_string())) - { + if ((field.clone() == "consumed".to_string()) || (field == "changed".to_string())) { parser_result_base_var(expr.clone(), source_indices.clone()) } else { None @@ -1818,7 +1819,7 @@ pub fn parser_passthrough_state_expr( } Some(ParserHelperIdentity::ParserHelperWith) => { match expr.children.clone().first().cloned() { - Some(base_arg) => Some(arg_value(base_arg.clone())), + Some(base_arg) => Some(arg_value(base_arg)), None => None, } } @@ -1840,14 +1841,10 @@ pub fn parser_result_witness( ref __s if __s == "eat" => Rc::new(ParserResultWitness::ParserWitnessEat), callee => match parser_helper_identity(callee.clone()) { Some(helper) => Rc::new(ParserResultWitness::ParserWitnessCall { - callee: Rc::new(ParserCallIdentity::ParserCallHelper { - helper: helper.clone(), - }), + callee: Rc::new(ParserCallIdentity::ParserCallHelper { helper: helper }), }), None => Rc::new(ParserResultWitness::ParserWitnessCall { - callee: Rc::new(ParserCallIdentity::ParserCallFunction { - name: callee.clone(), - }), + callee: Rc::new(ParserCallIdentity::ParserCallFunction { name: callee }), }), }, }, @@ -1915,7 +1912,7 @@ pub fn parse_type_angle_arg(tokens: Rc, ctx: Rc) -> R Some(t) => Some(t.shape.clone()), None => None, }; - let span = token_span(tok.clone()); + let span = token_span(tok); match sh { Some(TokenShape::ShLitInt) => { let r = parse_int_literal_value(tokens.clone()); @@ -1945,8 +1942,8 @@ pub fn is_conj_with_children(n: Rc) -> bool { } pub fn child_inferred_or_empty(ch: Rc) -> Rc { - match ch.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), + match (*ch.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => error_type(), } } @@ -1960,7 +1957,7 @@ pub fn node_inferred_to_outputs( let all_children_typed = { let mut __all = true; for ch in rt.children.clone().iter().cloned() { - if !(match ch.inferred.clone().as_deref().cloned() { + if !(match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }) { @@ -1978,7 +1975,7 @@ pub fn node_inferred_to_outputs( authored_name_at(source_indices.clone(), ch.clone()), child_inferred_or_empty(ch.clone()), Cardinality::Required, - ch.body.clone(), + (*ch.body).clone(), None, ch.span.clone(), node_name_span(ch.clone()), @@ -2007,7 +2004,7 @@ pub fn parse_dotted_ident(tokens: Rc) -> Rc { { let r = expect_name(tokens); if has_err(r.err.clone()) { - return r.clone(); + return r; } parse_dotted_ident_rest(r.tokens.clone(), r.name.clone(), r.span.clone()) } @@ -2019,11 +2016,11 @@ pub fn parse_dotted_ident_rest( mut span: Rc, ) -> Rc { loop { - match (*eat(tokens, Rc::new(ExpectedToken::ExpectDot))).clone() { + match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectDot))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let r = expect_name(__ec.clone()); if has_err(r.err.clone()) { - return r.clone(); + return r; } let extended = Rc::new(SourceSpan { file: span.file.clone(), @@ -2034,7 +2031,7 @@ pub fn parse_dotted_ident_rest( let __tco_0 = r.tokens.clone(); let __tco_1 = v1_rt::concat(v1_rt::concat(acc, ".".to_string()), r.name.clone()); - let __tco_2 = extended; + let __tco_2 = extended.clone(); tokens = __tco_0; acc = __tco_1; span = __tco_2; @@ -2043,7 +2040,7 @@ pub fn parse_dotted_ident_rest( } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(NameResult { - name: acc, + name: acc.clone(), span: span.clone(), tokens: __eu.clone(), err: None, @@ -2076,7 +2073,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some(r.module.clone()), + module: Some((*r.module).clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2175,8 +2172,8 @@ pub fn parse_module(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let r = parse_import_names(__ec.clone(), ctx.clone()); + let r = parse_import_names(__ec, ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ImportResult { import: err_import.clone(), @@ -2343,21 +2340,16 @@ pub fn parse_import(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); { - let __tco_0 = v1_rt::rc_list_push(acc, name_node); + let __tco_0 = v1_rt::rc_list_push(acc, name_node.clone()); acc = __tco_0; continue; } @@ -2463,7 +2455,7 @@ pub fn find_item_form(forms: Rc>>, keyword: String) -> Option None, - _ => Some(matches.clone().first().cloned().clone().unwrap()), + _ => Some(matches.first().cloned().clone().unwrap()), } } } @@ -2474,10 +2466,10 @@ pub fn parse_item(tokens: Rc, ctx: Rc) -> Rc parse_item_by_form(tokens.clone(), ctx, f.clone()), + Some(f) => parse_item_by_form(tokens.clone(), ctx, f), None => Rc::new(ItemResult { item: Rc::new(Node { name: "".to_string(), @@ -2501,7 +2493,7 @@ pub fn parse_item(tokens: Rc, ctx: Rc) -> Rc false, None => true, }); @@ -2634,7 +2626,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: ret_result.inferred.clone(), + inferred: (*ret_result.inferred).clone(), uses: Rc::new(vec![]), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -2642,11 +2634,11 @@ pub fn parse_item_prefix( }); } Rc::new(ItemPrefixResult { - name: name.clone(), - name_span: name_span.clone(), + name: name, + name_span: name_span, type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: ret_result.inferred.clone(), + inferred: (*ret_result.inferred).clone(), uses: uses_result.uses.clone(), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -2702,58 +2694,56 @@ pub fn parse_item_by_form( let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_type_body_from_prefix(prefix.clone(), start_span.clone()) + parse_type_body_from_prefix(prefix, start_span) } BodyKind::ExprBody => { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_fn_body_from_prefix(prefix.clone(), start_span.clone()) + parse_fn_body_from_prefix(prefix, start_span) } BodyKind::BlockBody => { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_block_body_from_prefix(prefix.clone(), start_span.clone()) + parse_block_body_from_prefix(prefix, start_span) } BodyKind::ServiceBody => { - parse_service_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) + parse_service_after_kw(tokens.clone(), ctx.clone(), start_span) } BodyKind::ResourceBody => { - parse_resource_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) - } - BodyKind::ValueBody => { - parse_data_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) + parse_resource_after_kw(tokens.clone(), ctx.clone(), start_span) } + BodyKind::ValueBody => parse_data_after_kw(tokens.clone(), ctx.clone(), start_span), BodyKind::NoBody => { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_no_body_from_prefix(prefix.clone(), start_span.clone()) + parse_no_body_from_prefix(prefix, start_span) } } } @@ -2770,7 +2760,7 @@ pub fn field_to_child_node( "from_key".to_string(), make_expr_node( Rc::new(ExprData::ExprLiteral { - value: Rc::new(LiteralValue::LitStr { value: key.clone() }), + value: Rc::new(LiteralValue::LitStr { value: key }), }), Rc::new(vec![]), None, @@ -2822,7 +2812,7 @@ pub fn variant_to_child_node( span: variant.span.clone(), ident_span: variant.ident_span.clone(), children: children, - connective: if ((fields.clone().len() as i64) > 0) { + connective: if ((fields.len() as i64) > 0) { Connective::Conj } else { Connective::NoConnective @@ -3015,7 +3005,7 @@ pub fn parse_type_def(tokens: Rc, ctx: Rc) -> Rc { - let r = parse_field_list(skip_newlines(__ec.clone()), ctx.clone()); + let r = parse_field_list(skip_newlines(__ec), ctx.clone()); let named_dummy = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -3102,7 +3092,7 @@ pub fn parse_type_after_kw( let r2 = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBrace)); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy.clone(), + item: named_dummy, tokens: r2.tokens.clone(), ctx: ctx.clone(), err: r2.err.clone(), @@ -3133,12 +3123,12 @@ pub fn parse_type_after_kw( Rc::new(vec![]) }; let item = Rc::new(Node { - name: name.clone(), + name: name, span: start_span.clone(), - ident_span: Some(name_span.clone()), + ident_span: Some(name_span), children: type_children, connective: Connective::Conj, - params: type_params.clone(), + params: type_params, inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3162,14 +3152,14 @@ pub fn parse_type_after_kw( EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectEq))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = skip_newlines(__ec.clone()); + let tokens = skip_newlines(__ec); parse_type_body_after_eq( tokens.clone(), ctx.clone(), - name.clone(), - name_span.clone(), + name, + name_span, start_span.clone(), - type_params.clone(), + type_params, ) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -3179,9 +3169,9 @@ pub fn parse_type_after_kw( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), connective: Connective::NoConnective, - params: type_params.clone(), + params: type_params, inferred: Some(Rc::new(InferredNode::Resolved { - node: leaf_type_node(name.clone(), name_span.clone()), + node: leaf_type_node(name, name_span), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3197,7 +3187,7 @@ pub fn parse_type_after_kw( }); Rc::new(ItemResult { item: item, - tokens: __eu.clone(), + tokens: __eu, ctx: ctx.clone(), err: None, }) @@ -3242,10 +3232,10 @@ pub fn parse_type_body_from_prefix( token_stream_first(raw_tokens.clone()), "sole_constructor".to_string(), ); - let tokens = type_body_tokens_after_modifiers(raw_tokens.clone()); + let tokens = type_body_tokens_after_modifiers(raw_tokens); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBrace))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_field_list(skip_newlines(__ec.clone()), ctx.clone()); + let r = parse_field_list(skip_newlines(__ec), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ItemResult { item: named_dummy.clone(), @@ -3256,10 +3246,10 @@ pub fn parse_type_body_from_prefix( } let tokens = skip_newlines(r.tokens.clone()); let ctx = r.ctx.clone(); - let r2 = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBrace)); + let r2 = expect(tokens, Rc::new(ExpectedToken::ExpectRBrace)); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy.clone(), + item: named_dummy, tokens: r2.tokens.clone(), ctx: ctx.clone(), err: r2.err.clone(), @@ -3290,12 +3280,12 @@ pub fn parse_type_body_from_prefix( Rc::new(vec![]) }; let item = Rc::new(Node { - name: name.clone(), + name: name, span: start_span.clone(), - ident_span: Some(name_span.clone()), + ident_span: Some(name_span), children: type_children, connective: Connective::Conj, - params: type_params.clone(), + params: type_params, inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3312,21 +3302,21 @@ pub fn parse_type_body_from_prefix( Rc::new(ItemResult { item: item, tokens: skip_newlines(r2.tokens.clone()), - ctx: ctx.clone(), + ctx: ctx, err: None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectEq))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = skip_newlines(__ec.clone()); + let tokens = skip_newlines(__ec); parse_type_body_after_eq( - tokens.clone(), - ctx.clone(), - name.clone(), - name_span.clone(), + tokens, + ctx, + name, + name_span, start_span.clone(), - type_params.clone(), + type_params, ) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -3336,9 +3326,9 @@ pub fn parse_type_body_from_prefix( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), connective: Connective::NoConnective, - params: type_params.clone(), + params: type_params, inferred: Some(Rc::new(InferredNode::Resolved { - node: leaf_type_node(name.clone(), name_span.clone()), + node: leaf_type_node(name, name_span), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3354,8 +3344,8 @@ pub fn parse_type_body_from_prefix( }); Rc::new(ItemResult { item: item, - tokens: __eu.clone(), - ctx: ctx.clone(), + tokens: __eu, + ctx: ctx, err: None, }) } @@ -3396,7 +3386,7 @@ pub fn parse_type_body_after_eq( }); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectPipe))).clone() { EatResult::EatConsumed { tokens: __lead, .. } => { - let tokens = skip_newlines(__lead.clone()); + let tokens = skip_newlines(__lead); let rid = expect_ident(tokens.clone()); if has_err(rid.err.clone()) { return Rc::new(ItemResult { @@ -3422,11 +3412,11 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![rv.variant.clone()]), + Rc::new(vec![(*rv.variant).clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: rest.tokens.clone(), ctx: rest.ctx.clone(), err: rest.err.clone(), @@ -3500,7 +3490,7 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = r.variant.clone(); + let first_variant = (*r.variant).clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), @@ -3508,7 +3498,7 @@ pub fn parse_type_body_after_eq( ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: rest.tokens.clone(), ctx: rest.ctx.clone(), err: rest.err.clone(), @@ -3571,12 +3561,12 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: wr.tokens.clone(), ctx: wr.ctx.clone(), err: wr.err.clone(), @@ -3590,7 +3580,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3627,12 +3617,12 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { return Rc::new(ItemResult { - item: dummy.clone(), + item: dummy, tokens: wr.tokens.clone(), ctx: wr.ctx.clone(), err: wr.err.clone(), @@ -3646,7 +3636,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3682,7 +3672,7 @@ pub fn try_where_clause( if tok_is_keyword(token_stream_first(tokens.clone()), "where".to_string()) { match (*advance(tokens.clone())).clone() { AdvanceResult::AdvanceOk { tokens: rest, .. } => { - let r = parse_predicates(rest.clone(), ctx); + let r = parse_predicates(rest, ctx); if has_err(r.err.clone()) { return Rc::new(TypeResult { type_expr: base_te.clone(), @@ -3765,7 +3755,7 @@ pub fn parse_predicates_acc( mut acc: Rc>>, ) -> Rc { loop { - let r = parse_single_predicate(tokens, ctx); + let r = parse_single_predicate(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(PredsResult { predicates: Rc::new(vec![]), @@ -3774,7 +3764,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -3824,7 +3814,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let tokens = r.tokens.clone(); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLParen))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = __ec.clone(); + let tokens = __ec; match pred_name.clone().as_str() { "pattern" => { let r2 = parse_string_literal_value(tokens.clone()); @@ -3839,7 +3829,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3859,7 +3849,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3879,7 +3869,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3899,7 +3889,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3919,7 +3909,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3939,7 +3929,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3959,7 +3949,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3979,7 +3969,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3999,7 +3989,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -4019,7 +4009,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -4039,7 +4029,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -4093,7 +4083,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), @@ -4101,15 +4091,12 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }) } _ => Rc::new(PredResult { - predicate: dummy_pred.clone(), + predicate: dummy_pred, tokens: tokens.clone(), ctx: ctx.clone(), err: Some(parse_error( v1_rt::concat( - v1_rt::concat( - "unknown where predicate `".to_string(), - pred_name.clone(), - ), + v1_rt::concat("unknown where predicate `".to_string(), pred_name), "`".to_string(), ), token_span(token_stream_first(tokens.clone())), @@ -4130,7 +4117,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: tokens.clone(), ctx: ctx.clone(), @@ -4138,7 +4125,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), _ => Rc::new(PredResult { predicate: make_field_init_node( - pred_name.clone(), + pred_name, make_expr_node( Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitBool { value: true }), @@ -4148,7 +4135,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span.clone(), + zero_span, ), tokens: tokens.clone(), ctx: ctx.clone(), @@ -4173,7 +4160,7 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R } match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r2 = parse_single_named_int(skip_newlines(__ec.clone()), r.ctx.clone()); + let r2 = parse_single_named_int(skip_newlines(__ec), r.ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(RangeArgsResult { min_val: None, @@ -4269,7 +4256,7 @@ pub fn parse_single_named_int( }); } Rc::new(NamedIntResult { - arg_name: name.clone(), + arg_name: name, arg_value: r3.value.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -4295,19 +4282,19 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), Cardinality::Required, None, None, - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { token: comma_tok, tokens: __ec, .. } => Rc::new(FieldsResult { fields: Rc::new(vec![]), - tokens: __ec.clone(), + tokens: __ec, ctx: r.ctx.clone(), - err: Some(parse_error("positional variant payload accepts a single type only (comma-separated fields not supported yet)".to_string(), token_span(Some(comma_tok.clone())))), + err: Some(parse_error("positional variant payload accepts a single type only (comma-separated fields not supported yet)".to_string(), token_span(Some(comma_tok)))), }), EatResult::EatUnchanged { tokens: __eu, .. } => Rc::new(FieldsResult { fields: Rc::new(vec![field]), @@ -4329,7 +4316,7 @@ pub fn parse_variant_fields( let start_span = token_span(token_stream_first(tokens.clone())); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBrace))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_field_list(skip_newlines(__ec.clone()), ctx); + let r = parse_field_list(skip_newlines(__ec), ctx); if has_err(r.err.clone()) { return Rc::new(VariantResult { variant: make_variant_node( @@ -4361,7 +4348,7 @@ pub fn parse_variant_fields( let v = make_variant_node( vname.clone(), r.fields.clone(), - start_span.clone(), + start_span, vname_span.clone(), ); Rc::new(VariantResult { @@ -4374,7 +4361,7 @@ pub fn parse_variant_fields( EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLParen))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_positional_variant_type_fields(__ec.clone(), ctx); + let r = parse_positional_variant_type_fields(__ec, ctx); if has_err(r.err.clone()) { return Rc::new(VariantResult { variant: make_variant_node( @@ -4405,7 +4392,7 @@ pub fn parse_variant_fields( let v = make_variant_node( vname.clone(), r.fields.clone(), - start_span.clone(), + start_span, vname_span.clone(), ); Rc::new(VariantResult { @@ -4475,7 +4462,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4484,7 +4471,7 @@ pub fn parse_more_variants_acc( } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(VariantsResult { - variants: acc, + variants: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -4529,7 +4516,7 @@ pub fn parse_type_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(TypeResult { type_expr: leaf_type_node("".to_string(), span.clone()), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error( - "expected type expression".to_string(), - span.clone(), - )), + err: Some(parse_error("expected type expression".to_string(), span)), }), } } @@ -4659,7 +4640,7 @@ pub fn parse_callable_type_expr( let ret = parse_type_expr(r3.tokens.clone(), params_result.ctx.clone()); if has_err(ret.err.clone()) { return Rc::new(TypeResult { - type_expr: dummy_te.clone(), + type_expr: dummy_te, tokens: ret.tokens.clone(), ctx: ret.ctx.clone(), err: ret.err.clone(), @@ -4673,7 +4654,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: ret.type_expr.clone(), + node: (*ret.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4697,7 +4678,7 @@ pub fn parse_callable_param_types( mut acc: Rc>>, ) -> Rc { loop { - let r = parse_type_expr(tokens.clone(), ctx); + let r = parse_type_expr(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ParamsResult { params: Rc::new(vec![]), @@ -4708,12 +4689,12 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), None, - r.type_expr.clone().span.clone(), - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), + (*r.type_expr).clone().span.clone(), ); - acc = v1_rt::rc_list_push(acc.clone(), param); + acc = v1_rt::rc_list_push(acc.clone(), param.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -4754,11 +4735,11 @@ pub fn finish_type_expr_from_name( let dummy_te = leaf_type_node(type_name.clone(), start_span.clone()); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLt))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_angle_arg(__ec.clone(), ctx); + let r = parse_type_angle_arg(__ec, ctx); if has_err(r.err.clone()) { - return r.clone(); + return r; } - let first_arg = r.type_expr.clone(); + let first_arg = (*r.type_expr).clone(); let type_args = collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { @@ -4772,7 +4753,7 @@ pub fn finish_type_expr_from_name( let r3 = expect(type_args.tokens.clone(), Rc::new(ExpectedToken::ExpectGt)); if has_err(r3.err.clone()) { return Rc::new(TypeResult { - type_expr: dummy_te.clone(), + type_expr: dummy_te, tokens: r3.tokens.clone(), ctx: type_args.ctx.clone(), err: r3.err.clone(), @@ -4826,7 +4807,7 @@ pub fn parse_optional_type_params( ) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLt))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let params_result = collect_type_param_names(__ec.clone(), ctx, Rc::new(vec![])); + let params_result = collect_type_param_names(__ec, ctx, Rc::new(vec![])); let r = expect( params_result.tokens.clone(), Rc::new(ExpectedToken::ExpectGt), @@ -4861,28 +4842,28 @@ pub fn collect_type_param_names( span.clone(), span.clone(), ); - let next_params = v1_rt::rc_list_push(params, param); + let next_params = v1_rt::rc_list_push(params.clone(), param.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); - let __tco_1 = next_params; + let __tco_1 = next_params.clone(); tokens = __tco_0; params = __tco_1; continue; } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(TypeParamsResult { - params: next_params, + params: next_params.clone(), tokens: r.tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), }); } } } else { break Rc::new(TypeParamsResult { - params: params, + params: params.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), }); } } @@ -4904,7 +4885,7 @@ pub fn collect_type_args( loop { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_angle_arg(__ec.clone(), ctx); + let r = parse_type_angle_arg(__ec.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(TypeArgsResult { args: args.clone(), @@ -4916,7 +4897,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); + let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -4927,7 +4908,7 @@ pub fn collect_type_args( break Rc::new(TypeArgsResult { args: args.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } @@ -4950,22 +4931,22 @@ pub fn maybe_optional( children: te.children.clone(), connective: te.connective.clone(), params: te.params.clone(), - inferred: te.inferred.clone(), + inferred: (*te.inferred).clone(), return_cardinality: Cardinality::CardOptional, uses: te.uses.clone(), - body: te.body.clone(), - transport: te.transport.clone(), + body: (*te.body).clone(), + transport: (*te.transport).clone(), properties: te.properties.clone(), - type_annotation: te.type_annotation.clone(), + type_annotation: (*te.type_annotation).clone(), is_self_recursive: te.is_self_recursive.clone(), has_non_tail_self_call: te.has_non_tail_self_call.clone(), - match_pattern: te.match_pattern.clone(), + match_pattern: (*te.match_pattern).clone(), expr_data: te.expr_data.clone(), ident: None, }); Rc::new(TypeResult { type_expr: ote, - tokens: __ec.clone(), + tokens: __ec, ctx: ctx, err: None, }) @@ -4993,14 +4974,14 @@ pub fn parse_field_list_acc( let tok = token_stream_first(tokens.clone()); if ((tok_is_rbrace(tok.clone()) || tok_is_rparen(tok.clone())) || tok_is_eof(tok.clone())) { break Rc::new(FieldsResult { - fields: acc, + fields: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } else { if (tok_is_ident(tok.clone()) || tok_is_keyword_name(tok.clone())) { - let r = parse_field(tokens.clone(), ctx); + let r = parse_field(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(FieldsResult { fields: Rc::new(vec![]), @@ -5011,22 +4992,22 @@ pub fn parse_field_list_acc( } tokens = r.tokens.clone(); let e = eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); ctx = __tco_0; acc = __tco_1; continue; } } else { break Rc::new(FieldsResult { - fields: acc, + fields: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } @@ -5079,7 +5060,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let r4 = parse_expr(__ec.clone(), ctx.clone()); + let r4 = parse_expr(__ec, ctx.clone()); if has_err(r4.err.clone()) { return Rc::new(FieldResult { - field: dummy_field.clone(), + field: dummy_field, tokens: r4.tokens.clone(), ctx: r4.ctx.clone(), err: r4.err.clone(), @@ -5112,9 +5093,9 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc>>, ) -> Rc { loop { - let r = parse_uses_entry(tokens, ctx); + let r = parse_uses_entry(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(UsesResult { uses: Rc::new(vec![]), @@ -5852,7 +5833,7 @@ pub fn parse_uses_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.resource_use.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.resource_use).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); @@ -5913,7 +5894,7 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc { - let ar = parse_resource_config_args(__ec.clone(), r3.ctx.clone()); + let ar = parse_resource_config_args(__ec, r3.ctx.clone()); if has_err(ar.err.clone()) { return Rc::new(ResUseResult { resource_use: dummy.clone(), @@ -5925,33 +5906,33 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - r3.type_expr.clone(), - start_span.clone(), + (*r3.type_expr).clone(), + start_span, r.span.clone(), ); Rc::new(ResUseResult { @@ -6035,8 +6016,13 @@ pub fn parse_resource_config_acc( err: r3.err.clone(), }); } - let fi = make_field_init_node(field_name, r3.expr.clone(), zero_span, r.span.clone()); - acc = v1_rt::rc_list_push(acc.clone(), fi); + let fi = make_field_init_node( + field_name.clone(), + (*r3.expr).clone(), + zero_span.clone(), + r.span.clone(), + ); + acc = v1_rt::rc_list_push(acc.clone(), fi.clone()); match (*eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -6060,7 +6046,7 @@ pub fn parse_resource_config_acc( pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectArrow))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_expr(__ec.clone(), ctx); + let r = parse_type_expr(__ec, ctx); if has_err(r.err.clone()) { return Rc::new(OptRetResult { inferred: None, @@ -6071,7 +6057,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: r.type_expr.clone(), + node: (*r.type_expr).clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6124,7 +6110,7 @@ pub fn parse_service_def(tokens: Rc, ctx: Rc) -> Rc service_config_properties( - cfg.endpoint.clone(), - cfg.auth.clone(), - cfg.auth_input.clone(), - cfg.auth_source.clone(), - cfg.rate_limit.clone(), - cfg.retry.clone(), + (*cfg.endpoint).clone(), + (*cfg.auth).clone(), + (*cfg.auth_input).clone(), + (*cfg.auth_source).clone(), + (*cfg.rate_limit).clone(), + (*cfg.retry).clone(), ), None => Rc::new(vec![]), }; let item = Rc::new(Node { - name: name.clone(), + name: name, span: start_span.clone(), - ident_span: Some(svc_name_span.clone()), + ident_span: Some(svc_name_span), children: r.operations.clone(), params: Rc::new(vec![]), inferred: None, @@ -6257,7 +6243,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some(r.transport.clone()), + transport: Some((*r.transport).clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6310,7 +6296,7 @@ pub fn parse_service_entries( None => None, }; let span = token_span(tok.clone()); - match sh { + match sh.clone() { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); if (id.clone() == "config".to_string()) { @@ -6382,7 +6368,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.transport.clone(); + let __tco_2 = (*r.transport).clone(); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -6398,7 +6384,7 @@ pub fn parse_service_entries( err: Some(parse_error( "expected config, transport, or operation in service block" .to_string(), - span, + span.clone(), )), }); } @@ -6406,7 +6392,7 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text == "operation".to_string()) { + if (kw_text.clone() == "operation".to_string()) { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6421,7 +6407,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); + let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6437,7 +6423,7 @@ pub fn parse_service_entries( err: Some(parse_error( "expected config, transport, or operation in service block" .to_string(), - span, + span.clone(), )), }); } @@ -6451,7 +6437,7 @@ pub fn parse_service_entries( ctx: ctx.clone(), err: Some(parse_error( "expected config, transport, or operation in service block".to_string(), - span, + span.clone(), )), }); } @@ -6483,7 +6469,7 @@ pub fn parse_config_fields( || tok_is_eof(token_stream_first(tokens.clone()))) { let cfg = Rc::new(ServiceConfig { - endpoint: match endpoint { + endpoint: match endpoint.clone() { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -6496,14 +6482,14 @@ pub fn parse_config_fields( make_span(0, 0), ), }, - auth: auth, - auth_input: auth_input, - auth_source: auth_source, - rate_limit: rate_limit, - retry: retry, + auth: auth.clone(), + auth_input: auth_input.clone(), + auth_source: auth_source.clone(), + rate_limit: rate_limit.clone(), + retry: retry.clone(), }); break Rc::new(ConfigResult { - config: cfg, + config: cfg.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6561,34 +6547,34 @@ pub fn parse_config_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }; - match fname.as_str() { + match fname.clone().as_str() { "endpoint" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); retry = __tco_0; continue; } @@ -6612,7 +6598,7 @@ pub fn parse_transport_binding( Some(t) => t.text.clone(), None => "".to_string(), }; - let sh = match tok.clone() { + let sh = match tok { Some(t) => Some(t.shape.clone()), None => None, }; @@ -6636,7 +6622,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6648,14 +6634,14 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy.clone(), + transport: dummy, tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6682,7 +6668,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6694,21 +6680,21 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy.clone(), + transport: dummy, tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, }) } } else { - if (tok_text.clone() == "file".to_string()) { + if (tok_text == "file".to_string()) { { let r = expect( token_stream_advance(tokens.clone(), 1), @@ -6728,7 +6714,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6740,14 +6726,14 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy.clone(), + transport: dummy, tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6755,7 +6741,7 @@ pub fn parse_transport_binding( } } else { Rc::new(TransportResult { - transport: dummy.clone(), + transport: dummy, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6765,7 +6751,7 @@ pub fn parse_transport_binding( } } _ => Rc::new(TransportResult { - transport: dummy.clone(), + transport: dummy, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6809,7 +6795,7 @@ pub fn parse_rest_fields( if (tok_is_rbrace(token_stream_first(tokens.clone())) || tok_is_eof(token_stream_first(tokens.clone()))) { - let bu = match base_url { + let bu = match base_url.clone() { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -6824,14 +6810,14 @@ pub fn parse_rest_fields( }; break Rc::new(TransportResult { transport: rest_transport_node( - bu, + bu.clone(), Rc::new(vec![]), - headers, - method, - path_template, - query, - request_body, - response_format, + headers.clone(), + method.clone(), + path_template.clone(), + query.clone(), + request_body.clone(), + response_format.clone(), span.clone(), ), tokens: tokens.clone(), @@ -6875,49 +6861,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*r3.expr.clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), + let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -6929,7 +6915,7 @@ pub fn parse_rest_fields( }), }; { - let __tco_0 = h; + let __tco_0 = h.clone(); headers = __tco_0; continue; } @@ -6969,7 +6955,12 @@ pub fn parse_shell_fields( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(TransportResult { - transport: shell_transport_node(argv, Rc::new(vec![]), stdin, span.clone()), + transport: shell_transport_node( + argv.clone(), + Rc::new(vec![]), + stdin.clone(), + span.clone(), + ), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -7027,7 +7018,7 @@ pub fn parse_shell_fields( }); } let e = eat(r5.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e).clone() { + tokens = match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r5.tokens.clone(), }; @@ -7050,13 +7041,13 @@ pub fn parse_shell_fields( }); } let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e).clone() { + tokens = match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7072,7 +7063,7 @@ pub fn parse_shell_fields( }); } let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e).clone() { + tokens = match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; @@ -7106,7 +7097,7 @@ pub fn parse_file_fields( if (tok_is_rbrace(token_stream_first(tokens.clone())) || tok_is_eof(token_stream_first(tokens.clone()))) { - let bp = match base_path { + let bp = match base_path.clone() { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -7120,7 +7111,7 @@ pub fn parse_file_fields( ), }; break Rc::new(TransportResult { - transport: file_transport_node(bp, span.clone()), + transport: file_transport_node(bp.clone(), span.clone()), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -7162,7 +7153,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7211,7 +7202,7 @@ pub fn parse_operation_def(tokens: Rc, ctx: Rc) -> Rc let r = expect_ident(r.tokens.clone()); if has_err(r.err.clone()) { return Rc::new(OpResult { - operation: dummy_op.clone(), + operation: dummy_op, tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -7221,21 +7212,9 @@ pub fn parse_operation_def(tokens: Rc, ctx: Rc) -> Rc let name_span = r.span.clone(); let tokens = skip_newlines(r.tokens.clone()); if tok_is_lbrace(token_stream_first(tokens.clone())) { - parse_operation_v1_body( - tokens.clone(), - ctx.clone(), - name, - name_span, - start_span.clone(), - ) + parse_operation_v1_body(tokens.clone(), ctx.clone(), name, name_span, start_span) } else { - parse_operation_v2_inline( - tokens.clone(), - ctx.clone(), - name, - name_span, - start_span.clone(), - ) + parse_operation_v2_inline(tokens.clone(), ctx.clone(), name, name_span, start_span) } } } @@ -7309,9 +7288,9 @@ pub fn parse_operation_v2_inline( } let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); - let outputs = match ret.inferred.clone().as_deref().cloned() { + let outputs = match (*ret.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - node_inferred_to_outputs(rt.clone(), ctx.source_indices.clone()) + node_inferred_to_outputs(rt, ctx.source_indices.clone()) } _ => Rc::new(vec![]), }; @@ -7330,7 +7309,7 @@ pub fn parse_operation_v2_inline( let mock_r = parse_optional_mock_response_block(tokens.clone(), ctx.clone()); if has_err(mock_r.err.clone()) { return Rc::new(OpResult { - operation: dummy_op.clone(), + operation: dummy_op, tokens: mock_r.tokens.clone(), ctx: mock_r.ctx.clone(), err: mock_r.err.clone(), @@ -7416,7 +7395,7 @@ pub fn parse_operation_v1_body( ); if has_err(r3.err.clone()) { return Rc::new(OpResult { - operation: dummy_op.clone(), + operation: dummy_op, tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -7431,7 +7410,7 @@ pub fn parse_operation_v1_body( r2.mock_props.clone(), r2.exit_props.clone(), r2.modifier_props.clone(), - r2.transport.clone(), + (*r2.transport).clone(), start_span.clone(), ctx.source_indices.clone(), ); @@ -7478,7 +7457,7 @@ pub fn parse_op_body_entries( Some(t) => Some(t.shape.clone()), None => None, }; - match sh { + match sh.clone() { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); if (kw_text.clone() == "input".to_string()) { @@ -7606,30 +7585,34 @@ pub fn parse_op_body_entries( } } else { if (kw_text.clone() == "idempotent".to_string()) { - let prop = modifier_to_prop("idempotent".to_string(), span); + let prop = modifier_to_prop("idempotent".to_string(), span.clone()); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); + let __tco_1 = v1_rt::rc_list_push(modifier_props, prop.clone()); tokens = __tco_0; modifier_props = __tco_1; continue; } } else { if (kw_text.clone() == "readonly".to_string()) { - let prop = modifier_to_prop("readonly".to_string(), span); + let prop = + modifier_to_prop("readonly".to_string(), span.clone()); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); + let __tco_1 = + v1_rt::rc_list_push(modifier_props, prop.clone()); tokens = __tco_0; modifier_props = __tco_1; continue; } } else { if (kw_text.clone() == "hermetic".to_string()) { - let prop = modifier_to_prop("hermetic".to_string(), span); + let prop = + modifier_to_prop("hermetic".to_string(), span.clone()); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); + let __tco_1 = + v1_rt::rc_list_push(modifier_props, prop.clone()); tokens = __tco_0; modifier_props = __tco_1; continue; @@ -7666,7 +7649,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some(r.transport.clone()); + let __tco_2 = Some((*r.transport).clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -7863,7 +7846,7 @@ pub fn parse_op_body_entries( "unexpected '{}' in operation body", id.clone() ), - span, + span.clone(), )), }); } @@ -7885,7 +7868,7 @@ pub fn parse_op_body_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected token in operation body".to_string(), - span, + span.clone(), )), }); } @@ -7938,9 +7921,9 @@ pub fn status_expr_to_str( source_indices: Rc>>, ) -> String { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { - LiteralValue::LitInt { value: n, .. } => int_to_string(n.clone()), - LiteralValue::LitStr { value: s, .. } => s.clone(), + ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + LiteralValue::LitInt { value: n, .. } => int_to_string(n), + LiteralValue::LitStr { value: s, .. } => s, _ => "_".to_string(), }, ExprData::ExprVar { @@ -7984,6 +7967,7 @@ pub fn int_to_string_acc(mut value: i64, mut acc: Rc>) -> Rc>) -> Rc>) -> Rc) -> Rc { match n.children.clone().first().cloned() { - Some(ch) => ch.clone(), - None => n.clone(), + Some(ch) => ch, + None => n, } } pub fn last_child_or_self(n: Rc) -> Rc { match n.children.clone().last().cloned() { - Some(ch) => ch.clone(), - None => n.clone(), + Some(ch) => ch, + None => n, } } @@ -8041,7 +8025,7 @@ pub fn node_to_name_str( } else { n.clone() }; - let opt_prefix = if is_optional.clone() { + let opt_prefix = if is_optional { "Optional_".to_string() } else { "".to_string() @@ -8052,31 +8036,27 @@ pub fn node_to_name_str( if is_keyed_container { match effective_n.children.clone().last().cloned() { Some(ch) => v1_rt::concat( - v1_rt::concat( - v1_rt::concat(opt_prefix, effective_name.clone()), - "_".to_string(), - ), - node_to_name_str(ch.clone(), source_indices.clone()), + v1_rt::concat(v1_rt::concat(opt_prefix, effective_name), "_".to_string()), + node_to_name_str(ch, source_indices.clone()), ), - None => v1_rt::concat(opt_prefix, effective_name.clone()), + None => v1_rt::concat(opt_prefix, effective_name), } } else { - if (effective_n.type_annotation.clone() != None) { + if ((*effective_n.type_annotation).clone() != None) { match effective_n.children.clone().first().cloned() { - Some(ch) => v1_rt::concat( - opt_prefix, - node_to_name_str(ch.clone(), source_indices.clone()), - ), - None => v1_rt::concat(opt_prefix, effective_name.clone()), + Some(ch) => { + v1_rt::concat(opt_prefix, node_to_name_str(ch, source_indices.clone())) + } + None => v1_rt::concat(opt_prefix, effective_name), } } else { if is_container_type(effective_name.clone()) { match effective_n.children.clone().first().cloned() { Some(ch) => v1_rt::concat( v1_rt::concat(opt_prefix, "List_".to_string()), - node_to_name_str(ch.clone(), source_indices.clone()), + node_to_name_str(ch, source_indices.clone()), ), - None => v1_rt::concat(opt_prefix, effective_name.clone()), + None => v1_rt::concat(opt_prefix, effective_name), } } else { if (effective_n.ident_span.clone() == None) { @@ -8089,12 +8069,12 @@ pub fn node_to_name_str( if is_disj { v1_rt::concat(opt_prefix, "Union".to_string()) } else { - v1_rt::concat(opt_prefix, effective_name.clone()) + v1_rt::concat(opt_prefix, effective_name) } } } } else { - v1_rt::concat(opt_prefix, effective_name.clone()) + v1_rt::concat(opt_prefix, effective_name) } } } @@ -8117,7 +8097,7 @@ pub fn parse_exit_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(ExitEntriesResult { - entries: acc, + entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8132,7 +8112,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = r.expr.clone(); + let code = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8152,38 +8132,38 @@ pub fn parse_exit_entries_acc( }); } let desc_tok = token_stream_first(r3.tokens.clone()); - let desc_sh = match desc_tok { + let desc_sh = match desc_tok.clone() { Some(t) => Some(t.shape.clone()), None => None, }; - let desc_tokens = match desc_sh { + let desc_tokens = match desc_sh.clone() { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(code, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); - let prop_name = v1_rt::concat("exit_".to_string(), code_str); + let code_str = status_expr_to_str(code.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let prop_name = v1_rt::concat("exit_".to_string(), code_str.clone()); let entry = make_field_init_node( - prop_name, + prop_name.clone(), make_named_expr_node( - type_name, + type_name.clone(), Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => desc_tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry); + let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -8231,9 +8211,9 @@ pub fn parse_operation_modifiers_acc( } } else { break Rc::new(ModsResult { - modifiers: acc, + modifiers: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } @@ -8254,7 +8234,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R Some(TokenShape::ShLitInt) => { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v.clone(), + Some(v) => v, None => { return Rc::new(ExprResult { expr: make_expr_error_node( @@ -8289,7 +8269,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 2), ctx: ctx.clone(), @@ -8303,7 +8283,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8318,7 +8298,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8335,7 +8315,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8351,7 +8331,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8444,7 +8424,7 @@ pub fn parse_response_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(RespEntriesResult { - entries: acc, + entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8459,7 +8439,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8478,30 +8458,30 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); - let prop_name = v1_rt::concat("response_".to_string(), status_str); + let status_str = status_expr_to_str(status.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let prop_name = v1_rt::concat("response_".to_string(), status_str.clone()); let entry = make_field_init_node( - prop_name, + prop_name.clone(), make_named_expr_node( - type_name, + type_name.clone(), Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry); + let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -8593,7 +8573,7 @@ pub fn parse_mock_response_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(MockEntriesResult { - entries: acc, + entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8608,7 +8588,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8627,27 +8607,32 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = r3.expr.clone(); + let body = (*r3.expr).clone(); let desc_tok = token_stream_first(r3.tokens.clone()); - let desc_sh = match desc_tok { + let desc_sh = match desc_tok.clone() { Some(t) => Some(t.shape.clone()), None => None, }; - let desc_tokens = match desc_sh { + let desc_tokens = match desc_sh.clone() { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let prop_name = v1_rt::concat("mock_".to_string(), status_str); - let entry = make_field_init_node(prop_name, body, make_span(0, 0), make_span(0, 0)); + let status_str = status_expr_to_str(status.clone(), ctx.source_indices.clone()); + let prop_name = v1_rt::concat("mock_".to_string(), status_str.clone()); + let entry = make_field_init_node( + prop_name.clone(), + body.clone(), + make_span(0, 0), + make_span(0, 0), + ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => desc_tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry); + let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -8693,7 +8678,7 @@ pub fn parse_resource_def(tokens: Rc, ctx: Rc) -> Rc< err: r.err.clone(), }); } - parse_resource_after_kw(r.tokens.clone(), ctx.clone(), start_span.clone()) + parse_resource_after_kw(r.tokens.clone(), ctx.clone(), start_span) } } @@ -8783,16 +8768,16 @@ pub fn parse_resource_after_kw( ); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy.clone(), + item: named_dummy, tokens: r2.tokens.clone(), ctx: r.ctx.clone(), err: r2.err.clone(), }); } let item = Rc::new(Node { - name: name.clone(), + name: name, span: start_span.clone(), - ident_span: Some(name_span.clone()), + ident_span: Some(name_span), children: r.capabilities.clone(), params: Rc::new(vec![]), inferred: None, @@ -8841,7 +8826,7 @@ pub fn parse_resource_entries( Some(t) => Some(t.shape.clone()), None => None, }; - match sh { + match sh.clone() { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); if (kw_text.clone() == "capability".to_string()) { @@ -8858,7 +8843,8 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); + let __tco_2 = + v1_rt::rc_list_push(capabilities, (*r.capability).clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8936,7 +8922,7 @@ pub fn parse_resource_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected keyword in resource block".to_string(), - span, + span.clone(), )), }); } @@ -8977,15 +8963,15 @@ pub fn parse_resource_entries( }); } let fi = make_field_init_node( - fname, - r3.expr.clone(), + fname.clone(), + (*r3.expr).clone(), make_span(0, 0), r.span.clone(), ); { let __tco_0 = skip_newlines(r3.tokens.clone()); let __tco_1 = r3.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(properties, fi); + let __tco_2 = v1_rt::rc_list_push(properties, fi.clone()); tokens = __tco_0; ctx = __tco_1; properties = __tco_2; @@ -8999,7 +8985,7 @@ pub fn parse_resource_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected token in resource block".to_string(), - span, + span.clone(), )), }); } @@ -9013,7 +8999,7 @@ pub fn parse_resource_entries( err: Some(parse_error( "expected capability, acquire, release, or property in resource block" .to_string(), - span, + span.clone(), )), }); } @@ -9033,7 +9019,7 @@ pub fn skip_until_rbrace(tokens: Rc) -> Rc { }) } else { { - let sh = match tok.clone() { + let sh = match tok { Some(t) => Some(t.shape.clone()), None => None, }; @@ -9119,7 +9105,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc node_inferred_to_outputs( - rt.clone(), - ret.ctx.clone().source_indices.clone(), - ), + let outputs = match (*ret.inferred).clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => { + node_inferred_to_outputs(rt, ret.ctx.clone().source_indices.clone()) + } _ => Rc::new(vec![]), }; let cap = make_capability_node( @@ -9195,7 +9180,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc>>, ) -> Rc { loop { - let r = parse_param(tokens.clone(), ctx); + let r = parse_param(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ParamsResult { params: Rc::new(vec![]), @@ -9587,7 +9572,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9660,7 +9645,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let r4 = parse_expr(__ec.clone(), ctx.clone()); + let r4 = parse_expr(__ec, ctx.clone()); if has_err(r4.err.clone()) { return Rc::new(ParamResult { - param: dummy_param.clone(), + param: dummy_param, tokens: r4.tokens.clone(), ctx: r4.ctx.clone(), err: r4.err.clone(), @@ -9688,8 +9673,8 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, type_expr, None, start_span.clone(), name_span); + let p = make_param_node(name, type_expr, None, start_span, name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -9740,7 +9725,7 @@ pub fn parse_block(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let kw_text = tok_keyword_text(tok.clone()); + let kw_text = tok_keyword_text(tok); if (kw_text.clone() == "let".to_string()) { parse_let(tokens.clone(), ctx) } else { - if (kw_text.clone() == "return".to_string()) { + if (kw_text == "return".to_string()) { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -9924,7 +9904,7 @@ pub fn parse_constrained_assignment( let r2 = expect(cr.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: r2.tokens.clone(), ctx: cr.ctx.clone(), err: r2.err.clone(), @@ -9932,12 +9912,12 @@ pub fn parse_constrained_assignment( } let r3 = parse_expr(r2.tokens.clone(), cr.ctx.clone()); if has_err(r3.err.clone()) { - return r3.clone(); + return r3; } let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![r3.expr.clone()]), + Rc::new(vec![(*r3.expr).clone()]), None, span, name_span, @@ -9948,22 +9928,22 @@ pub fn parse_constrained_assignment( ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: node.inferred.clone(), + inferred: (*node.inferred).clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: node.body.clone(), + body: (*node.body).clone(), connective: node.connective.clone(), - transport: node.transport.clone(), + transport: (*node.transport).clone(), properties: cr.constraints.clone(), - type_annotation: node.type_annotation.clone(), + type_annotation: (*node.type_annotation).clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: node.match_pattern.clone(), + match_pattern: (*node.match_pattern).clone(), expr_data: node.expr_data.clone(), ident: None, }); Rc::new(ExprResult { - expr: node.clone(), + expr: node, tokens: r3.tokens.clone(), ctx: r3.ctx.clone(), err: None, @@ -10005,7 +9985,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc __ec.clone(), + EatResult::EatConsumed { tokens: __ec, .. } => __ec, EatResult::EatUnchanged { tokens: _, .. } => { let r2 = expect(cr.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r2.err.clone()) { @@ -10021,29 +10001,29 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc Some(r3.expr.clone()), + let type_ann = match (*e_colon).clone() { + EatResult::EatConsumed { .. } => Some((*r3.expr).clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { name: name, span: span, ident_span: Some(name_span), - children: Rc::new(vec![r3.expr.clone()]), + children: Rc::new(vec![(*r3.expr).clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: ret.inferred.clone(), + inferred: (*ret.inferred).clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -10091,12 +10071,12 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> } let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { - return r3.clone(); + return r3; } let cr = try_constraint_annotations(r3.tokens.clone(), r3.ctx.clone()); if has_err(cr.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: cr.err.clone(), @@ -10105,7 +10085,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![r3.expr.clone()]), + Rc::new(vec![(*r3.expr).clone()]), None, span, name_span, @@ -10118,22 +10098,22 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: node.inferred.clone(), + inferred: (*node.inferred).clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: node.body.clone(), + body: (*node.body).clone(), connective: node.connective.clone(), - transport: node.transport.clone(), + transport: (*node.transport).clone(), properties: cr.constraints.clone(), - type_annotation: node.type_annotation.clone(), + type_annotation: (*node.type_annotation).clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: node.match_pattern.clone(), + match_pattern: (*node.match_pattern).clone(), expr_data: node.expr_data.clone(), ident: None, }); Rc::new(ExprResult { - expr: node.clone(), + expr: node, tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: None, @@ -10141,7 +10121,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> } } else { Rc::new(ExprResult { - expr: node.clone(), + expr: node, tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: None, @@ -10162,9 +10142,9 @@ pub fn parse_expr_bp( { let r = parse_prefix(tokens, ctx); if has_err(r.err.clone()) { - return r.clone(); + return r; } - let lhs = r.expr.clone(); + let lhs = (*r.expr).clone(); parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10199,7 +10179,7 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = post.expr.clone(); + let __tco_2 = (*post.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10207,7 +10187,7 @@ pub fn parse_expr_loop( } } else { let bp = infix_bp(tokens.clone()); - match bp { + match bp.clone() { Some(bps) => { if (bps.left.clone() < min_bp.clone()) { break Rc::new(ExprResult { @@ -10241,12 +10221,12 @@ pub fn parse_expr_loop( }), Rc::new(vec![lhs.clone()]), None, - loop_span, + loop_span.clone(), r.span.clone(), ); { let __tco_0 = r.tokens.clone(); - let __tco_1 = new_lhs; + let __tco_1 = new_lhs.clone(); tokens = __tco_0; lhs = __tco_1; continue; @@ -10257,11 +10237,11 @@ pub fn parse_expr_loop( rest.clone(), ctx.clone(), lhs.clone(), - loop_span, + loop_span.clone(), ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10270,7 +10250,7 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.expr.clone(); + let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10285,7 +10265,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10295,7 +10275,7 @@ pub fn parse_expr_loop( dag_syntax_spec().operators.clone(), op_tok.text.clone(), ); - match binop_opt { + match binop_opt.clone() { Some(binop) => { let new_lhs = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -10304,15 +10284,15 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - r.expr.clone(), + (*r.expr).clone(), ]), None, - loop_span, + loop_span.clone(), ); { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = new_lhs; + let __tco_2 = new_lhs.clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10330,7 +10310,7 @@ pub fn parse_expr_loop( .to_string(), op_tok.text.clone(), ), - loop_span, + loop_span.clone(), )), }); } @@ -10377,7 +10357,7 @@ pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Optio }); if ((matching.clone().len() as i64) > 0) { { - let op = matching.clone().first().cloned().clone().unwrap(); + let op = matching.first().cloned().clone().unwrap(); Some(BindingPower { left: op.left_bp.clone(), right: op.right_bp.clone(), @@ -10408,14 +10388,7 @@ pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Op __result }); if ((matching.clone().len() as i64) > 0) { - matching - .clone() - .first() - .cloned() - .clone() - .unwrap() - .binop - .clone() + matching.first().cloned().clone().unwrap().binop.clone() } else { None } @@ -10446,7 +10419,7 @@ pub fn parse_pipe_rhs( let r2 = parse_call_args(tokens.clone(), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -10509,13 +10482,13 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), None => None, }; - let span = token_span(tok.clone()); + let span = token_span(tok); match sh { Some(TokenShape::ShBang) => { let r = parse_expr_bp(token_stream_advance(tokens.clone(), 1), ctx, 12); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10526,7 +10499,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let spelling = next.clone().unwrap().text.clone(); - let end_span = token_span(next.clone()); + let end_span = token_span(next); let lit_span = make_span(span.start.clone(), end_span.end.clone()); Rc::new(ExprResult { expr: make_expr_node( @@ -10588,16 +10561,16 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc { - let r = parse_expr(token_stream_advance(after_caret.clone(), 1), ctx.clone()); + let r = parse_expr(token_stream_advance(after_caret, 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10627,8 +10600,8 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let found = match next_shape.clone() { - Some(shape) => shape_display_name(shape.clone()), + let found = match next_shape { + Some(shape) => shape_display_name(shape), None => "EOF".to_string(), }; Rc::new(ExprResult { @@ -10651,14 +10624,11 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( - Rc::new(ExprData::ExprLiteral { value: lv.clone() }), + Rc::new(ExprData::ExprLiteral { value: lv }), Rc::new(vec![]), None, - span.clone(), + span, ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -10711,14 +10681,14 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()), + Some(n) => parse_ident_expr(tokens.clone(), ctx.clone(), n), None => Rc::new(ExprResult { expr: parse_recovery_expr(span.clone(), format!("expected expression, found keyword '{}'", kw_text.clone())), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text.clone()), span.clone())), + err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text), span)), }), } } @@ -10734,7 +10704,7 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v.clone(), + Some(v) => v, None => { return Rc::new(ExprResult { expr: make_expr_error_node( @@ -10758,11 +10728,11 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc parse_caret_expr(tokens.clone(), ctx.clone()), Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()) + parse_ident_expr(tokens.clone(), ctx.clone(), n) } Some(TokenShape::ShLParen) => parse_paren_expr(tokens.clone(), ctx.clone()), Some(TokenShape::ShLBracket) => parse_list_literal(tokens.clone(), ctx.clone()), Some(TokenShape::ShLBrace) => parse_brace_expr(tokens.clone(), ctx.clone()), _ => { - let tag = match sh.clone() { - Some(shape) => shape_display_name(shape.clone()), + let tag = match sh { + Some(shape) => shape_display_name(shape), None => "EOF".to_string(), }; Rc::new(ExprResult { @@ -10823,8 +10793,8 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc bool { { let ch = v1_rt::char_at(&name, 0); - ((ch.clone() >= "A".to_string()) && (ch.clone() <= "Z".to_string())) + ((ch.clone() >= "A".to_string()) && (ch <= "Z".to_string())) } } @@ -11054,7 +11024,7 @@ pub fn try_postfix( Rc::new(PostfixResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![lhs.clone(), r.type_expr.clone()]), + Rc::new(vec![lhs.clone(), (*r.type_expr).clone()]), None, span, ), @@ -11111,7 +11081,7 @@ pub fn try_postfix( }); } Rc::new(PostfixResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), changed: true, tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -11140,7 +11110,7 @@ pub fn try_postfix( let r = parse_record_literal( tokens.clone(), ctx.clone(), - n.clone(), + n, lhs.span.clone(), ); if has_err(r.err.clone()) { @@ -11153,7 +11123,7 @@ pub fn try_postfix( }); } Rc::new(PostfixResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), changed: true, tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -11217,9 +11187,9 @@ pub fn parse_constraint_annotations( ) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_constraint_list(__ec.clone(), ctx, Rc::new(vec![])); + let r = parse_constraint_list(__ec, ctx, Rc::new(vec![])); if has_err(r.err.clone()) { - return r.clone(); + return r; } let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r2.err.clone()) { @@ -11262,7 +11232,7 @@ pub fn parse_constraint_list( } None => false, }; - if !is_constraint_kw { + if !is_constraint_kw.clone() { return Rc::new(ConstraintsResult { constraints: acc.clone(), tokens: tokens.clone(), @@ -11280,8 +11250,13 @@ pub fn parse_constraint_list( err: r.err.clone(), }); } - let fi = make_field_init_node(kw_name, r.expr.clone(), make_span(0, 0), make_span(0, 0)); - acc = v1_rt::rc_list_push(acc.clone(), fi); + let fi = make_field_init_node( + kw_name.clone(), + (*r.expr).clone(), + make_span(0, 0), + make_span(0, 0), + ); + acc = v1_rt::rc_list_push(acc.clone(), fi.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); @@ -11385,13 +11360,13 @@ pub fn parse_index_or_slice( let r = parse_expr(r.tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let first_expr = r.expr.clone(); + let first_expr = (*r.expr).clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11399,17 +11374,17 @@ pub fn parse_index_or_slice( let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let end_expr = r.expr.clone(); + let end_expr = (*r.expr).clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -11432,7 +11407,7 @@ pub fn parse_index_or_slice( let r = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -11477,7 +11452,7 @@ pub fn parse_call_args(tokens: Rc, ctx: Rc) -> Rc Rc { loop { tokens = skip_newlines(tokens.clone()); - let r = parse_single_arg(tokens.clone(), ctx); + let r = parse_single_arg(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ArgsResult { args: Rc::new(vec![]), @@ -11520,7 +11495,7 @@ pub fn parse_arg_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.arg.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.arg).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -11561,7 +11536,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc= min_bp.clone())) { let span = token_span(token_stream_first(tokens.clone())); - let r = parse_index_or_slice(tokens.clone(), ctx.clone(), lhs.clone(), span); + let r = parse_index_or_slice( + tokens.clone(), + ctx.clone(), + lhs.clone(), + span.clone(), + ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -11804,7 +11783,7 @@ pub fn parse_expr_loop_no_brace( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.expr.clone(); + let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -11812,7 +11791,7 @@ pub fn parse_expr_loop_no_brace( } } else { let bp = infix_bp(tokens.clone()); - match bp { + match bp.clone() { Some(bps) => { if (bps.left.clone() < min_bp.clone()) { break Rc::new(ExprResult { @@ -11846,12 +11825,12 @@ pub fn parse_expr_loop_no_brace( }), Rc::new(vec![lhs.clone()]), None, - loop_span, + loop_span.clone(), r.span.clone(), ); { let __tco_0 = r.tokens.clone(); - let __tco_1 = new_lhs; + let __tco_1 = new_lhs.clone(); tokens = __tco_0; lhs = __tco_1; continue; @@ -11862,11 +11841,11 @@ pub fn parse_expr_loop_no_brace( rest.clone(), ctx.clone(), lhs.clone(), - loop_span, + loop_span.clone(), ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -11875,7 +11854,7 @@ pub fn parse_expr_loop_no_brace( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.expr.clone(); + let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -11890,7 +11869,7 @@ pub fn parse_expr_loop_no_brace( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -11900,7 +11879,7 @@ pub fn parse_expr_loop_no_brace( dag_syntax_spec().operators.clone(), op_tok.text.clone(), ); - match binop_opt { + match binop_opt.clone() { Some(binop) => { let new_lhs = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -11909,15 +11888,15 @@ pub fn parse_expr_loop_no_brace( }), Rc::new(vec![ lhs.clone(), - r.expr.clone(), + (*r.expr).clone(), ]), None, - loop_span, + loop_span.clone(), ); { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = new_lhs; + let __tco_2 = new_lhs.clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -11935,7 +11914,7 @@ pub fn parse_expr_loop_no_brace( .to_string(), op_tok.text.clone(), ), - loop_span, + loop_span.clone(), )), }); } @@ -11986,11 +11965,11 @@ pub fn parse_match_arms_acc( break Rc::new(ArmsResult { arms: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } else { - let r = parse_match_arm(tokens.clone(), ctx); + let r = parse_match_arm(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ArmsResult { arms: acc.clone(), @@ -12000,13 +11979,13 @@ pub fn parse_match_arms_acc( }); } let e = eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.arm.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.arm).clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -12033,7 +12012,7 @@ pub fn parse_match_arm(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R { let tok = token_stream_first(tokens.clone()); let is_block = (tok_is_keyword(tok.clone(), "let".to_string()) - || tok_is_keyword(tok.clone(), "return".to_string())); + || tok_is_keyword(tok, "return".to_string())); if is_block { { let r = parse_match_arm_stmts(tokens.clone(), ctx, Rc::new(vec![])); @@ -12138,7 +12117,7 @@ pub fn parse_match_arm_stmts( break Rc::new(StmtsResult { stmts: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } else { @@ -12146,11 +12125,11 @@ pub fn parse_match_arm_stmts( break Rc::new(StmtsResult { stmts: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } else { - let r = parse_stmt(tokens.clone(), ctx); + let r = parse_stmt(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(StmtsResult { stmts: acc.clone(), @@ -12162,7 +12141,7 @@ pub fn parse_match_arm_stmts( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r.expr.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r.expr).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -12186,7 +12165,7 @@ pub fn looks_like_arm_start(tokens: Rc) -> bool { if (n.clone() == "_".to_string()) { peek_is_fat_arrow_at(tokens.clone(), 1) } else { - if is_uppercase_start(n.clone()) { + if is_uppercase_start(n) { if peek_is_fat_arrow_at(tokens.clone(), 1) { true } else { @@ -12226,7 +12205,7 @@ pub fn peek_is_expected_at( expected: Rc, ) -> bool { match token_stream_first(token_stream_advance(tokens, offset)) { - Some(t) => token_matches_expected(t.clone(), expected), + Some(t) => token_matches_expected(t, expected), None => false, } } @@ -12292,7 +12271,7 @@ pub fn parse_optional_guard(tokens: Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some(r.expr.clone()), + guard: Some((*r.expr).clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12331,11 +12310,11 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(PatternResult { - pattern: Rc::new(MatchPattern::LitPattern { value: lv.clone() }), + pattern: Rc::new(MatchPattern::LitPattern { value: lv }), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), err: None, @@ -12364,7 +12343,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v.clone(), + Some(v) => v, None => { return Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), @@ -12386,7 +12365,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r2.tokens.clone(), }); let fb = make_field_binding_node( field_name.clone(), - r2.pattern.clone(), - bind_span, - field_name_span, + (*r2.pattern).clone(), + bind_span.clone(), + field_name_span.clone(), ); { let __tco_0 = r2.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, fb); + let __tco_1 = v1_rt::rc_list_push(acc, fb.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -12581,7 +12560,7 @@ pub fn parse_variant_bindings_brace_acc( } EatResult::EatUnchanged { tokens: __eu, .. } => { let e2 = eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e2).clone() { + tokens = skip_newlines(match (*e2.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); @@ -12590,11 +12569,11 @@ pub fn parse_variant_bindings_brace_acc( Rc::new(MatchPattern::Bind { name: field_name.clone(), }), - bind_span, - field_name_span, + bind_span.clone(), + field_name_span.clone(), ); { - let __tco_0 = v1_rt::rc_list_push(acc, fb); + let __tco_0 = v1_rt::rc_list_push(acc, fb.clone()); acc = __tco_0; continue; } @@ -12631,17 +12610,17 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let tokens = skip_newlines(__ec.clone()); + let tokens = skip_newlines(__ec); if tok_is_keyword(token_stream_first(tokens.clone()), "if".to_string()) { { let r2 = parse_if(tokens.clone(), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: r2.expr.clone(), + expr: (*r2.expr).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -12668,7 +12647,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -13001,7 +12980,7 @@ pub fn parse_field_init(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc t.text.clone(), None => "_".to_string(), }; let r = parse_expr(token_stream_advance(tokens.clone(), 2), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(FieldInitResult { - field: dummy_fi.clone(), + field: dummy_fi, tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let fi = - make_field_init_node(str_name, r.expr.clone(), span.clone(), no_span()); + let fi = make_field_init_node(str_name, (*r.expr).clone(), span, no_span()); Rc::new(FieldInitResult { field: fi, tokens: r.tokens.clone(), @@ -13095,18 +13069,14 @@ pub fn parse_field_init(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc< ); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr.clone(), + expr: dummy_expr, tokens: r2.tokens.clone(), ctx: r.ctx.clone(), err: r2.err.clone(), @@ -13186,15 +13156,15 @@ pub fn parse_expr_list_until_acc( Some(t) => token_matches_expected(t.clone(), end_expected.clone()), None => false, }; - if (at_end_tag || tok_is_eof(token_stream_first(tokens.clone()))) { + if (at_end_tag.clone() || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(ExprsResult { - exprs: acc, + exprs: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } else { - let r = parse_expr(tokens.clone(), ctx); + let r = parse_expr(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprsResult { exprs: Rc::new(vec![]), @@ -13204,13 +13174,13 @@ pub fn parse_expr_list_until_acc( }); } let e = eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e).clone() { + tokens = skip_newlines(match (*e.clone()).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.expr.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.expr).clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -13253,7 +13223,7 @@ pub fn parse_paren_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = __ec.clone(); - let __tco_1 = new_acc; + let __tco_1 = new_acc.clone(); tokens = __tco_0; acc = __tco_1; continue; @@ -13521,9 +13491,9 @@ pub fn collect_lambda_idents( EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(IdentCollectResult { success: true, - params: new_acc, + params: new_acc.clone(), tokens: token_stream_advance(tokens.clone(), 1), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } @@ -13531,9 +13501,9 @@ pub fn collect_lambda_idents( } else { break Rc::new(IdentCollectResult { success: false, - params: acc, + params: acc.clone(), tokens: tokens.clone(), - ctx: ctx, + ctx: ctx.clone(), err: None, }); } @@ -13552,9 +13522,7 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc Some(TokenShape::ShStrBegin) => { let prefix = tok.clone().unwrap().text.clone(); let parts_init = if (v1_rt::string_length(&prefix) > 0) { - Rc::new(vec![Rc::new(StringPart::Text { - value: prefix.clone(), - })]) + Rc::new(vec![Rc::new(StringPart::Text { value: prefix })]) } else { Rc::new(vec![]) }; @@ -13562,7 +13530,7 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc token_stream_advance(tokens.clone(), 1), ctx, parts_init, - span.clone(), + span, ) } _ => Rc::new(ExprResult { @@ -13574,7 +13542,7 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc ctx: ctx, err: Some(parse_error( "expected string interpolation".to_string(), - span.clone(), + span, )), }), } @@ -13590,12 +13558,12 @@ pub fn parse_interp_parts( loop { let r = parse_expr(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { - return r.clone(); + return r; } let new_parts = v1_rt::rc_list_push( - parts, + parts.clone(), Rc::new(StringPart::Interpolation { - expr: r.expr.clone(), + expr: (*r.expr).clone(), }), ); tokens = r.tokens.clone(); @@ -13605,17 +13573,20 @@ pub fn parse_interp_parts( Some(t) => Some(t.shape.clone()), None => None, }; - match interp_sh { + match interp_sh.clone() { Some(TokenShape::ShStrMid) => { let mid = interp_tok.clone().unwrap().text.clone(); let mid_parts = if (v1_rt::string_length(&mid) > 0) { - v1_rt::rc_list_push(new_parts, Rc::new(StringPart::Text { value: mid.clone() })) + v1_rt::rc_list_push( + new_parts.clone(), + Rc::new(StringPart::Text { value: mid.clone() }), + ) } else { - new_parts + new_parts.clone() }; { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = mid_parts; + let __tco_1 = mid_parts.clone(); tokens = __tco_0; parts = __tco_1; continue; @@ -13625,20 +13596,20 @@ pub fn parse_interp_parts( let suffix = interp_tok.clone().unwrap().text.clone(); let final_parts = if (v1_rt::string_length(&suffix) > 0) { v1_rt::rc_list_push( - new_parts, + new_parts.clone(), Rc::new(StringPart::Text { value: suffix.clone(), }), ) } else { - new_parts + new_parts.clone() }; break Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), Rc::new({ let mut __result = Vec::new(); - for p in final_parts.iter().cloned() { + for p in final_parts.clone().iter().cloned() { __result.push(match (*p.clone()).clone() { StringPart::Text { value: v, .. } => { make_text_part_node(v.clone(), span.clone()) @@ -13664,7 +13635,7 @@ pub fn parse_interp_parts( Rc::new(ExprData::ExprStringInterp), Rc::new({ let mut __result = Vec::new(); - for p in new_parts.iter().cloned() { + for p in new_parts.clone().iter().cloned() { __result.push(match (*p.clone()).clone() { StringPart::Text { value: v, .. } => { make_text_part_node(v.clone(), span.clone()) @@ -13716,7 +13687,7 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc { let brace_kw = tok_keyword_text(tok.clone()); if ((brace_kw.clone() == "let".to_string()) - || (brace_kw.clone() == "return".to_string())) + || (brace_kw == "return".to_string())) { { let r = parse_stmts(tokens.clone(), ctx); @@ -13733,7 +13704,7 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, m: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/03_resolve.dag:1814:acc"); { let result = resolve_module_imports( m.clone(), @@ -122,7 +122,7 @@ pub fn resolve_modules( let import_diags = resolve_accum.diagnostics.clone(); let topo_result = topological_sort(modules.clone(), source_indices.clone()); let topo_diags = match topo_result.cycle_error.clone() { - Some(diag) => Rc::new(vec![diag.clone()]), + Some(diag) => Rc::new(vec![diag]), None => Rc::new(vec![]), }; let sorted_names = topo_result.sorted.clone(); @@ -220,7 +220,7 @@ pub fn resolve_module_imports( for r in Rc::new({ let mut __result = Vec::new(); for r in results.clone().iter().cloned() { - if ((r.resolved.clone().target_module.clone() != None) + if (((*r.resolved.clone().target_module).clone() != None) && ((r.diagnostics.clone().len() as i64) == 0)) { __result.push(r); @@ -237,7 +237,7 @@ pub fn resolve_module_imports( }); let diags = Rc::new({ let mut __result = Vec::new(); - for r in results.clone().iter().cloned() { + for r in results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -277,7 +277,7 @@ pub fn resolve_import( ); Rc::new(ImportResolveResult { resolved: Rc::new(ResolvedImport { - module_path: import_path.clone(), + module_path: import_path, is_all: import_is_all(import.clone()), specific_names: import_specific_names_at( import.clone(), @@ -290,7 +290,7 @@ pub fn resolve_import( } Some(target_mod) => { let exported_set = match v1_rt::map_get(&export_sets, import_path.clone()) { - Some(set) => set.clone(), + Some(set) => set, None => v1_rt::rc_empty_map::(), }; let name_diags = if import_is_all(import.clone()) { @@ -329,13 +329,13 @@ pub fn resolve_import( }; Rc::new(ImportResolveResult { resolved: Rc::new(ResolvedImport { - module_path: import_path.clone(), + module_path: import_path, is_all: import_is_all(import.clone()), specific_names: import_specific_names_at( import.clone(), source_indices.clone(), ), - target_module: Some(target_mod.clone()), + target_module: Some(target_mod), }), diagnostics: name_diags, }) @@ -478,7 +478,7 @@ pub fn adjacency_add_edge( ) -> Rc>>> { { let existing = match v1_rt::map_get(&adjacency, from_module.clone()) { - Some(lst) => lst.clone(), + Some(lst) => lst, None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -493,7 +493,7 @@ pub fn topo_sort_key(name: String) -> String { if (name.clone() == "std.types".to_string()) { "".to_string() } else { - name.clone() + name } } @@ -605,11 +605,11 @@ pub fn topological_sort( let result = kahn_drain( initial_queue, Rc::new(vec![]), - in_degree_map.clone(), + in_degree_map, adjacency, module_count.clone(), ); - if ((result.sorted.clone().len() as i64) == module_count.clone()) { + if ((result.sorted.clone().len() as i64) == module_count) { Rc::new(TopoResult { sorted: result.sorted.clone(), cycle_error: None, @@ -624,7 +624,7 @@ pub fn topological_sort( ); let cycle_members = Rc::new({ let mut __result = Vec::new(); - for name in module_names.clone().iter().cloned() { + for name in module_names.iter().cloned() { if (v1_rt::map_has(&sorted_set, name.clone()) == false) { __result.push(name); } @@ -636,7 +636,7 @@ pub fn topological_sort( sorted: result.sorted.clone(), cycle_error: Some(make_error_node( Rc::new(CompilerDiagnostic::CircularDependency { - modules: cycle_members.clone(), + modules: cycle_members, span: no_span(), }), "".to_string(), @@ -673,7 +673,7 @@ pub fn kahn_drain( in_degree_map: in_degree_map.clone(), }), |state: Rc, node: String| { - let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); + let state = v1_rt::take_owned_counted(state, "src/v1/03_resolve.dag:11425:state"); { let new_sorted = v1_rt::rc_list_push(state.sorted, node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { @@ -750,7 +750,7 @@ pub fn kahn_drain( __sorted }); { - let __tco_0 = new_zero; + let __tco_0 = new_zero.clone(); let __tco_1 = batch_result.sorted.clone(); let __tco_2 = batch_result.in_degree_map.clone(); let __tco_3 = (fuel - 1); diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index 7b4719aca47..23bb9dedd25 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -94,11 +94,11 @@ pub fn render_stage0_crate_dep(dep: Rc) -> String { match (*dep.source.clone()).clone() { CargoDepSource::RegistryDep { version, features, .. - } => emit_cargo_dep(dep.name.clone(), version.clone(), features.clone()), + } => emit_cargo_dep(dep.name.clone(), version, features), CargoDepSource::LocalPathDep { path: path, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat(dep.name.clone(), " = { path = \"".to_string()), - path.clone(), + path, ), "\" }\n".to_string(), ), diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index 1e7d9828c41..5c15786c023 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -234,12 +234,12 @@ pub fn scan_next_token(source: Rc, pos: Rc) -> Rc ), TokenShape::ShRBrace, ), - interp_depth: replace_last(pos.interp_depth.clone(), (top.clone() - 1)), + interp_depth: replace_last(pos.interp_depth.clone(), (top - 1)), }); } } } - scan_token(source.clone(), pos.clone(), ch.clone()) + scan_token(source.clone(), pos.clone(), ch) } } @@ -250,7 +250,7 @@ pub fn tokenize_loop( mut fuel: i64, ) -> Rc { loop { - let s = skip_spaces(source.clone(), pos); + let s = skip_spaces(source.clone(), pos.clone()); if (s.pos.clone() >= source_len(source.clone())) { return Rc::new(TokenizerState { pos: s.pos.clone(), @@ -389,7 +389,7 @@ pub fn scan_token(source: Rc, pos: Rc, ch: i64) -> Rc, pos: Rc, ch: i64) -> Rc emit( - pos.clone(), - sh.clone(), - ch_text.clone(), - 1, - source.file.clone(), - ), + v1_rt::Witness::Holds { value: sh, .. } => { + emit(pos.clone(), sh, ch_text, 1, source.file.clone()) + } v1_rt::Witness::Violates { diagnostic: _, .. } => emit( pos.clone(), TokenShape::ShUnknown, - ch_text.clone(), + ch_text, 1, source.file.clone(), ), @@ -543,12 +539,12 @@ pub fn scan_ident(source: Rc, pos: Rc) -> Rc { } }; let token = make_token( - text.clone(), + text, make_file_span(source.file.clone(), pos.pos.clone(), end.clone()), shape, ); Rc::new(ScanResult { - pos: end.clone(), + pos: end, token: token, interp_depth: pos.interp_depth.clone(), }) @@ -571,7 +567,7 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { TokenShape::ShLitFloat, ); return Rc::new(ScanResult { - pos: frac_end.clone(), + pos: frac_end, token: token.clone(), interp_depth: pos.interp_depth.clone(), }); @@ -584,13 +580,13 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { None => TokenShape::ShUnknown, }; let token = make_token( - text.clone(), + text, make_file_span(source.file.clone(), pos.pos.clone(), int_end.clone()), shape, ); Rc::new(ScanResult { - pos: int_end.clone(), - token: token.clone(), + pos: int_end, + token: token, interp_depth: pos.interp_depth.clone(), }) } @@ -629,14 +625,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::ClosedString { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShLitStr, ); Rc::new(ScanResult { - pos: (end_pos.clone() + 1), + pos: (end_pos + 1), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -644,14 +640,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::InterpolationStart { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrBegin, ); Rc::new(ScanResult { - pos: (end_pos.clone() + 1), + pos: (end_pos + 1), token: token, interp_depth: Rc::new(v1_rt::append(pos.interp_depth.clone(), 0)), }) @@ -659,14 +655,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::UnterminatedString { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, end_pos.clone()), TokenShape::ShUnknown, ); Rc::new(ScanResult { - pos: end_pos.clone(), + pos: end_pos, token: token, interp_depth: pos.interp_depth.clone(), }) @@ -682,14 +678,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::ClosedString { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrEnd, ); Rc::new(ScanResult { - pos: (end_pos.clone() + 1), + pos: (end_pos + 1), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -697,14 +693,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::InterpolationStart { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrMid, ); Rc::new(ScanResult { - pos: (end_pos.clone() + 1), + pos: (end_pos + 1), token: token, interp_depth: Rc::new(v1_rt::append(pos.interp_depth.clone(), 0)), }) @@ -712,14 +708,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::UnterminatedString { content, end_pos, .. } => { - let processed = process_escapes(content.clone()); + let processed = process_escapes(content); let token = make_token( processed, make_file_span(source.file.clone(), span_start, end_pos.clone()), TokenShape::ShUnknown, ); Rc::new(ScanResult { - pos: end_pos.clone(), + pos: end_pos, token: token, interp_depth: pos.interp_depth.clone(), }) @@ -736,14 +732,14 @@ pub fn scan_string_body( loop { if (pos.clone() >= source_len(source.clone())) { break Rc::new(StringScanResult::UnterminatedString { - content: acc.join(&"".to_string()), + content: acc.clone().join(&"".to_string()), end_pos: pos.clone(), }); } else { let ch = source_char(source.clone(), pos.clone()); if (ch.clone() == "\"".to_string()) { break Rc::new(StringScanResult::ClosedString { - content: acc.join(&"".to_string()), + content: acc.clone().join(&"".to_string()), end_pos: pos.clone(), }); } else { @@ -754,7 +750,7 @@ pub fn scan_string_body( let __tco_0 = (pos + 2); let __tco_1 = v1_rt::rc_list_push( v1_rt::rc_list_push(acc, "\\".to_string()), - escaped, + escaped.clone(), ); pos = __tco_0; acc = __tco_1; @@ -762,7 +758,7 @@ pub fn scan_string_body( } } else { break Rc::new(StringScanResult::UnterminatedString { - content: v1_rt::rc_list_push(acc, "\\".to_string()) + content: v1_rt::rc_list_push(acc.clone(), "\\".to_string()) .join(&"".to_string()), end_pos: (pos.clone() + 1), }); @@ -771,7 +767,7 @@ pub fn scan_string_body( if (ch.clone() == "{".to_string()) { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { - content: acc.join(&"".to_string()), + content: acc.clone().join(&"".to_string()), end_pos: pos.clone(), }); } else { @@ -805,7 +801,7 @@ pub fn should_start_interpolation(source: Rc, pos: i64) -> bool { { let next = source_code_point(source.clone(), (pos.clone() + 1)); (((is_ident_start(next.clone()) || (next.clone() == 40)) || (next.clone() == 33)) - || (next.clone() == 45)) + || (next == 45)) } } } @@ -817,7 +813,7 @@ pub fn process_escapes(raw: String) -> String { pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc>) -> String { loop { if (pos.clone() >= v1_rt::string_length(&source)) { - break acc.join(&"".to_string()); + break acc.clone().join(&"".to_string()); } else { let ch = v1_rt::char_at(&source, pos.clone()); if ((ch.clone() == "\\".to_string()) @@ -851,7 +847,7 @@ pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc, pos: Rc) -> Rc { } pub fn is_digit(ch: i64) -> bool { - ((ch.clone() >= 48) && (ch.clone() <= 57)) + ((ch.clone() >= 48) && (ch <= 57)) } pub fn is_ident_start(ch: i64) -> bool { @@ -919,7 +915,7 @@ pub fn is_ident_start(ch: i64) -> bool { } pub fn is_ident_char(ch: i64) -> bool { - (v1_rt::is_xid_continue(ch.clone()) || v1_rt::is_emoji_ident(ch.clone())) + (v1_rt::is_xid_continue(ch.clone()) || v1_rt::is_emoji_ident(ch)) } pub fn is_hex_upper_digit(ch: i64) -> bool { @@ -932,7 +928,7 @@ pub fn all_hex_upper_in_range(mut text: String, mut pos: i64, mut end: i64) -> b break true; } else { let ch = v1_rt::code_point(v1_rt::char_at(&text, pos.clone())); - if is_hex_upper_digit(ch) { + if is_hex_upper_digit(ch.clone()) { { let __tco_0 = (pos + 1); pos = __tco_0; @@ -1007,23 +1003,19 @@ pub fn is_reserved_emit_sentinel(text: String) -> bool { if (n.clone() < ((pfx_len.clone() + sfx_len.clone()) + 1)) { false } else { - if !sentinel_prefix_matches(text.clone(), pfx.clone(), 0, pfx_len.clone()) { + if !sentinel_prefix_matches(text.clone(), pfx, 0, pfx_len.clone()) { false } else { if !sentinel_suffix_matches( text.clone(), - sfx.clone(), + sfx, 0, sfx_len.clone(), (n.clone() - sfx_len.clone()), ) { false } else { - all_hex_upper_in_range( - text.clone(), - pfx_len.clone(), - (n.clone() - sfx_len.clone()), - ) + all_hex_upper_in_range(text.clone(), pfx_len, (n - sfx_len)) } } } diff --git a/src/v1/stage0/src/v1_compiler_trace.rs b/src/v1/stage0/src/v1_compiler_trace.rs index 95c4625f716..66206e73087 100644 --- a/src/v1/stage0/src/v1_compiler_trace.rs +++ b/src/v1/stage0/src/v1_compiler_trace.rs @@ -106,7 +106,7 @@ pub fn trace_pop_frame(trace: Rc) -> Rc { .clone() .iter() .cloned() - .take((n.clone() - 1) as usize) + .take((n - 1) as usize) .collect::>(), ), }) @@ -116,17 +116,17 @@ pub fn trace_pop_frame(trace: Rc) -> Rc { pub fn event_span(event: Rc) -> Rc { match (*event).clone() { - TraceEvent::TraceEnter { span: s, .. } => s.clone(), - TraceEvent::TraceExit { span: s, .. } => s.clone(), - TraceEvent::TraceError { span: s, .. } => s.clone(), + TraceEvent::TraceEnter { span: s, .. } => s, + TraceEvent::TraceExit { span: s, .. } => s, + TraceEvent::TraceError { span: s, .. } => s, } } pub fn event_node_id(event: Rc) -> String { match (*event).clone() { - TraceEvent::TraceEnter { node_id: id, .. } => id.clone(), - TraceEvent::TraceExit { node_id: id, .. } => id.clone(), - TraceEvent::TraceError { node_id: id, .. } => id.clone(), + TraceEvent::TraceEnter { node_id: id, .. } => id, + TraceEvent::TraceExit { node_id: id, .. } => id, + TraceEvent::TraceError { node_id: id, .. } => id, } } @@ -204,11 +204,8 @@ pub fn format_trace_event(event: Rc) -> String { span: sp, .. } => v1_rt::concat( - v1_rt::concat( - v1_rt::concat("> ".to_string(), id.clone()), - " at ".to_string(), - ), - format_span(sp.clone()), + v1_rt::concat(v1_rt::concat("> ".to_string(), id), " at ".to_string()), + format_span(sp), ), TraceEvent::TraceExit { node_id: id, @@ -218,15 +215,12 @@ pub fn format_trace_event(event: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat("< ".to_string(), id.clone()), - " at ".to_string(), - ), - format_span(sp.clone()), + v1_rt::concat(v1_rt::concat("< ".to_string(), id), " at ".to_string()), + format_span(sp), ), ": ".to_string(), ), - out.clone(), + out, ), TraceEvent::TraceError { node_id: id, @@ -236,15 +230,12 @@ pub fn format_trace_event(event: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat("! ".to_string(), id.clone()), - " at ".to_string(), - ), - format_span(sp.clone()), + v1_rt::concat(v1_rt::concat("! ".to_string(), id), " at ".to_string()), + format_span(sp), ), ": ".to_string(), ), - msg.clone(), + msg, ), } } diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index a0826e3e1bf..7542619f127 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -229,12 +229,6 @@ pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() } -pub fn sorted_map_keys(m: &HashMap) -> Vec { - let mut keys = map_keys(m); - keys.sort(); - keys -} - pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -335,12 +329,11 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. -// take_owned_counted: the fail-closed replacement for the silent -// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: -// a failure arm must refuse or be counted, never silently widen). The ownership -// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose -// per-site frequency must stay observable, so the clone arm counts per emitted -// site (site = ":" of the use-site the emitter rewrote). +// take_owned_counted: fail-closed replacement for the silent +// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5: +// a failure arm must refuse or be counted, never silently widen). A shared Rc +// at a proof-licensed take-owned site is a proof deficit; the clone arm counts +// per emitted site so the deficit frequency stays observable. thread_local! { static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = std::cell::RefCell::new(HashMap::new()); diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 21638ee4243..67e3f0a7a28 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -167,7 +167,7 @@ pub enum InferredNode { pub fn inferred_to_node(inferred: Rc) -> Option> { match (*inferred).clone() { - InferredNode::Resolved { node: n, .. } => Some(n.clone()), + InferredNode::Resolved { node: n, .. } => Some(n), InferredNode::CompilerError { .. } => None, InferredNode::TypeVariable { id: _, .. } => None, } @@ -182,7 +182,7 @@ pub fn is_compiler_error(inferred: Rc) -> bool { } pub fn has_inferred(n: Rc) -> bool { - (n.inferred.clone() != None) + ((*n.inferred).clone() != None) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -468,23 +468,23 @@ pub struct ErrorDAG { pub fn diagnostic_to_span(d: Rc) -> Rc { match (*d).clone() { - CompilerDiagnostic::UnresolvedImport { span: s, .. } => s.clone(), - CompilerDiagnostic::MissingExport { span: s, .. } => s.clone(), - CompilerDiagnostic::UnresolvedType { span: s, .. } => s.clone(), - CompilerDiagnostic::TypeMismatch { span: s, .. } => s.clone(), - CompilerDiagnostic::ArityMismatch { span: s, .. } => s.clone(), - CompilerDiagnostic::VariantNotFound { span: s, .. } => s.clone(), - CompilerDiagnostic::FieldNotFound { span: s, .. } => s.clone(), - CompilerDiagnostic::NonExhaustiveMatch { span: s, .. } => s.clone(), - CompilerDiagnostic::CircularDependency { span: s, .. } => s.clone(), - CompilerDiagnostic::DuplicateModule { span: s, .. } => s.clone(), - CompilerDiagnostic::MissingAnnotation { span: s, .. } => s.clone(), - CompilerDiagnostic::ParseError { span: s, .. } => s.clone(), - CompilerDiagnostic::InternalError { span: s, .. } => s.clone(), - CompilerDiagnostic::ComplexityUnknown { span: s, .. } => s.clone(), - CompilerDiagnostic::OwnershipViolation { span: s, .. } => s.clone(), - CompilerDiagnostic::VariantCollision { span: s, .. } => s.clone(), - CompilerDiagnostic::SoleConstructorViolation { span: s, .. } => s.clone(), + CompilerDiagnostic::UnresolvedImport { span: s, .. } => s, + CompilerDiagnostic::MissingExport { span: s, .. } => s, + CompilerDiagnostic::UnresolvedType { span: s, .. } => s, + CompilerDiagnostic::TypeMismatch { span: s, .. } => s, + CompilerDiagnostic::ArityMismatch { span: s, .. } => s, + CompilerDiagnostic::VariantNotFound { span: s, .. } => s, + CompilerDiagnostic::FieldNotFound { span: s, .. } => s, + CompilerDiagnostic::NonExhaustiveMatch { span: s, .. } => s, + CompilerDiagnostic::CircularDependency { span: s, .. } => s, + CompilerDiagnostic::DuplicateModule { span: s, .. } => s, + CompilerDiagnostic::MissingAnnotation { span: s, .. } => s, + CompilerDiagnostic::ParseError { span: s, .. } => s, + CompilerDiagnostic::InternalError { span: s, .. } => s, + CompilerDiagnostic::ComplexityUnknown { span: s, .. } => s, + CompilerDiagnostic::OwnershipViolation { span: s, .. } => s, + CompilerDiagnostic::VariantCollision { span: s, .. } => s, + CompilerDiagnostic::SoleConstructorViolation { span: s, .. } => s, } } @@ -497,10 +497,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("unresolved import: module '".to_string(), m.clone()), + v1_rt::concat("unresolved import: module '".to_string(), m), "' not found (imported by '".to_string(), ), - i.clone(), + i, ), "')".to_string(), ), @@ -514,19 +514,19 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("name '".to_string(), n.clone()), + v1_rt::concat("name '".to_string(), n), "' not found in module '".to_string(), ), - m.clone(), + m, ), "' (imported by '".to_string(), ), - i.clone(), + i, ), "')".to_string(), ), CompilerDiagnostic::UnresolvedType { name: n, .. } => v1_rt::concat( - v1_rt::concat("unresolved type '".to_string(), n.clone()), + v1_rt::concat("unresolved type '".to_string(), n), "'".to_string(), ), CompilerDiagnostic::TypeMismatch { @@ -536,10 +536,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("type mismatch: expected '".to_string(), e.clone()), + v1_rt::concat("type mismatch: expected '".to_string(), e), "', got '".to_string(), ), - g.clone(), + g, ), "'".to_string(), ), @@ -552,14 +552,14 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("type ".to_string(), n.clone()), + v1_rt::concat("type ".to_string(), n), " expects ".to_string(), ), - (e.clone()).to_string(), + (e).to_string(), ), " type arguments, got ".to_string(), ), - (g.clone()).to_string(), + (g).to_string(), ), CompilerDiagnostic::VariantNotFound { variant: v, @@ -568,10 +568,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("variant '".to_string(), v.clone()), + v1_rt::concat("variant '".to_string(), v), "' not found in type '".to_string(), ), - t.clone(), + t, ), "'".to_string(), ), @@ -582,23 +582,23 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("field '".to_string(), f.clone()), + v1_rt::concat("field '".to_string(), f), "' not found in type '".to_string(), ), - t.clone(), + t, ), "'".to_string(), ), CompilerDiagnostic::NonExhaustiveMatch { missing: ms, .. } => v1_rt::concat( "non-exhaustive match: missing variant(s) ".to_string(), - ms.clone().join(&", ".to_string()), + ms.join(&", ".to_string()), ), CompilerDiagnostic::CircularDependency { modules: ms, .. } => v1_rt::concat( "circular dependency detected: ".to_string(), - ms.clone().join(&" -> ".to_string()), + ms.join(&" -> ".to_string()), ), CompilerDiagnostic::DuplicateModule { name: n, .. } => v1_rt::concat( - v1_rt::concat("duplicate module declaration: '".to_string(), n.clone()), + v1_rt::concat("duplicate module declaration: '".to_string(), n), "'".to_string(), ), CompilerDiagnostic::MissingAnnotation { @@ -608,25 +608,25 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("function '".to_string(), f.clone()), + v1_rt::concat("function '".to_string(), f), "' requires ".to_string(), ), - w.clone(), + w, ), " annotation".to_string(), ), - CompilerDiagnostic::ParseError { message: m, .. } => m.clone(), - CompilerDiagnostic::InternalError { message: m, .. } => m.clone(), + CompilerDiagnostic::ParseError { message: m, .. } => m, + CompilerDiagnostic::InternalError { message: m, .. } => m, CompilerDiagnostic::ComplexityUnknown { func_name: f, reason: r, .. } => v1_rt::concat( v1_rt::concat( - v1_rt::concat("complexity: ".to_string(), f.clone()), + v1_rt::concat("complexity: ".to_string(), f), ": ".to_string(), ), - r.clone(), + r, ), CompilerDiagnostic::OwnershipViolation { binding: b, @@ -638,14 +638,14 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("ownership: binding '".to_string(), b.clone()), + v1_rt::concat("ownership: binding '".to_string(), b), "' in '".to_string(), ), - f.clone(), + f, ), "' has ".to_string(), ), - (c.clone()).to_string(), + (c).to_string(), ), " consumers".to_string(), ), @@ -659,19 +659,19 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("variant '".to_string(), v.clone()), + v1_rt::concat("variant '".to_string(), v), "' appears in both '".to_string(), ), - e1.clone(), + e1, ), "' and '".to_string(), ), - e2.clone(), + e2, ), "'".to_string(), ), CompilerDiagnostic::SoleConstructorViolation { type_name: t, .. } => v1_rt::concat( - v1_rt::concat("sole_constructor type '".to_string(), t.clone()), + v1_rt::concat("sole_constructor type '".to_string(), t), "' cannot be constructed outside its defining module".to_string(), ), } @@ -770,7 +770,7 @@ pub fn default_ident_span(name: String, span: Rc) -> Option) -> Rc { match n.ident_span.clone() { - Some(s) => s.clone(), + Some(s) => s, None => n.span.clone(), } } @@ -878,13 +878,13 @@ pub fn make_arg_node( ) -> Rc { { let arg_name = match name { - Some(n) => n.clone(), + Some(n) => n, None => "".to_string(), }; Rc::new(Node { name: arg_name.clone(), span: span, - ident_span: default_ident_span(arg_name.clone(), name_span), + ident_span: default_ident_span(arg_name, name_span), children: Rc::new(vec![value]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -912,7 +912,7 @@ pub fn make_arm_node( ) -> Rc { { let children = match guard { - Some(g) => Rc::new(vec![g.clone(), body]), + Some(g) => Rc::new(vec![g, body]), None => Rc::new(vec![body]), }; Rc::new(Node { @@ -975,7 +975,7 @@ pub fn resource_use_name_at( pub fn resource_use_resource(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed resource-use: missing resource".to_string(), @@ -1048,8 +1048,8 @@ pub fn field_binding_name_at( } pub fn field_binding_pattern(n: Rc) -> Rc { - match n.match_pattern.clone() { - Some(p) => p.clone(), + match (*n.match_pattern).clone() { + Some(p) => p, None => Rc::new(MatchPattern::Wildcard), } } @@ -1111,7 +1111,7 @@ pub fn make_param_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr, dv.clone()]), + Some(dv) => Rc::new(vec![type_expr, dv]), None => Rc::new(vec![type_expr]), }; Rc::new(Node { @@ -1147,7 +1147,7 @@ pub fn make_resolved_param_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr.clone(), dv.clone()]), + Some(dv) => Rc::new(vec![type_expr.clone(), dv]), None => Rc::new(vec![type_expr.clone()]), }; Rc::new(Node { @@ -1196,11 +1196,11 @@ pub fn authored_name_at( match node.ident_span.clone() { Some(span) => match v1_rt::map_get(&source_indices, span.file.clone()) { Some(index) => { - let text = source_text_at(index.clone(), span.clone()); + let text = source_text_at(index, span); if (text.clone() == "".to_string()) { "".to_string() } else { - text.clone() + text } } None => { @@ -1238,7 +1238,7 @@ pub fn find_child_named( .first() .cloned() { - Some(ch) => Some(ch.clone()), + Some(ch) => Some(ch), None => None, } } @@ -1262,7 +1262,7 @@ pub fn has_child_named( pub fn param_node_type_expr(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed param: missing type_expr".to_string(), @@ -1294,7 +1294,7 @@ pub fn make_field_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr.clone(), dv.clone()]), + Some(dv) => Rc::new(vec![type_expr.clone(), dv]), None => Rc::new(vec![type_expr.clone()]), }; let props = match from_key { @@ -1303,7 +1303,7 @@ pub fn make_field_node( Rc::new(Node { name: fk.clone(), span: make_span(0, 0), - ident_span: default_ident_span(fk.clone(), make_span(0, 0)), + ident_span: default_ident_span(fk, make_span(0, 0)), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -1357,7 +1357,7 @@ pub fn field_node_name_at( pub fn field_node_type_expr(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed field: missing type_expr".to_string(), @@ -1387,7 +1387,7 @@ pub fn field_node_from_key( "from_key".to_string(), source_indices.clone(), ) { - Some(p) => Some(authored_name_at(source_indices.clone(), p.clone())), + Some(p) => Some(authored_name_at(source_indices.clone(), p)), None => None, } } @@ -1606,7 +1606,7 @@ pub fn function_size_effects() -> Rc>> { pub fn is_tree_size_preserving(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { FunctionSizeEffect::TreeSizePreserving => true, FunctionSizeEffect::PropertyContraction { domain_size: _, .. } => true, _ => false, @@ -1617,7 +1617,7 @@ pub fn is_tree_size_preserving(func_name: String) -> bool { pub fn is_tree_size_reducing(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { FunctionSizeEffect::TreeSizeReducing => true, _ => false, }, @@ -1627,7 +1627,7 @@ pub fn is_tree_size_reducing(func_name: String) -> bool { pub fn is_property_contraction(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { FunctionSizeEffect::PropertyContraction { domain_size: _, .. } => true, _ => false, }, @@ -1637,7 +1637,7 @@ pub fn is_property_contraction(func_name: String) -> bool { pub fn expr_child_at(texpr: Rc, index: i64, role: String) -> Rc { match texpr.children.clone().get(index as usize).cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, v1_rt::concat("malformed node: missing ".to_string(), role), @@ -1655,14 +1655,14 @@ pub fn arg_name_at( if (name.clone() == "".to_string()) { None } else { - Some(name.clone()) + Some(name) } } } pub fn arg_value(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed arg: missing value".to_string(), @@ -1672,8 +1672,8 @@ pub fn arg_value(n: Rc) -> Rc { } pub fn arm_pattern(n: Rc) -> Rc { - match n.match_pattern.clone() { - Some(p) => p.clone(), + match (*n.match_pattern).clone() { + Some(p) => p, None => Rc::new(MatchPattern::Wildcard), } } @@ -1688,7 +1688,7 @@ pub fn arm_guard(n: Rc) -> Option> { pub fn arm_body(n: Rc) -> Rc { match n.children.clone().last().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed arm: missing body".to_string(), @@ -1706,7 +1706,7 @@ pub fn field_init_node_name_at( pub fn field_init_node_value(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v.clone(), + Some(v) => v, None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed field-init: missing value".to_string(), @@ -1775,7 +1775,7 @@ pub fn field_access_field_at( pub fn expr_field_access_summary(texpr: Rc) -> Option> { match (*texpr.expr_data.clone()).clone() { - ExprData::ExprFieldAccess { summary: s, .. } => s.clone(), + ExprData::ExprFieldAccess { summary: s, .. } => s, _ => None, } } @@ -1792,7 +1792,7 @@ pub fn expr_call_descent_evidence(texpr: Rc) -> Option de.clone(), + } => de, _ => None, } } @@ -1825,7 +1825,7 @@ pub fn expr_method_call_semantics(texpr: Rc) -> Option ExprData::ExprMethodCall { method_semantics: ms, .. - } => ms.clone(), + } => ms, _ => None, } } @@ -1933,7 +1933,7 @@ pub fn record_lit_type_name_at( if (name.clone() == "".to_string()) { None } else { - Some(name.clone()) + Some(name) } } } @@ -2100,7 +2100,7 @@ pub fn rest_transport_node( let method_props = match method { Some(m) => Rc::new(vec![make_field_init_node( transport_method_key(), - m.clone(), + m, zero_span.clone(), zero_span.clone(), )]), @@ -2109,7 +2109,7 @@ pub fn rest_transport_node( let path_props = match path { Some(p) => Rc::new(vec![make_field_init_node( transport_path_template_key(), - p.clone(), + p, zero_span.clone(), zero_span.clone(), )]), @@ -2118,7 +2118,7 @@ pub fn rest_transport_node( let query_props = match query { Some(q) => Rc::new(vec![make_field_init_node( transport_query_key(), - q.clone(), + q, zero_span.clone(), zero_span.clone(), )]), @@ -2127,7 +2127,7 @@ pub fn rest_transport_node( let body_props = match request_body { Some(b) => Rc::new(vec![make_field_init_node( transport_body_key(), - b.clone(), + b, zero_span.clone(), zero_span.clone(), )]), @@ -2136,9 +2136,9 @@ pub fn rest_transport_node( let rf_props = match response_format { Some(rf) => Rc::new(vec![make_field_init_node( transport_response_format_key(), - rf.clone(), - zero_span.clone(), + rf, zero_span.clone(), + zero_span, )]), None => Rc::new(vec![]), }; @@ -2196,9 +2196,9 @@ pub fn shell_transport_node( let stdin_props = match stdin { Some(s) => Rc::new(vec![make_field_init_node( transport_stdin_key(), - s.clone(), - zero_span.clone(), + s, zero_span.clone(), + zero_span, )]), None => Rc::new(vec![]), }; @@ -2255,7 +2255,7 @@ pub fn find_property( .first() .cloned() { - Some(fi) => Some(field_init_node_value(fi.clone())), + Some(fi) => Some(field_init_node_value(fi)), None => None, } } @@ -2271,7 +2271,7 @@ pub fn find_property_string( let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; - Some(s.clone()) + Some(s) } _ => None, }, @@ -2298,7 +2298,7 @@ pub fn is_rest_transport( } pub fn is_shell_transport(t: Rc) -> bool { - (t.body.clone() != None) + ((*t.body).clone() != None) } pub fn is_file_transport( @@ -2328,7 +2328,7 @@ pub fn field_init_operation_modifier( if (fi_name.clone() == "readonly".to_string()) { Some(OperationModifier::Readonly) } else { - if (fi_name.clone() == "hermetic".to_string()) { + if (fi_name == "hermetic".to_string()) { Some(OperationModifier::Hermetic) } else { None @@ -2499,16 +2499,16 @@ pub fn map_children(node: Rc, transform: impl Fn(Rc) -> Rc + C }), connective: node.connective.clone(), params: node.params.clone(), - inferred: node.inferred.clone(), + inferred: (*node.inferred).clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: node.body.clone(), - transport: node.transport.clone(), + body: (*node.body).clone(), + transport: (*node.transport).clone(), properties: node.properties.clone(), - type_annotation: node.type_annotation.clone(), + type_annotation: (*node.type_annotation).clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: node.match_pattern.clone(), + match_pattern: (*node.match_pattern).clone(), expr_data: node.expr_data.clone(), }) } @@ -2654,7 +2654,7 @@ pub fn expr_has_non_tail_self_call( ); let else_bad = match if_else_branch(texpr.clone()) { Some(e) => expr_has_non_tail_self_call( - e.clone(), + e, fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2696,7 +2696,7 @@ pub fn expr_has_non_tail_self_call( ); let body_bad = match let_body(texpr.clone()) { Some(b) => expr_has_non_tail_self_call( - b.clone(), + b, fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2748,9 +2748,9 @@ pub fn expr_has_non_tail_self_call( } __found }; - let last_bad = match ss.clone().last().cloned() { + let last_bad = match ss.last().cloned() { Some(last_expr) => expr_has_non_tail_self_call( - last_expr.clone(), + last_expr, fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2829,7 +2829,7 @@ pub fn service_config_properties( let auth_prop = match auth { Some(a) => Rc::new(vec![make_field_init_node( "svc_auth".to_string(), - a.clone(), + a, zero_span.clone(), zero_span.clone(), )]), @@ -2838,7 +2838,7 @@ pub fn service_config_properties( let auth_input_prop = match auth_input { Some(ai) => Rc::new(vec![make_field_init_node( "svc_auth_input".to_string(), - ai.clone(), + ai, zero_span.clone(), zero_span.clone(), )]), @@ -2847,7 +2847,7 @@ pub fn service_config_properties( let auth_source_prop = match auth_source { Some(src) => Rc::new(vec![make_field_init_node( "svc_auth_source".to_string(), - src.clone(), + src, zero_span.clone(), zero_span.clone(), )]), @@ -2865,9 +2865,9 @@ pub fn service_config_properties( let retry_prop = match retry { Some(r) => Rc::new(vec![make_field_init_node( "svc_retry".to_string(), - r.clone(), - zero_span.clone(), + r, zero_span.clone(), + zero_span, )]), None => Rc::new(vec![]), }; @@ -3048,7 +3048,7 @@ pub fn import_node( } pub fn import_is_all(n: Rc) -> bool { - (n.body.clone() != None) + ((*n.body).clone() != None) } pub fn import_specific_names_at( @@ -3402,7 +3402,7 @@ pub fn build_newline_index(file: String, source: String) -> Rc { Rc::new(NewlineIndex { file: file, offsets: offsets, - char_codes: char_codes.clone(), + char_codes: char_codes, }) } } @@ -3434,13 +3434,13 @@ pub fn byte_to_line_col(index: Rc, offset: i64) -> LineCol { .get((line.clone() - 2) as usize) .cloned() { - Some(o) => (o.clone() + 1), + Some(o) => (o + 1), None => 0, } }; - let col = ((clamped.clone() - line_start) + 1); + let col = ((clamped - line_start) + 1); LineCol { - line: line.clone(), + line: line, col: col, } } @@ -3468,8 +3468,8 @@ pub fn source_line_at(index: Rc, line: i64) -> String { .get((line.clone() - 1) as usize) .cloned() { - Some(o) => o.clone(), - None => src_len.clone(), + Some(o) => o, + None => src_len, }; v1_rt::chars_to_string(&index.char_codes.clone(), line_start, line_end) } @@ -3508,7 +3508,7 @@ pub fn intern(table: Rc, s: String) -> Rc { match v1_rt::map_get(&table.index.clone(), s.clone()) { Some(id) => Rc::new(InternResult { table: table.clone(), - id: id.clone(), + id: id, }), None => { let id = table.next_id.clone(); @@ -3518,7 +3518,7 @@ pub fn intern(table: Rc, s: String) -> Rc { index: v1_rt::rc_map_insert(table.index.clone(), s.clone(), id.clone()), next_id: (id.clone() + 1), }), - id: id.clone(), + id: id, }) } } @@ -3526,21 +3526,21 @@ pub fn intern(table: Rc, s: String) -> Rc { pub fn intern_str(table: Rc, id: i64) -> String { match table.strings.clone().get(id as usize).cloned() { - Some(s) => s.clone(), + Some(s) => s, None => "".to_string(), } } pub fn intern_find(table: Rc, s: String) -> Option { match v1_rt::map_get(&table.index.clone(), s) { - Some(id) => Some(id.clone()), + Some(id) => Some(id), None => None, } } pub fn intern_find_or_empty(table: Rc, s: String) -> i64 { match v1_rt::map_get(&table.index.clone(), s) { - Some(id) => id.clone(), + Some(id) => id, None => 0, } } @@ -3594,16 +3594,16 @@ pub fn with_optional_cardinality(n: Rc) -> Rc { children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: Cardinality::CardOptional, uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), }) } @@ -3617,16 +3617,16 @@ pub fn with_required_cardinality(n: Rc) -> Rc { children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: n.inferred.clone(), + inferred: (*n.inferred).clone(), return_cardinality: Cardinality::Required, uses: n.uses.clone(), - body: n.body.clone(), - transport: n.transport.clone(), + body: (*n.body).clone(), + transport: (*n.transport).clone(), properties: n.properties.clone(), - type_annotation: n.type_annotation.clone(), + type_annotation: (*n.type_annotation).clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: n.match_pattern.clone(), + match_pattern: (*n.match_pattern).clone(), expr_data: n.expr_data.clone(), }) } From 7bde873db5ec055cc7d32213e7b6b5e404a26bd9 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:04:37 +0000 Subject: [PATCH 13/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/extdeps_cargo.rs | 14 +- src/v1/stage0/src/extdeps_cargo_version.rs | 6 +- .../stage0/src/extdeps_languages_go_types.rs | 2 +- .../src/extdeps_languages_python_types.rs | 2 +- .../stage0/src/extdeps_languages_rust_emit.rs | 4 +- src/v1/stage0/src/extdeps_uri.rs | 2 +- src/v1/stage0/src/extdeps_uri_path.rs | 29 +- src/v1/stage0/src/extdeps_version_semver.rs | 18 +- src/v1/stage0/src/std_computation.rs | 51 +- src/v1/stage0/src/std_effects.rs | 72 +- src/v1/stage0/src/std_graph.rs | 9 +- src/v1/stage0/src/std_http_path.rs | 42 +- src/v1/stage0/src/std_induction.rs | 123 ++- src/v1/stage0/src/std_integer.rs | 38 +- src/v1/stage0/src/std_logic.rs | 5 + src/v1/stage0/src/std_measure.rs | 158 ++- src/v1/stage0/src/std_nat.rs | 8 +- src/v1/stage0/src/std_realization_schedule.rs | 90 +- src/v1/stage0/src/std_termination.rs | 18 +- src/v1/stage0/src/std_types.rs | 4 +- src/v1/stage0/src/v1_compiler_compile.rs | 30 +- src/v1/stage0/src/v1_compiler_complexity.rs | 254 ++--- src/v1/stage0/src/v1_compiler_emit.rs | 76 +- .../src/v1_compiler_emit_core_support.rs | 26 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 26 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 28 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 366 +++---- src/v1/stage0/src/v1_compiler_infer.rs | 964 +++++++++--------- src/v1/stage0/src/v1_compiler_infer_access.rs | 4 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 14 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 14 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 38 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 16 +- .../stage0/src/v1_compiler_infer_patterns.rs | 18 +- .../stage0/src/v1_compiler_infer_resolve.rs | 392 +++---- .../stage0/src/v1_compiler_infer_service.rs | 6 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 18 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 148 +-- src/v1/stage0/src/v1_compiler_normalize.rs | 12 +- src/v1/stage0/src/v1_compiler_ownership.rs | 4 +- src/v1/stage0/src/v1_compiler_parse.rs | 326 +++--- src/v1/stage0/src/v1_compiler_resolve.rs | 2 +- src/v1/stage0/src/v1_std_core.rs | 258 ++--- 44 files changed, 1837 insertions(+), 1902 deletions(-) diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index f9572bb101d..3de394df2a6 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -64,14 +64,14 @@ pub fn default_rust_edition() -> RustEdition { CACHED.with(|c: &RustEdition| c.clone()) } -pub fn min_cargo_version() -> SemVerConstraint { +pub fn min_cargo_version() -> CargoToolVersionFloor { thread_local! { - static CACHED: SemVerConstraint = { + static CACHED: CargoToolVersionFloor = { serde_json::from_value(serde_json::json!(">= 1.56")) .expect("valid data definition") }; } - CACHED.with(|c: &SemVerConstraint| c.clone()) + CACHED.with(|c: &CargoToolVersionFloor| c.clone()) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -139,7 +139,7 @@ pub fn cargo_target_source_path( segments: Rc::new(vec![ "src".to_string(), "bin".to_string(), - v1_rt::concat(name, ".rs".to_string()), + v1_rt::concat(name.clone(), ".rs".to_string()), ]), }) } @@ -147,19 +147,19 @@ pub fn cargo_target_source_path( CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "tests".to_string(), - v1_rt::concat(name, ".rs".to_string()), + v1_rt::concat(name.clone(), ".rs".to_string()), ]), }), CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "examples".to_string(), - v1_rt::concat(name, ".rs".to_string()), + v1_rt::concat(name.clone(), ".rs".to_string()), ]), }), CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { segments: Rc::new(vec![ "benches".to_string(), - v1_rt::concat(name, ".rs".to_string()), + v1_rt::concat(name.clone(), ".rs".to_string()), ]), }), } diff --git a/src/v1/stage0/src/extdeps_cargo_version.rs b/src/v1/stage0/src/extdeps_cargo_version.rs index 8457d1c1876..ecec54e6a94 100644 --- a/src/v1/stage0/src/extdeps_cargo_version.rs +++ b/src/v1/stage0/src/extdeps_cargo_version.rs @@ -28,11 +28,11 @@ pub fn extdeps_external_authority_anchor() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub type CargoPackageVersion = VersionIdentity; +pub type CargoPackageVersion = SemVerIdentity; -pub type CargoVersionRequirement = VersionConstraint; +pub type CargoVersionRequirement = SemVerConstraint; -pub type CargoToolVersionFloor = VersionConstraint; +pub type CargoToolVersionFloor = SemVerConstraint; pub fn default_stage0_package_version() -> String { thread_local! { diff --git a/src/v1/stage0/src/extdeps_languages_go_types.rs b/src/v1/stage0/src/extdeps_languages_go_types.rs index 699cea85247..b4715e2dbde 100644 --- a/src/v1/stage0/src/extdeps_languages_go_types.rs +++ b/src/v1/stage0/src/extdeps_languages_go_types.rs @@ -4,7 +4,7 @@ pub use crate::extdeps_external_authority::ExternalAuthority; use crate::extdeps_uri::UriScheme::Https; pub use crate::extdeps_uri::{Uri, UriScheme}; -pub use crate::std_coercion::{CallableRepr, CastRule, CastSyntax, InhabitantDecl, TypeCheckpoint}; +pub use crate::std_coercion::{CallableRepr, CastSyntax, InhabitantDecl, TypeCheckpoint}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index b4c3a4195fa..f64787e8873 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -5,7 +5,7 @@ use self::PythonTypeKind::*; pub use crate::extdeps_external_authority::ExternalAuthority; use crate::extdeps_uri::UriScheme::Https; pub use crate::extdeps_uri::{Uri, UriScheme}; -pub use crate::std_coercion::{CallableRepr, CastRule, CastSyntax, InhabitantDecl, TypeCheckpoint}; +pub use crate::std_coercion::{CallableRepr, CastSyntax, InhabitantDecl, TypeCheckpoint}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 9ace4c79b53..328ecc12d3d 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -536,8 +536,8 @@ pub fn is_rt_function(name: String) -> bool { pub fn rt_bridge_name(name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), name.clone()) { - Some(bridge) => bridge, - None => name, + Some(bridge) => bridge.clone(), + None => name.clone(), } } diff --git a/src/v1/stage0/src/extdeps_uri.rs b/src/v1/stage0/src/extdeps_uri.rs index 41675e15268..a60e44657d0 100644 --- a/src/v1/stage0/src/extdeps_uri.rs +++ b/src/v1/stage0/src/extdeps_uri.rs @@ -138,7 +138,7 @@ pub fn parse_href_scheme(url: String) -> Rc { }) } else { if (v1_rt::starts_with(s.clone(), "mailto:".to_string()) - || v1_rt::starts_with(s, "MAILTO:".to_string())) + || v1_rt::starts_with(s.clone(), "MAILTO:".to_string())) { Rc::new(ParsedHrefScheme::HrefScheme { scheme: UriScheme::Mailto, diff --git a/src/v1/stage0/src/extdeps_uri_path.rs b/src/v1/stage0/src/extdeps_uri_path.rs index 2a4214c593b..37d17b8ee15 100644 --- a/src/v1/stage0/src/extdeps_uri_path.rs +++ b/src/v1/stage0/src/extdeps_uri_path.rs @@ -88,8 +88,8 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let after_open = match before_and_rest.get(1 as usize).cloned() { - Some(r) => r, + let after_open = match before_and_rest.clone().get(1 as usize).cloned() { + Some(r) => r.clone(), None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -112,7 +112,7 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }); } let param_name = match name_and_suffix.clone().first().cloned() { - Some(p) => p, + Some(p) => p.clone(), None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -121,8 +121,8 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let suffix = match name_and_suffix.get(1 as usize).cloned() { - Some(s) => s, + let suffix = match name_and_suffix.clone().get(1 as usize).cloned() { + Some(s) => s.clone(), None => { return Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -131,7 +131,9 @@ pub fn parse_segment_tokens(seg: String) -> Rc { } }; let prefix_tokens = if (prefix.clone() != "".to_string()) { - Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: prefix })]) + Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { + text: prefix.clone(), + })]) } else { Rc::new(vec![]) }; @@ -149,9 +151,9 @@ pub fn parse_segment_tokens(seg: String) -> Rc { } else { Rc::new(vec![]) }; - if (((param_name == "".to_string()) + if (((param_name.clone() == "".to_string()) || v1_rt::contains(suffix.clone(), "{".to_string())) - || v1_rt::contains(suffix, "}".to_string())) + || v1_rt::contains(suffix.clone(), "}".to_string())) { Rc::new(PathSegmentTokensResult::MalformedPathSegment { segment: seg.clone(), @@ -180,7 +182,7 @@ pub fn parse_path_template(raw: String) -> Rc { .first() .cloned() { - Some(p) => p, + Some(p) => p.clone(), None => raw.clone(), }; let segments = Rc::new({ @@ -206,15 +208,15 @@ pub fn parse_path_template(raw: String) -> Rc { tokens: Rc::new(vec![]), }), }), - Some(first_seg) => match (*parse_segment_tokens(first_seg)).clone() { + Some(first_seg) => match (*parse_segment_tokens(first_seg.clone())).clone() { PathSegmentTokensResult::MalformedPathSegment { segment: s, reason: r, .. } => Rc::new(PathTemplateParseResult::MalformedPathTemplate { raw: raw.clone(), - segment: s, - reason: r, + segment: s.clone(), + reason: r.clone(), }), PathSegmentTokensResult::ParsedSegmentTokens { tokens: first_tokens, @@ -222,6 +224,7 @@ pub fn parse_path_template(raw: String) -> Rc { } => { let parsed = Rc::new( segments + .clone() .iter() .cloned() .skip(1 as usize) @@ -232,7 +235,7 @@ pub fn parse_path_template(raw: String) -> Rc { .fold( Rc::new(PathTemplateParseResult::ParsedPathTemplate { template: Rc::new(PathTemplate { - tokens: first_tokens, + tokens: first_tokens.clone(), }), }), |acc: Rc, seg: String| match (*acc.clone()).clone() diff --git a/src/v1/stage0/src/extdeps_version_semver.rs b/src/v1/stage0/src/extdeps_version_semver.rs index 8802a372920..03bc8938a22 100644 --- a/src/v1/stage0/src/extdeps_version_semver.rs +++ b/src/v1/stage0/src/extdeps_version_semver.rs @@ -55,7 +55,7 @@ pub struct SemVerVersion { pub build: Rc>>, } -pub fn semver_compare_non_negative_int(a: Nat, b: Nat) -> Ordering { +pub fn semver_compare_non_negative_int(a: NonNegativeInt, b: NonNegativeInt) -> Ordering { nat_compare(a, b) } @@ -63,7 +63,7 @@ pub fn semver_compare_identifier(a: Rc, b: Rc match (*b).clone() { SemVerIdentifier::SemVerNumericIdentifier { value: bv, .. } => { - semver_compare_non_negative_int(av, bv) + semver_compare_non_negative_int(av.clone(), bv.clone()) } SemVerIdentifier::SemVerAlphanumericIdentifier { label: _, .. } => Ordering::Less, }, @@ -73,7 +73,7 @@ pub fn semver_compare_identifier(a: Rc, b: Rc bl) { + if (al.clone() > bl.clone()) { Ordering::Greater } else { Ordering::Equal @@ -142,20 +142,20 @@ pub fn semver_compare(a: Rc, b: Rc) -> Ordering { Ordering::Equal => { semver_compare_pre_release(a.pre_release.clone(), b.pre_release.clone()) } - other => other, + other => other.clone(), } } - other => other, + other => other.clone(), } } - other => other, + other => other.clone(), } } pub fn semver_identifier_label(id: Rc) -> String { match (*id).clone() { - SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v), - SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s, + SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v.clone()), + SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s.clone(), } } @@ -212,7 +212,7 @@ pub fn semver_identity_compare(a: NonEmptyStr, b: NonEmptyStr) -> Ordering { if (a.clone() == b.clone()) { Ordering::Equal } else { - if (a < b) { + if (a.clone() < b.clone()) { Ordering::Less } else { Ordering::Greater diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index f8b02f3de4f..320be281a1c 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -30,22 +30,13 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn subtree_size_rename_marker() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c) collision fix: SizeBound's tree bound arm was named TreeSize, colliding with RankingDimension.TreeSize (std.termination) in this module's own scope once one arm name may have only one owner. Renamed to SubtreeSize — the more precise fact: a tree-descent bound measures the shrinking SUBTREE consumed per step. RankingDimension.TreeSize (the ranking-dimension taxonomy, ~12 sites in v1.complexity/induction) keeps the shared name.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeBound { CollectionSize { param: String }, ParserStreamSize { witness: String }, WorklistDrainSize { element: String }, - SubtreeSize { param: String }, + TreeSize { param: String }, ArithmeticParam { param: String }, ExplicitCountZero, ExplicitCountPositive { steps: Rc }, @@ -53,7 +44,7 @@ pub enum SizeBound { } pub fn tree_size_bound(param: String) -> Rc { - Rc::new(SizeBound::SubtreeSize { param: param }) + Rc::new(SizeBound::TreeSize { param: param }) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -116,7 +107,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { match (*pattern).clone() { CallPattern::ChildAccessorCall { accessor: a, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Descend, - bound: Rc::new(SizeBound::SubtreeSize { param: a }), + bound: Rc::new(SizeBound::TreeSize { param: a.clone() }), evidence: DescentEvidence::Strict, factor: None, }), @@ -126,9 +117,9 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::CollectionSize { param: c }), + bound: Rc::new(SizeBound::CollectionSize { param: c.clone() }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p })), + factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p.clone() })), }), CallPattern::ArithmeticSubtractCall { steps: p, @@ -136,9 +127,9 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: r }), + bound: Rc::new(SizeBound::ArithmeticParam { param: r.clone() }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p })), + factor: Some(Rc::new(ShrinkFactor::ConstantShrink { steps: p.clone() })), }), CallPattern::ArithmeticDivideCall { divisor: d, @@ -146,19 +137,21 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: r }), + bound: Rc::new(SizeBound::ArithmeticParam { param: r.clone() }), evidence: DescentEvidence::Strict, - factor: Some(Rc::new(ShrinkFactor::ProportionalShrink { divisor: d })), + factor: Some(Rc::new(ShrinkFactor::ProportionalShrink { + divisor: d.clone(), + })), }), CallPattern::ParserAdvanceCall { witness: w, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::ParserStreamSize { witness: w }), + bound: Rc::new(SizeBound::ParserStreamSize { witness: w.clone() }), evidence: DescentEvidence::Strict, factor: None, }), CallPattern::WorklistDrainCall { element: e, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::WorklistDrainSize { element: e }), + bound: Rc::new(SizeBound::WorklistDrainSize { element: e.clone() }), evidence: DescentEvidence::Strict, factor: None, }), @@ -167,7 +160,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, - bound: Rc::new(SizeBound::CollectionSize { param: oc }), + bound: Rc::new(SizeBound::CollectionSize { param: oc.clone() }), evidence: DescentEvidence::NonIncreasing, factor: None, }), @@ -182,11 +175,11 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { pub fn size_bound_param(bound: Rc) -> Option { match (*bound).clone() { - SizeBound::SubtreeSize { param: p, .. } => Some(p), - SizeBound::CollectionSize { param: p, .. } => Some(p), - SizeBound::ParserStreamSize { witness: w, .. } => Some(w), - SizeBound::WorklistDrainSize { element: e, .. } => Some(e), - SizeBound::ArithmeticParam { param: p, .. } => Some(p), + SizeBound::TreeSize { param: p, .. } => Some(p.clone()), + SizeBound::CollectionSize { param: p, .. } => Some(p.clone()), + SizeBound::ParserStreamSize { witness: w, .. } => Some(w.clone()), + SizeBound::WorklistDrainSize { element: e, .. } => Some(e.clone()), + SizeBound::ArithmeticParam { param: p, .. } => Some(p.clone()), SizeBound::ExplicitCountZero => None, SizeBound::ExplicitCountPositive { steps: _, .. } => None, SizeBound::Forever => None, @@ -209,7 +202,9 @@ pub fn forever_iteration_bound() -> i64 { pub fn constant_bound_value(bound: Rc) -> Option { match (*bound).clone() { SizeBound::ExplicitCountZero => Some(0), - SizeBound::ExplicitCountPositive { steps: s, .. } => Some(positive_descent_count(s)), + SizeBound::ExplicitCountPositive { steps: s, .. } => { + Some(positive_descent_count(s.clone())) + } SizeBound::Forever => Some(forever_iteration_bound()), _ => None, } @@ -242,7 +237,7 @@ pub fn type_iteration_dimension(type_name: String) -> Option Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { - Some(p) => algebra_profile_to_dimension(p), + Some(p) => algebra_profile_to_dimension(p.clone()), None => None, } } diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index 2b6069dd71f..c882f608192 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -84,7 +84,7 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { EffectShape::ReadEffect => true, EffectShape::UpsertEffect { .. } => true, EffectShape::DeleteEffect { .. } => true, - EffectShape::CreateEffect { cause: cause, .. } => match (*cause).clone() { + EffectShape::CreateEffect { cause: cause, .. } => match (*cause.clone()).clone() { CreateCause::CreateIfAbsent { key_source: key_source, .. @@ -98,15 +98,15 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { pub fn key_source_eq(left: Rc, right: Rc) -> bool { match (*left).clone() { KeySource::PathParam { param: pa, .. } => match (*right).clone() { - KeySource::PathParam { param: pb, .. } => (pa == pb), + KeySource::PathParam { param: pb, .. } => (pa.clone() == pb.clone()), _ => false, }, KeySource::InputField { field: fa, .. } => match (*right).clone() { - KeySource::InputField { field: fb, .. } => (fa == fb), + KeySource::InputField { field: fb, .. } => (fa.clone() == fb.clone()), _ => false, }, KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { - KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa, fb), + KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), _ => false, }, } @@ -114,7 +114,7 @@ pub fn key_source_eq(left: Rc, right: Rc) -> bool { pub fn create_effect_is_dedupable(shape: Rc) -> bool { match (*shape).clone() { - EffectShape::CreateEffect { cause: cause, .. } => match (*cause).clone() { + EffectShape::CreateEffect { cause: cause, .. } => match (*cause.clone()).clone() { CreateCause::CreateIfAbsent { key_source: key_source, .. @@ -127,12 +127,16 @@ pub fn create_effect_is_dedupable(shape: Rc) -> bool { pub fn create_double_init_collapsible(a: Rc, b: Rc) -> bool { match (*a).clone() { - EffectShape::CreateEffect { cause: cause_a, .. } => match (*cause_a).clone() { + EffectShape::CreateEffect { cause: cause_a, .. } => match (*cause_a.clone()).clone() { CreateCause::CreateIfAbsent { key_source: ka, .. } => match (*b).clone() { - EffectShape::CreateEffect { cause: cause_b, .. } => match (*cause_b).clone() { - CreateCause::CreateIfAbsent { key_source: kb, .. } => key_source_eq(ka, kb), - CreateCause::PostAlways => false, - }, + EffectShape::CreateEffect { cause: cause_b, .. } => { + match (*cause_b.clone()).clone() { + CreateCause::CreateIfAbsent { key_source: kb, .. } => { + key_source_eq(ka.clone(), kb.clone()) + } + CreateCause::PostAlways => false, + } + } _ => false, }, CreateCause::PostAlways => false, @@ -167,28 +171,26 @@ impl CompositionVerdict { } pub fn compose_effects(effects: Rc>>) -> Rc { - effects.iter().cloned().fold( - Rc::new(CompositionVerdict::IdempotentComposition), - |acc: Rc, e: Rc| match (*acc.clone()).clone() { - CompositionVerdict::BrokenBy { - first_breaker: breaker, - .. - } => acc.clone(), - CompositionVerdict::IdempotentComposition => match (*e.evidence.clone()).clone() { - IdempotencyEvidence::NonIdempotent { shape, reason, .. } => { - Rc::new(CompositionVerdict::BrokenBy { - first_breaker: e.clone(), - }) - } - IdempotencyEvidence::LatticeEffect { shape: shape, .. } => { - Rc::new(CompositionVerdict::IdempotentComposition) - } - IdempotencyEvidence::IdentityEffect => { - Rc::new(CompositionVerdict::IdempotentComposition) + { + let non_idempotent = Rc::new({ + let mut __result = Vec::new(); + for e in effects.iter().cloned() { + if match (*e.evidence.clone()).clone() { + IdempotencyEvidence::NonIdempotent { .. } => true, + _ => false, + } { + __result.push(e); } - }, - }, - ) + } + __result + }); + match non_idempotent.first().cloned() { + Some(op) => Rc::new(CompositionVerdict::BrokenBy { + first_breaker: op.clone(), + }), + None => Rc::new(CompositionVerdict::IdempotentComposition), + } + } } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -224,7 +226,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::DeleteEffect { - key_source: Rc::new(KeySource::PathParam { param: p }), + key_source: Rc::new(KeySource::PathParam { param: p.clone() }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -232,7 +234,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::UpsertEffect { - key_source: Rc::new(KeySource::PathParam { param: p }), + key_source: Rc::new(KeySource::PathParam { param: p.clone() }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -240,7 +242,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc match last_path_param(path) { Some(p) => Rc::new(EffectShape::UpsertEffect { - key_source: Rc::new(KeySource::PathParam { param: p }), + key_source: Rc::new(KeySource::PathParam { param: p.clone() }), }), None => Rc::new(EffectShape::CreateEffect { cause: Rc::new(CreateCause::PostAlways), @@ -319,7 +321,7 @@ pub fn check_modifier_vs_derivation( }), } } else { - if (!declared_idempotent.clone() && derived_idempotent) { + if (!declared_idempotent.clone() && derived_idempotent.clone()) { match (*op.shape.clone()).clone() { EffectShape::CreateEffect { ref cause, .. } => { let CreateCause::CreateIfAbsent { diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index a719554dcf6..5d20b69f286 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -151,7 +151,7 @@ pub fn dfs_finish_order( { let next_visited = v1_rt::rc_set_insert(acc.visited.clone(), node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { - Some(ns) => ns, + Some(ns) => ns.clone(), None => Rc::new(vec![]), }; let explored = neighbors.iter().cloned().fold( @@ -185,7 +185,7 @@ pub fn dfs_collect_component( let next_visited = v1_rt::rc_set_insert(acc.visited.clone(), node.clone()); let next_members = v1_rt::rc_list_push(acc.members.clone(), node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { - Some(ns) => ns, + Some(ns) => ns.clone(), None => Rc::new(vec![]), }; neighbors.iter().cloned().fold( @@ -314,8 +314,9 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> } __result }); - let nd_graph = build_call_graph_from_proof_edges(members.clone(), non_descending); - (graph_has_multi_node_scc(members, nd_graph) == false) + let nd_graph = + build_call_graph_from_proof_edges(members.clone(), non_descending.clone()); + (graph_has_multi_node_scc(members.clone(), nd_graph) == false) } } } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index 4d860a887d2..4a36b0a2aa3 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -54,49 +54,11 @@ pub fn last_path_param(template: Rc) -> Option { __result }); match params.last().cloned() { - Some(tok) => match (*tok).clone() { - UrlPathToken::ParamToken { name: n, .. } => Some(n), + Some(tok) => match (*tok.clone()).clone() { + UrlPathToken::ParamToken { name: n, .. } => Some(n.clone()), UrlPathToken::LiteralToken { .. } => None, }, None => None, } } } - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct PathParamBinding { - pub name: String, - pub value: String, -} - -pub fn path_param_value(params: Rc>>, name: String) -> String { - params.iter().cloned().fold( - "".to_string(), - |acc: String, binding: Rc| { - if (acc.clone() != "".to_string()) { - acc.clone() - } else { - if (binding.name.clone() == name.clone()) { - binding.value.clone() - } else { - acc.clone() - } - } - }, - ) -} - -pub fn render_path_template( - template: Rc, - params: Rc>>, -) -> String { - template.tokens.clone().iter().cloned().fold( - "".to_string(), - |acc: String, tok: Rc| match (*tok.clone()).clone() { - UrlPathToken::LiteralToken { text: t, .. } => v1_rt::concat(acc.clone(), t.clone()), - UrlPathToken::ParamToken { name: n, .. } => { - v1_rt::concat(acc.clone(), path_param_value(params.clone(), n.clone())) - } - }, - ) -} diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 9545f3dba2d..a4a5073c4ad 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -121,13 +121,13 @@ pub enum SubValueRelation { pub fn sub_value_to_evidence(relation: Rc) -> DescentEvidence { match (*relation).clone() { - SubValueRelation::StrictSubValue { factor: f, .. } => match (*f).clone() { + SubValueRelation::StrictSubValue { factor: f, .. } => match (*f.clone()).clone() { ShrinkFactor::UnitShrink => DescentEvidence::Strict, ShrinkFactor::ConstantShrink { steps: _, .. } => DescentEvidence::Strict, ShrinkFactor::ProportionalShrink { divisor: _, .. } => DescentEvidence::Strict, }, SubValueRelation::IteratedSubValue { field: _, .. } => DescentEvidence::Strict, - SubValueRelation::ArithmeticDescent { factor: f, .. } => match (*f).clone() { + SubValueRelation::ArithmeticDescent { factor: f, .. } => match (*f.clone()).clone() { ShrinkFactor::UnitShrink => DescentEvidence::Strict, ShrinkFactor::ConstantShrink { steps: _, .. } => DescentEvidence::Strict, ShrinkFactor::ProportionalShrink { divisor: _, .. } => DescentEvidence::Strict, @@ -148,13 +148,13 @@ pub fn shrink_factor_eq(a: Rc, b: Rc) -> bool { }, ShrinkFactor::ConstantShrink { steps: sa, .. } => match (*b).clone() { ShrinkFactor::ConstantShrink { steps: sb, .. } => { - (positive_descent_count(sa) == positive_descent_count(sb)) + (positive_descent_count(sa.clone()) == positive_descent_count(sb.clone())) } _ => false, }, ShrinkFactor::ProportionalShrink { divisor: da, .. } => match (*b).clone() { ShrinkFactor::ProportionalShrink { divisor: db, .. } => { - (proportional_divisor_to_int(da) == proportional_divisor_to_int(db)) + (proportional_divisor_to_int(da.clone()) == proportional_divisor_to_int(db.clone())) } _ => false, }, @@ -172,11 +172,16 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) field: fb, factor: fac_b, .. - } => (inductive_field_eq(fa, fb) && shrink_factor_eq(fac_a, fac_b)), + } => { + (inductive_field_eq(fa.clone(), fb.clone()) + && shrink_factor_eq(fac_a.clone(), fac_b.clone())) + } _ => false, }, SubValueRelation::IteratedSubValue { field: fa, .. } => match (*b).clone() { - SubValueRelation::IteratedSubValue { field: fb, .. } => inductive_field_eq(fa, fb), + SubValueRelation::IteratedSubValue { field: fb, .. } => { + inductive_field_eq(fa.clone(), fb.clone()) + } _ => false, }, SubValueRelation::ArithmeticDescent { @@ -188,7 +193,7 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) param: pb, factor: fac_b, .. - } => ((pa == pb) && shrink_factor_eq(fac_a, fac_b)), + } => ((pa.clone() == pb.clone()) && shrink_factor_eq(fac_a.clone(), fac_b.clone())), _ => false, }, SubValueRelation::PreservedValue => match (*b).clone() { @@ -239,7 +244,7 @@ pub fn sub_value_level(r: Rc) -> i64 { pub fn meet_sub_value(a: Rc, b: Rc) -> Rc { if sub_value_structural_eq(a.clone(), b.clone()) { - a + a.clone() } else { { let la = sub_value_level(a.clone()); @@ -250,16 +255,16 @@ pub fn meet_sub_value(a: Rc, b: Rc) -> Rc, b: Rc) -> Rc, b: Rc) -> Rc { if sub_value_structural_eq(a.clone(), b.clone()) { - a + a.clone() } else { { let la = sub_value_level(a.clone()); let lb = sub_value_level(b.clone()); if (la.clone() == 0) { - b + b.clone() } else { if (lb.clone() == 0) { - a + a.clone() } else { if ((la.clone() == 4) || (lb.clone() == 4)) { Rc::new(SubValueRelation::MixedTop) } else { - if (la == 1) { - b + if (la.clone() == 1) { + b.clone() } else { - if (lb == 1) { - a + if (lb.clone() == 1) { + a.clone() } else { - if (is_strict_style_structural(a) && is_strict_style_structural(b)) + if (is_strict_style_structural(a.clone()) + && is_strict_style_structural(b.clone())) { Rc::new(SubValueRelation::StrictAxisErased) } else { @@ -354,17 +360,17 @@ pub fn compose_sub_value_relations( _ => Rc::new(SubValueRelation::MixedTop), }, SubValueRelation::StrictSubValue { .. } => match (*arg_rel).clone() { - SubValueRelation::PreservedValue => callee_rel, + SubValueRelation::PreservedValue => callee_rel.clone(), SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::StrictSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f, + field: f.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), }) } SubValueRelation::IteratedSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f, + field: f.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), }) } @@ -376,17 +382,17 @@ pub fn compose_sub_value_relations( SubValueRelation::MixedTop => Rc::new(SubValueRelation::MixedTop), }, SubValueRelation::IteratedSubValue { field: _, .. } => match (*arg_rel).clone() { - SubValueRelation::PreservedValue => callee_rel, + SubValueRelation::PreservedValue => callee_rel.clone(), SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::StrictSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f, + field: f.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), }) } SubValueRelation::IteratedSubValue { field: f, .. } => { Rc::new(SubValueRelation::StrictSubValue { - field: f, + field: f.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), }) } @@ -403,8 +409,8 @@ pub fn compose_sub_value_relations( .. } => match (*arg_rel).clone() { SubValueRelation::PreservedValue => Rc::new(SubValueRelation::ArithmeticDescent { - param: p, - factor: f, + param: p.clone(), + factor: f.clone(), }), SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), SubValueRelation::NonIncreasingValue => Rc::new(SubValueRelation::NonIncreasingValue), @@ -431,22 +437,22 @@ pub fn sub_value_to_call_pattern(relation: Rc) -> Option match (*f).clone() { + } => match (*f.clone()).clone() { ShrinkFactor::ConstantShrink { steps: steps, .. } => { Some(Rc::new(CallPattern::ArithmeticSubtractCall { - steps: steps, - ring_param: p, + steps: steps.clone(), + ring_param: p.clone(), })) } ShrinkFactor::ProportionalShrink { divisor: d, .. } => { Some(Rc::new(CallPattern::ArithmeticDivideCall { - divisor: d, - ring_param: p, + divisor: d.clone(), + ring_param: p.clone(), })) } ShrinkFactor::UnitShrink => Some(Rc::new(CallPattern::ArithmeticSubtractCall { steps: Rc::new(PositiveDescentAmount::OneStep), - ring_param: p, + ring_param: p.clone(), })), }, SubValueRelation::PreservedValue => Some(Rc::new(CallPattern::SameArgumentCall)), @@ -467,7 +473,7 @@ pub fn sub_value_to_lowering_target(relation: Rc) -> Option Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, @@ -483,9 +489,9 @@ pub fn sub_value_to_lowering_target(relation: Rc) -> Option Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, - bound: Rc::new(SizeBound::ArithmeticParam { param: p }), + bound: Rc::new(SizeBound::ArithmeticParam { param: p.clone() }), evidence: DescentEvidence::Strict, - factor: Some(fac), + factor: Some(fac.clone()), })), SubValueRelation::PreservedValue => Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, @@ -618,7 +624,9 @@ pub fn cost_poly(param: String, degree: i64) -> Rc { Some(deg) => Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { param: param, - exponent: Rc::new(PolynomialExponent::IntegerExpPos { degree: deg }), + exponent: Rc::new(PolynomialExponent::IntegerExpPos { + degree: deg.clone(), + }), }), }), None => Rc::new(CostBound::ErrorBound), @@ -637,7 +645,7 @@ pub fn cost_root(param: String, k: i64) -> Rc { param: param, exponent: Rc::new(PolynomialExponent::FractionExp { numerator: Rc::new(PositiveDescentAmount::OneStep), - root: rw, + root: rw.clone(), }), }), }), @@ -796,7 +804,7 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { if (base.clone() == (0 - 1)) { { let half = (e.clone() / 2); - if ((half.clone() + half) == e) { + if ((half.clone() + half.clone()) == e.clone()) { Some(1) } else { Some((0 - 1)) @@ -804,8 +812,9 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { } } else { match int_pow_bounded(base.clone(), (exp.clone() - 1)) { - Some(prev) => match int_mul_checked(base.clone(), prev) { - Some(prod) => Some(prod), + Some(prev) => match int_mul_checked(base.clone(), prev.clone()) + { + Some(prod) => Some(prod.clone()), None => None, }, None => None, @@ -830,13 +839,13 @@ pub fn ceil_log(base: i64, argument: i64) -> Option { pub fn ceil_log_iter(mut base: i64, mut argument: i64, mut k: i64, mut power: i64) -> Option { loop { if (power.clone() >= argument.clone()) { - break Some(k.clone()); + break Some(k); } else { match int_mul_checked(power.clone(), base.clone()) { None => { break None; } - Some(next_power) => match int_add_checked(k.clone(), 1) { + Some(next_power) => match int_add_checked(k, 1) { None => { break None; } @@ -870,40 +879,42 @@ pub fn master_theorem(form: Rc) -> Rc { if (a.clone() < b_to_d.clone()) { match d_ok.clone() { 0 => Rc::new(CostBound::ConstantBound), - _ => cost_poly(n, d_ok), + _ => cost_poly(n.clone(), d_ok.clone()), } } else { - if (a.clone() == b_to_d) { + if (a.clone() == b_to_d.clone()) { match d_ok.clone() { - 0 => cost_log(n), - _ => match positive_descent_amount_from_positive_int(d_ok) { + 0 => cost_log(n.clone()), + _ => match positive_descent_amount_from_positive_int( + d_ok.clone(), + ) { Some(deg) => Rc::new(CostBound::ProductBound { factors: Rc::new(vec![ Rc::new(AtomicCost::PolyCost { param: n.clone(), exponent: Rc::new( PolynomialExponent::IntegerExpPos { - degree: deg, + degree: deg.clone(), }, ), }), - Rc::new(AtomicCost::LogCost { param: n }), + Rc::new(AtomicCost::LogCost { param: n.clone() }), ]), }), None => Rc::new(CostBound::ErrorBound), }, } } else { - match proportional_divisor_from_int_at_least_two(b) { + match proportional_divisor_from_int_at_least_two(b.clone()) { Some(base_w) => { - match positive_descent_amount_from_positive_int(a) { + match positive_descent_amount_from_positive_int(a.clone()) { Some(arg_w) => Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { - param: n, + param: n.clone(), exponent: Rc::new( PolynomialExponent::LogBasedExp { - base: base_w, - argument: arg_w, + base: base_w.clone(), + argument: arg_w.clone(), }, ), }), @@ -964,7 +975,7 @@ pub fn derive_bound( master_theorem(Rc::new(RecurrenceForm { param: param, branches: branches.clone(), - divisor: proportional_divisor_to_int(d), + divisor: proportional_divisor_to_int(d.clone()), work_exponent: work_exponent.clone(), })) } diff --git a/src/v1/stage0/src/std_integer.rs b/src/v1/stage0/src/std_integer.rs index 63ad6def75c..a17979ff245 100644 --- a/src/v1/stage0/src/std_integer.rs +++ b/src/v1/stage0/src/std_integer.rs @@ -13,30 +13,20 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Int8 = crate::std_machine_constraints::Compose< - Int>, - crate::std_machine_constraints::MachineWidth<()>, ->; +pub type Int8 = + crate::std_machine_constraints::Compose>; -pub type Int16 = crate::std_machine_constraints::Compose< - Int>, - crate::std_machine_constraints::MachineWidth<()>, ->; +pub type Int16 = + crate::std_machine_constraints::Compose>; -pub type Int32 = crate::std_machine_constraints::Compose< - Int>, - crate::std_machine_constraints::MachineWidth<()>, ->; +pub type Int32 = + crate::std_machine_constraints::Compose>; -pub type Int64 = crate::std_machine_constraints::Compose< - Int>, - crate::std_machine_constraints::MachineWidth<()>, ->; +pub type Int64 = + crate::std_machine_constraints::Compose>; -pub type Int128 = crate::std_machine_constraints::Compose< - Int>, - crate::std_machine_constraints::MachineWidth<()>, ->; +pub type Int128 = + crate::std_machine_constraints::Compose>; pub type UInt8 = crate::std_machine_constraints::Compose>; @@ -55,10 +45,10 @@ pub type UInt128 = pub type Int = i64; -pub type UInt = Rc>; +pub type UInt = i64; pub type IntPlatform = crate::std_machine_constraints::Compose< - Int>, + i64, crate::std_machine_constraints::MachineWidth, >; @@ -67,6 +57,6 @@ pub type UIntPlatform = crate::std_machine_constraints::Compose< crate::std_machine_constraints::MachineWidth, >; -pub type NonNegativeInt = Rc>; +pub type NonNegativeInt = i64; -pub type PositiveInt = Rc>; +pub type PositiveInt = Nat; diff --git a/src/v1/stage0/src/std_logic.rs b/src/v1/stage0/src/std_logic.rs index 8a3af0e174a..d0355224cf0 100644 --- a/src/v1/stage0/src/std_logic.rs +++ b/src/v1/stage0/src/std_logic.rs @@ -40,3 +40,8 @@ pub fn classical_or(a: Classical, b: Classical) -> Classical { Classical::False => b, } } + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct True; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct False; diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index 0ff93e2c780..86ab6826f9d 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -86,15 +86,15 @@ pub fn scale_exponent(s: Scale) -> i64 { } } -pub fn gibibyte_scale_factor_bytes() -> Rc> { +pub fn gibibyte_scale_factor_bytes() -> Nat { 1073741824 } -pub fn kibi_factor() -> Rc> { +pub fn kibi_factor() -> Nat { 1024 } -pub fn memory_scale_factor_bytes(s: Scale) -> Rc> { +pub fn memory_scale_factor_bytes(s: Scale) -> Option { match s { Scale::One => Some(1), Scale::Kibi => Some(kibi_factor()), @@ -127,10 +127,10 @@ pub fn measure_count(m: Rc>) -> M { } pub fn measure_scale_fraction_floor( - m: Rc>>>, - num: Rc>, - den: Rc>, -) -> Rc>>> { + m: Rc>, + num: Nat, + den: Nat, +) -> Rc> { Rc::new(Measure { count: if (den.clone() == 0) { den.clone() @@ -142,24 +142,24 @@ pub fn measure_scale_fraction_floor( } pub fn measure_fit_count_floor( - capacity: Rc>>>, - each: Rc>>>, -) -> Rc> { + capacity: Rc>, + each: Rc>, +) -> Nat { { let each_count = each.count.clone(); if (each_count.clone() == 0) { - each_count + each_count.clone() } else { - (capacity.count.clone() / each_count) + (capacity.count.clone() / each_count.clone()) } } } pub fn measure_scale_fraction_ceil( - m: Rc>>>, - num: Rc>, - den: Rc>, -) -> Rc>>> { + m: Rc>, + num: Nat, + den: Nat, +) -> Rc> { Rc::new(Measure { count: if (den.clone() == 0) { (m.count.clone() * num) @@ -171,58 +171,40 @@ pub fn measure_scale_fraction_ceil( } pub fn measure_add( - a: Rc>>>, - b: Rc>>>, -) -> Rc>>> { + a: Rc>, + b: Rc>, +) -> Rc> { Rc::new(Measure { count: (a.count.clone() + b.count.clone()), _phantom: std::marker::PhantomData, }) } -pub fn measure_le( - a: Rc>>>, - b: Rc>>>, -) -> bool { +pub fn measure_le(a: Rc>, b: Rc>) -> bool { (a.count.clone() <= b.count.clone()) } -pub fn time_measure( - count: Rc>, -) -> Rc>>> { +pub fn time_measure(count: Nat) -> Rc> { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub type ByteSize = Rc>>>; +pub type ByteSize = Rc>; -pub type Kibibyte = Rc>>>; +pub type Kibibyte = Rc>; -pub type Mebibyte = Rc>>>; +pub type Gibibyte = Rc>; -pub type Gibibyte = Rc>>>; - -pub fn mebibyte(count: Rc>) -> Mebibyte { - Rc::new(Measure { - count: count, - _phantom: std::marker::PhantomData, - }) -} - -pub fn mebibyte_count(m: Mebibyte) -> Rc> { - measure_count(m) -} - -pub fn gibibyte(count: Rc>) -> Gibibyte { +pub fn gibibyte(count: Nat) -> Gibibyte { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn gibibyte_count(g: Gibibyte) -> Rc> { +pub fn gibibyte_count(g: Gibibyte) -> Nat { measure_count(g) } @@ -230,34 +212,30 @@ pub fn gibibyte_to_byte_size(g: Gibibyte) -> ByteSize { byte_size((gibibyte_count(g) * gibibyte_scale_factor_bytes())) } -pub type BitWidth = Rc>>>; +pub type BitWidth = Rc>; -pub fn bits_per_byte() -> Rc> { +pub fn bits_per_byte() -> Nat { 8 } -pub type Hertz = Rc>>>; +pub type Hertz = Rc>; -pub type HardwareThreadCount = - Rc>>>; +pub type HardwareThreadCount = Rc>; -pub type Millicore = Rc>>>; - -pub type Watt = Rc>>>; +pub type Watt = Rc>; pub type Celsius = Rc>; -pub type RevolutionsPerMinute = - Rc>>>; +pub type RevolutionsPerMinute = Rc>; -pub fn watt(count: Rc>) -> Watt { +pub fn watt(count: Nat) -> Watt { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn watt_count(w: Watt) -> Rc> { +pub fn watt_count(w: Watt) -> Nat { measure_count(w) } @@ -272,150 +250,138 @@ pub fn celsius_count(c: Celsius) -> i64 { measure_count(c) } -pub fn rpm(count: Rc>) -> RevolutionsPerMinute { +pub fn rpm(count: Nat) -> RevolutionsPerMinute { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn rpm_count(r: RevolutionsPerMinute) -> Rc> { +pub fn rpm_count(r: RevolutionsPerMinute) -> Nat { measure_count(r) } -pub type MoneyAmount = - Rc>>>; +pub type MoneyAmount = Rc>; pub type MoneyAmountMicro = MoneyAmount<()>; -pub fn money_amount_micro(count: Rc>) -> MoneyAmountMicro { +pub fn money_amount_micro(count: Nat) -> MoneyAmountMicro { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn money_amount_micro_count(m: MoneyAmountMicro) -> Rc> { +pub fn money_amount_micro_count(m: MoneyAmountMicro) -> Nat { measure_count(m) } -pub fn byte_size(count: Rc>) -> ByteSize { +pub fn byte_size(count: Nat) -> ByteSize { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn byte_size_count(b: ByteSize) -> Rc> { +pub fn byte_size_count(b: ByteSize) -> Nat { measure_count(b) } -pub fn bit_width(count: Rc>) -> BitWidth { +pub fn bit_width(count: Nat) -> BitWidth { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn bit_width_count(b: BitWidth) -> Rc> { +pub fn bit_width_count(b: BitWidth) -> Nat { measure_count(b) } -pub fn hertz(count: Rc>) -> Hertz { +pub fn hertz(count: Nat) -> Hertz { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn hertz_count(h: Hertz) -> Rc> { +pub fn hertz_count(h: Hertz) -> Nat { measure_count(h) } -pub fn hardware_thread_count(count: Rc>) -> HardwareThreadCount { +pub fn hardware_thread_count(count: Nat) -> HardwareThreadCount { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn hardware_thread_count_value(t: HardwareThreadCount) -> Rc> { +pub fn hardware_thread_count_value(t: HardwareThreadCount) -> Nat { measure_count(t) } -pub fn millicore(count: Rc>) -> Millicore { - Rc::new(Measure { - count: count, - _phantom: std::marker::PhantomData, - }) -} - -pub fn millicore_count(m: Millicore) -> Rc> { - measure_count(m) -} - -pub type Bandwidth = Rc>>>; +pub type Bandwidth = Rc>; -pub fn bandwidth(count: Rc>) -> Bandwidth { +pub fn bandwidth(count: Nat) -> Bandwidth { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn bandwidth_count(b: Bandwidth) -> Rc> { +pub fn bandwidth_count(b: Bandwidth) -> Nat { measure_count(b) } -pub type Nanosecond = Rc>>>; +pub type Nanosecond = Rc>; -pub fn nanosecond(count: Rc>) -> Nanosecond { +pub fn nanosecond(count: Nat) -> Nanosecond { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn nanosecond_count(n: Nanosecond) -> Rc> { +pub fn nanosecond_count(n: Nanosecond) -> Nat { measure_count(n) } -pub type Microsecond = Rc>>>; +pub type Microsecond = Rc>; -pub fn microsecond(count: Rc>) -> Microsecond { +pub fn microsecond(count: Nat) -> Microsecond { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn microsecond_count(m: Microsecond) -> Rc> { +pub fn microsecond_count(m: Microsecond) -> Nat { measure_count(m) } -pub type Second = Rc>>>; +pub type Second = Rc>; -pub fn second(count: Rc>) -> Second { +pub fn second(count: Nat) -> Second { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn second_count(s: Second) -> Rc> { +pub fn second_count(s: Second) -> Nat { measure_count(s) } -pub type Percent = Rc>>>; +pub type Percent = Rc>; -pub fn percent(count: Rc>) -> Percent { +pub fn percent(count: Nat) -> Percent { Rc::new(Measure { count: count, _phantom: std::marker::PhantomData, }) } -pub fn percent_count(p: Percent) -> Rc> { +pub fn percent_count(p: Percent) -> Nat { measure_count(p) } diff --git a/src/v1/stage0/src/std_nat.rs b/src/v1/stage0/src/std_nat.rs index c0107cd4739..2a9dd06c755 100644 --- a/src/v1/stage0/src/std_nat.rs +++ b/src/v1/stage0/src/std_nat.rs @@ -29,16 +29,16 @@ pub fn nat_compare(a: Nat, b: Nat) -> Ordering { pub fn nat_max(a: Nat, b: Nat) -> Nat { if (a.clone() > b.clone()) { - a + a.clone() } else { - b + b.clone() } } pub fn nat_min(a: Nat, b: Nat) -> Nat { if (a.clone() < b.clone()) { - a + a.clone() } else { - b + b.clone() } } diff --git a/src/v1/stage0/src/std_realization_schedule.rs b/src/v1/stage0/src/std_realization_schedule.rs index a8f034d228c..bd2ca24e794 100644 --- a/src/v1/stage0/src/std_realization_schedule.rs +++ b/src/v1/stage0/src/std_realization_schedule.rs @@ -36,8 +36,8 @@ pub enum CostBasis { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CostAccount { pub time: Rc>, - pub space: ByteSize, - pub power: Watt, + pub space: Box, + pub power: Box, pub basis: CostBasis, pub _phantom: std::marker::PhantomData, } @@ -45,28 +45,24 @@ pub struct CostAccount { pub fn cost_account_predicted_zero() -> Rc> { Rc::new(CostAccount { time: time_measure(0), - space: byte_size(0), - power: watt(0), + space: Box::new(byte_size(0)), + power: Box::new(watt(0)), basis: CostBasis::Predicted, _phantom: std::marker::PhantomData, }) } -pub fn cost_account_measured( - time: Rc>>>, -) -> Rc> { +pub fn cost_account_measured(time: Rc>) -> Rc> { Rc::new(CostAccount { time: time, - space: byte_size(0), - power: watt(0), + space: Box::new(byte_size(0)), + power: Box::new(watt(0)), basis: CostBasis::Measured, _phantom: std::marker::PhantomData, }) } -pub fn cost_account_time_count( - account: Rc>, -) -> Rc> { +pub fn cost_account_time_count(account: Rc>) -> Nat { measure_count(account.time.clone()) } @@ -83,7 +79,7 @@ pub struct ScheduleWitnessEntry { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RunnableMemoryPeak { - pub predicted_peak: ByteSize, + pub predicted_peak: Box, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -112,12 +108,10 @@ pub fn runnable_memory_negligible() -> Rc { Rc::new(RunnableMemoryClass::RunnableMemoryNegligible) } -pub fn runnable_memory_substantial( - predicted_peak: Rc>, -) -> Rc { +pub fn runnable_memory_substantial(predicted_peak: ByteSize) -> Rc { Rc::new(RunnableMemoryClass::RunnableMemorySubstantial { peak: Rc::new(RunnableMemoryPeak { - predicted_peak: predicted_peak, + predicted_peak: Box::new(predicted_peak), }), }) } @@ -134,8 +128,8 @@ pub fn runnable_memory_class_eq( RunnableMemoryClass::RunnableMemorySubstantial { peak: lp, .. } => match (*right).clone() { RunnableMemoryClass::RunnableMemoryNegligible => false, RunnableMemoryClass::RunnableMemorySubstantial { peak: rp, .. } => { - (byte_size_count(lp.predicted_peak.clone()) - == byte_size_count(rp.predicted_peak.clone())) + (byte_size_count((*lp.predicted_peak).clone()) + == byte_size_count((*rp.predicted_peak).clone())) } }, } @@ -149,13 +143,13 @@ pub fn runnable_memory_substantial_sum( let left_count = match (*left).clone() { RunnableMemoryClass::RunnableMemoryNegligible => 0, RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { - byte_size_count(p.predicted_peak.clone()) + byte_size_count((*p.predicted_peak).clone()) } }; let right_count = match (*right).clone() { RunnableMemoryClass::RunnableMemoryNegligible => 0, RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { - byte_size_count(p.predicted_peak.clone()) + byte_size_count((*p.predicted_peak).clone()) } }; runnable_memory_substantial(byte_size((left_count + right_count))) @@ -202,17 +196,19 @@ pub fn runnable_heavy_whole_tree_resolve(profile: Rc) - profile.heavy_whole_tree_resolve.clone() } -pub fn runnable_predicted_space(profile: Rc) -> Rc> { +pub fn runnable_predicted_space(profile: Rc) -> ByteSize { match (*profile.memory.clone()).clone() { RunnableMemoryClass::RunnableMemoryNegligible => byte_size(0), - RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => p.predicted_peak.clone(), + RunnableMemoryClass::RunnableMemorySubstantial { peak: p, .. } => { + (*p.predicted_peak).clone() + } } } pub fn runnable_profile(r: Rc) -> Rc { match (*r).clone() { - Runnable::RunnableSingleClaim { profile: p, .. } => p, - Runnable::RunnableDiscoveryBatch { profile: p, .. } => p, + Runnable::RunnableSingleClaim { profile: p, .. } => p.clone(), + Runnable::RunnableDiscoveryBatch { profile: p, .. } => p.clone(), Runnable::RunnableKernelWorkload { fused_op_count: _, .. } => runnable_resource_profile_negligible(), @@ -223,7 +219,7 @@ pub fn runnable_forbids_corpus_co_residence(r: Rc) -> bool { match (*r).clone() { Runnable::RunnableDiscoveryBatch { .. } => false, Runnable::RunnableSingleClaim { profile: p, .. } => { - runnable_excludes_corpus_co_residence(p) + runnable_excludes_corpus_co_residence(p.clone()) } Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -269,14 +265,14 @@ pub type Schedule = Rc>>>>; pub struct RealizationPlan { pub target: ContentHash, pub objective: Rc, - pub schedule: Schedule, + pub schedule: Box, pub total: Rc>, pub _phantom: std::marker::PhantomData, } pub fn runnable_step_label(r: Rc) -> String { match (*r).clone() { - Runnable::RunnableSingleClaim { function: f, .. } => f, + Runnable::RunnableSingleClaim { function: f, .. } => f.clone(), Runnable::RunnableDiscoveryBatch { .. } => "__discovery_corpus__".to_string(), Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -339,7 +335,7 @@ pub fn schedule_lens_violation_diagnostic( ScheduleLensViolation::CompileGateNotFirst { expected: expected, .. } => Rc::new(LensVerdictDiagnostic { - reason: ("schedule_lens_compile_gate_not_first:".to_string() + &expected), + reason: ("schedule_lens_compile_gate_not_first:".to_string() + &expected.clone()), at: at, }), ScheduleLensViolation::CorpusBeforeCompile => Rc::new(LensVerdictDiagnostic { @@ -358,7 +354,7 @@ pub fn schedule_lens_verdict_for_ci_floor( plan: Rc>, compile_gate_fn: String, ) -> Rc { - if ((plan.schedule.clone().len() as i64) == 0) { + if (((*plan.schedule).clone().len() as i64) == 0) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic( Rc::new(ScheduleLensViolation::EmptySchedule), @@ -366,7 +362,7 @@ pub fn schedule_lens_verdict_for_ci_floor( ), }) } else { - if ((plan.schedule.clone().len() as i64) < 2) { + if (((*plan.schedule).clone().len() as i64) < 2) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic( Rc::new(ScheduleLensViolation::SingleBatchOnly), @@ -375,7 +371,7 @@ pub fn schedule_lens_verdict_for_ci_floor( }) } else { { - let batch0 = plan.schedule.clone().first().cloned(); + let batch0 = (*plan.schedule).clone().first().cloned(); if ((batch0.clone().expect("fail-closed: Optional receiver for method count (empty Optional at runtime)").len() as i64) != 1) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::CompileGateNotFirst { @@ -390,13 +386,13 @@ pub fn schedule_lens_verdict_for_ci_floor( }), compile_gate_fn.clone()), }) } else { - if schedule_batch_contains_label(batch0.expect("fail-closed: an optional value flowed into non-optional parameter 0 of schedule_batch_contains_label (empty Optional at runtime)"), "__discovery_corpus__".to_string()) { + if schedule_batch_contains_label(batch0.clone().expect("fail-closed: an optional value flowed into non-optional parameter 0 of schedule_batch_contains_label (empty Optional at runtime)"), "__discovery_corpus__".to_string()) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::CorpusBeforeCompile), compile_gate_fn.clone()), }) } else { { - let batch1 = plan.schedule.clone().get(1 as usize).cloned(); + let batch1 = (*plan.schedule).clone().get(1 as usize).cloned(); if ((batch1.expect("fail-closed: Optional receiver for method count (empty Optional at runtime)").len() as i64) < 2) { Rc::new(LensVerdict::Violation { diagnostic: schedule_lens_violation_diagnostic(Rc::new(ScheduleLensViolation::SingleBatchOnly), compile_gate_fn.clone()), @@ -417,7 +413,7 @@ pub fn schedule_generates_same_batch_count( left: Rc>, right: Rc>, ) -> bool { - ((left.schedule.clone().len() as i64) == (right.schedule.clone().len() as i64)) + (((*left.schedule).clone().len() as i64) == ((*right.schedule).clone().len() as i64)) } pub fn schedule_witness_entry_eq(a: Rc, b: Rc) -> bool { @@ -492,7 +488,10 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { function: rf, profile: rp, .. - } => (((le == re) && (lf == rf)) && runnable_resource_profile_eq(lp, rp)), + } => { + (((le.clone() == re.clone()) && (lf.clone() == rf.clone())) + && runnable_resource_profile_eq(lp.clone(), rp.clone())) + } Runnable::RunnableDiscoveryBatch { .. } => false, Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -521,13 +520,14 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { profile: rp, .. } => { - (((((((string_list_eq(lsr, rsr) && string_list_eq(lsd, rsd)) - && schedule_witness_entry_list_eq(lex, rex)) - && (lskip == rskip)) - && string_list_eq(lex2, rex2)) - && string_list_eq(lsc, rsc)) - && (lwc == rwc)) - && runnable_resource_profile_eq(lp, rp)) + (((((((string_list_eq(lsr.clone(), rsr.clone()) + && string_list_eq(lsd.clone(), rsd.clone())) + && schedule_witness_entry_list_eq(lex.clone(), rex.clone())) + && (lskip.clone() == rskip.clone())) + && string_list_eq(lex2.clone(), rex2.clone())) + && string_list_eq(lsc.clone(), rsc.clone())) + && (lwc.clone() == rwc.clone())) + && runnable_resource_profile_eq(lp.clone(), rp.clone())) } Runnable::RunnableKernelWorkload { fused_op_count: _, .. @@ -542,7 +542,7 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { Runnable::RunnableKernelWorkload { fused_op_count: rcount, .. - } => (lleft == rcount), + } => (lleft.clone() == rcount.clone()), }, } } @@ -602,7 +602,7 @@ pub fn schedule_generates_identical_schedule( plan: Rc>, schedule: Schedule, ) -> bool { - schedule_eq(plan.schedule.clone(), schedule) + schedule_eq((*plan.schedule).clone(), schedule) } #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 05f4d44696b..f2b75710075 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -92,8 +92,8 @@ pub fn optional_evidence_meet( match a.clone() { None => b, Some(va) => match b { - None => a, - Some(vb) => Some(descent_evidence_lattice_meet(va, vb)), + None => a.clone(), + Some(vb) => Some(descent_evidence_lattice_meet(va.clone(), vb.clone())), }, } } @@ -107,7 +107,7 @@ pub fn map_evidence_merge_at( Some(existing) => v1_rt::rc_map_insert( base.clone(), key.clone(), - descent_evidence_lattice_meet(existing, new_val), + descent_evidence_lattice_meet(existing.clone(), new_val), ), None => v1_rt::rc_map_insert(base.clone(), key.clone(), new_val), } @@ -155,7 +155,7 @@ pub fn positive_descent_count(steps: Rc) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*steps).clone() { PositiveDescentAmount::OneStep => 1, PositiveDescentAmount::AdditionalStep { previous: p, .. } => { - (1 + positive_descent_count(p)) + (1 + positive_descent_count(p.clone())) } }) } @@ -179,7 +179,7 @@ pub fn proportional_divisor_to_int(d: Rc) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*d).clone() { ProportionalDivisor::DivideByTwo => 2, ProportionalDivisor::StrictlyLarger { inner: p, .. } => { - (1 + proportional_divisor_to_int(p)) + (1 + proportional_divisor_to_int(p.clone())) } }) } @@ -201,7 +201,7 @@ pub fn positive_descent_amount_from_positive_int(k: i64) -> Option Some(Rc::new(PositiveDescentAmount::AdditionalStep { - previous: prev, + previous: prev.clone(), })), None => None, } @@ -223,9 +223,9 @@ pub fn proportional_divisor_from_int_at_least_two(k: i64) -> Option { - Some(Rc::new(ProportionalDivisor::StrictlyLarger { inner: prev })) - } + Some(prev) => Some(Rc::new(ProportionalDivisor::StrictlyLarger { + inner: prev.clone(), + })), None => None, } } diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index c2c3e8b303d..59d65be8eb6 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -73,7 +73,7 @@ pub fn container_param_names_for(kind_name: String) -> Rc> { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { - Some(p) => algebra_type_param_names(p), + Some(p) => algebra_type_param_names(p.clone()), None => Rc::new(vec![]), } } @@ -113,7 +113,7 @@ pub fn container_param_name(kind_name: String, index: i64) -> Option { .first() .cloned() { - Some(name) => Some(name), + Some(name) => Some(name.clone()), None => None, } } diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index ab1d86445e7..9be630bf6b9 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -135,7 +135,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> if { let mut __found = false; for item in m.items.clone().iter().cloned() { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { __found = true; break; } @@ -156,7 +156,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> for item in Rc::new({ let mut __result = Vec::new(); for item in m.items.clone().iter().cloned() { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { __result.push(item); } } @@ -170,7 +170,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> (*m.type_env).clone().source_indices.clone(), item.clone(), ), - body: (*item.body).clone().clone().unwrap(), + body: item.body.clone().clone().unwrap(), params: item.params.clone(), span: item.span.clone(), is_tail_recursive: (item.is_self_recursive.clone() @@ -200,7 +200,7 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc) -> Rc) -> bool { (import_is_all(n.clone()) - || (((((n.children.clone().len() as i64) > 0) && ((*n.body).clone() == None)) + || (((((n.children.clone().len() as i64) > 0) && (n.body.clone() == None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && ((n.params.clone().len() as i64) == 0))) } @@ -1878,7 +1878,7 @@ pub fn serialize_node_record( Connective::Disj => json_quote(connective_name(Connective::Disj)), Connective::NoConnective => "null".to_string(), Connective::Arrow => json_quote(connective_name(Connective::Arrow)), -}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref((*node.inferred).clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref((*node.body).clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref((*node.transport).clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref((*node.type_annotation).clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) +}), ", \"params\": ".to_string()), serialize_node_params_json(node.clone(), source_indices.clone(), key_to_id.clone())), ", \"inferred\": ".to_string()), json_optional_inferred_node_ref(node.inferred.clone(), key_to_id.clone())), ", \"return_cardinality\": ".to_string()), json_quote(cardinality_name(node.return_cardinality.clone()))), ", \"uses\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for item in node.uses.clone().iter().cloned() { __result.push(serialize_resource_use(item.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"body\": ".to_string()), json_optional_node_ref(node.body.clone(), key_to_id.clone())), ", \"transport\": ".to_string()), json_optional_node_ref(node.transport.clone(), key_to_id.clone())), ", \"properties\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for prop in node.properties.clone().iter().cloned() { __result.push(serialize_field_init(prop.clone(), source_indices.clone(), key_to_id.clone())); } __result }))), ", \"type_annotation\": ".to_string()), json_optional_node_ref(node.type_annotation.clone(), key_to_id.clone())), ", \"is_self_recursive\": ".to_string()), json_bool(node.is_self_recursive.clone())), ", \"has_non_tail_self_call\": ".to_string()), json_bool(node.has_non_tail_self_call.clone())), ", \"expr_data\": ".to_string()), serialize_expr_data(node.clone(), source_indices.clone(), key_to_id.clone())), "}".to_string()) } pub fn serialize_typed_module( @@ -1892,7 +1892,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref((*module.module).clone(), key_to_id.clone()), + serialize_node_ref(module.module.clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2271,7 +2271,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let mut __result = Vec::new(); for p in parse_results.iter().cloned() { __result.extend( - (*match (*p.module).clone() { + (*match p.module.clone() { Some(m) => Rc::new(vec![m.clone()]), None => Rc::new(vec![]), }) @@ -2426,7 +2426,7 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - (*m.module).clone(), + m.module.clone(), )); } __result diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 5b2d0e1894e..c3e45272204 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -1359,7 +1359,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1380,7 +1380,7 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - (*entry.body).clone(), + entry.body.clone(), state_param, empty_parser_progress_env(), proven.clone(), @@ -1659,7 +1659,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -2196,7 +2196,7 @@ pub fn build_scc_measure_params( acc.clone(), name.clone(), recursive_measure_param_names( - (*entry.body).clone(), + entry.body.clone(), entry.params.clone(), si.clone(), ), @@ -5712,7 +5712,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), local_func_set.clone(), si.clone(), )) @@ -6433,7 +6433,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - (*entry.body).clone(), + entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6441,7 +6441,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - (*entry.body).clone(), + entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6534,8 +6534,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6609,15 +6609,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6691,8 +6691,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6740,7 +6740,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6795,7 +6795,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6834,7 +6834,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - (*entry.body).clone(), + entry.body.clone(), name.clone(), si.clone(), ); @@ -7168,12 +7168,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7499,7 +7499,7 @@ pub fn resolve_callback_cost( fn_ref, func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7508,7 +7508,7 @@ pub fn resolve_callback_cost( la, func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7519,7 +7519,7 @@ pub fn resolve_callback_cost( la, func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7532,7 +7532,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -7565,7 +7565,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - (*body_result.summary.clone().work).clone(), + body_result.summary.clone().work.clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7584,12 +7584,12 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: (*body_result.table).clone(), + table: body_result.table.clone(), }) } CostShape::ShapeSortBody => { @@ -7599,7 +7599,7 @@ pub fn cost_of_method_by_shape( la, func_index, scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7611,7 +7611,7 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { @@ -7620,7 +7620,7 @@ pub fn cost_of_method_by_shape( }); let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), per_comparison), + left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), right: log_factor, }); let sort_os = seed_cost_map( @@ -7633,12 +7633,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work), + work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: (*key_result.table).clone(), + table: key_result.table.clone(), }) } CostShape::ShapeLinearScan => { @@ -7661,28 +7661,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -8495,7 +8495,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - (*lr.table).clone(), + lr.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8503,23 +8503,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*lr.summary.clone().work).clone(), + lr.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().work).clone(), + rr.summary.clone().work.clone(), ), ), span: cost_seq( - (*lr.summary.clone().span).clone(), + lr.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().span).clone(), + rr.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*rr.table).clone(), + table: rr.table.clone(), }) } ExprData::ExprCall { .. } => { @@ -8552,49 +8552,49 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*callee_result.table).clone(), + table: callee_result.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*args_result.summary.clone().work).clone(), (*callee_result.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*args_result.summary.clone().span).clone(), (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } ExprData::ExprMethodCall { @@ -8641,17 +8641,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), })), } } @@ -8669,55 +8669,55 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().work).clone(), + args_result.summary.clone().work.clone(), ), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().span).clone(), + args_result.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } } @@ -8743,7 +8743,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*s_r.table).clone(), + table: s_r.table.clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8752,7 +8752,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*(*acc.result).clone().table).clone(), + (*acc.result).clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8760,22 +8760,22 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_par( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))( (*(*acc.result).clone().summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_par( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))( (*(*acc.result).clone().summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: (*ar.table).clone(), + table: ar.table.clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![(*ar.summary.clone().work).clone()]), + Rc::new(vec![ar.summary.clone().work.clone()]), ), }) }, @@ -8783,13 +8783,13 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*s_r.summary.clone().work).clone(), + s_r.summary.clone().work.clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - (*s_r.summary.clone().span).clone(), + s_r.summary.clone().span.clone(), Rc::new(vec![ - (*(*arms_accum.result).clone().summary.clone().span).clone() + (*arms_accum.result).clone().summary.clone().span.clone() ]), ), output_size: (*arms_accum.result) @@ -8805,7 +8805,7 @@ pub fn cost_of_expr( .certainty .clone(), }), - table: (*(*arms_accum.result).clone().table).clone(), + table: (*arms_accum.result).clone().table.clone(), }) } ExprData::ExprIf => { @@ -8824,7 +8824,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8835,14 +8835,14 @@ pub fn cost_of_expr( eb, func_index.clone(), scc_index.clone(), - (*t_r.table).clone(), + t_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: (*er.table).clone(), + table: er.table.clone(), }) } None => Rc::new(SummaryResult { @@ -8852,29 +8852,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*t_r.table).clone(), + table: t_r.table.clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*c_r.summary.clone().work).clone(), + c_r.summary.clone().work.clone(), Rc::new(vec![ - (*t_r.summary.clone().work).clone(), - (*e_result.summary.clone().work).clone(), + t_r.summary.clone().work.clone(), + e_result.summary.clone().work.clone(), ]), ), span: cost_conditional( - (*c_r.summary.clone().span).clone(), + c_r.summary.clone().span.clone(), Rc::new(vec![ - (*t_r.summary.clone().span).clone(), - (*e_result.summary.clone().span).clone(), + t_r.summary.clone().span.clone(), + e_result.summary.clone().span.clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: (*e_result.table).clone(), + table: e_result.table.clone(), }) } ExprData::ExprLet => { @@ -8894,25 +8894,25 @@ pub fn cost_of_expr( b, func_index.clone(), scc_index.clone(), - (*v_r.table).clone(), + v_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*v_r.summary.clone().work).clone(), (*b_r.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*v_r.summary.clone().span).clone(), (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: (*b_r.table).clone(), + table: b_r.table.clone(), }) } None => v_r, @@ -8933,25 +8933,25 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().work).clone(), (*sr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().span).clone(), (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: (*sr.table).clone(), + table: sr.table.clone(), }) }, ), @@ -8971,22 +8971,22 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); let size = receiver_size_var(c, si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size, (*bd_r.summary.clone().work).clone()); + let loop_work = cost_loop(binder, size, bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*c_r.summary.clone().span).clone(), loop_work), + work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: (*bd_r.table).clone(), + table: bd_r.table.clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9004,25 +9004,25 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9041,25 +9041,25 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9117,7 +9117,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - (*entry.body).clone(), + entry.body.clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9136,12 +9136,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), scc_members.clone(), ), span: bounded_scc_cost( t, - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), scc_members, ), output_size: result.summary.clone().output_size.clone(), @@ -9151,12 +9151,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), func_name.clone(), ), span: bounded_recursive_cost( t, - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9167,13 +9167,13 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost((*bounded.work).clone()), - span: simplify_cost((*bounded.span).clone()), + work: simplify_cost(bounded.work.clone()), + span: simplify_cost(bounded.span.clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); let final_table = cache_summary( - (*result.table).clone(), + result.table.clone(), func_name.clone(), simplified.clone(), ); @@ -9538,7 +9538,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9567,7 +9567,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - (*entry.body).clone(), + entry.body.clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9667,13 +9667,13 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9746,12 +9746,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity((*sr.summary.clone().work).clone()); + let class_str = classify_complexity(sr.summary.clone().work.clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9759,12 +9759,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { + let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason((*sr.summary.clone().work).clone()), + reason: extract_unknown_reason(sr.summary.clone().work.clone()), span: entry.span.clone(), })]), ) @@ -9813,9 +9813,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(evicted_table.clone(), func_name.clone()) + evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) } else { - evicted_table.clone() + Rc::new(evicted_table.clone()) }; Rc::new(TopoBuildAcc { table: final_table.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 5f3d818a392..899380ce5c6 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -593,13 +593,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: (*typed_module.type_env).clone(), - func_env: (*typed_module.func_env).clone(), + type_env: typed_module.type_env.clone(), + func_env: typed_module.func_env.clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -644,7 +644,7 @@ pub fn lookup_func_sig_in_scope( scope: Rc, name: String, ) -> Option> { - lookup_func_sig((*scope.func_env).clone(), name) + lookup_func_sig(scope.func_env.clone(), name) } pub fn typed_named_arg_matches( @@ -1247,7 +1247,7 @@ pub fn named_type_vars_in_inferred(inferred: Option>) -> Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_vars = named_type_vars_in_inferred((*n.inferred).clone()); + let self_vars = named_type_vars_in_inferred(n.inferred.clone()); let child_vars = Rc::new({ let mut __result = Vec::new(); for ch in n.children.clone().iter().cloned() { @@ -1324,13 +1324,13 @@ pub fn render_node_type( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); - let n_is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let n_is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; @@ -1338,7 +1338,7 @@ pub fn render_node_type( && ((n.children.clone().len() as i64) == 0)) { { - let is_named_type_var = match (*n.inferred).clone().as_deref().cloned() { + let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { ((tn.clone() != "".to_string()) && (tn.clone() == var_id)) } @@ -1377,7 +1377,7 @@ pub fn render_node_type( __result }); let param_str = param_strs.clone().join(&repr.param_separator.clone()); - let ret_str = match (*n.inferred).clone().as_deref().cloned() { + let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_node_type( rt, target.clone(), @@ -1461,7 +1461,7 @@ pub fn render_node_type( } if is_conj { { - if ((*n.type_annotation).clone() != None) { + if (n.type_annotation.clone() != None) { { let refined_str = match n.children.clone().first().cloned() { Some(base) => render_node_type( @@ -1482,7 +1482,7 @@ pub fn render_node_type( { let first_child = match n.children.clone().first().cloned() { Some(c) => { - if ((*c.inferred).clone() != None) { + if (c.inferred.clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1502,7 +1502,7 @@ pub fn render_node_type( }; let second_child = match n.children.clone().get(1 as usize).cloned() { Some(c) => { - if ((*c.inferred).clone() != None) { + if (c.inferred.clone() != None) { render_node_type( resolved_type(c.clone()), target.clone(), @@ -1809,15 +1809,15 @@ pub fn has_service_items(typed: Rc) -> bool { } pub fn service_fallback_transport(item: Rc) -> Rc { - if ((*item.transport).clone() == None) { + if (item.transport.clone() == None) { local_transport_node(item.span.clone()) } else { - (*item.transport).clone().clone().unwrap() + item.transport.clone().clone().unwrap() } } pub fn effective_operation_transport(op_node: Rc, fallback: Rc) -> Rc { - match (*op_node.transport).clone() { + match op_node.transport.clone() { Some(op_transport) => op_transport, None => fallback, } @@ -1833,9 +1833,9 @@ pub fn service_has_rest( let from_ops = { let mut __found = false; for op in op_children.iter().cloned() { - if if ((*op.transport).clone() != None) { + if if (op.transport.clone() != None) { is_rest_transport( - (*op.transport).clone().clone().unwrap(), + op.transport.clone().clone().unwrap(), source_indices.clone(), ) } else { @@ -1857,8 +1857,8 @@ pub fn service_has_shell(fallback_transport: Rc, op_children: Rc { - if (expr_call_func_at((*frame.expr).clone(), si.clone()) == fn_name.clone()) { + if (expr_call_func_at(frame.expr.clone(), si.clone()) == fn_name.clone()) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), @@ -2549,7 +2549,7 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value((*frame.expr).clone()); + let inner = return_value(frame.expr.clone()); { let __tco_0 = Rc::new(TcoFrame { expr: inner.clone(), @@ -2616,7 +2616,7 @@ pub fn shared_tco_default_return( ) -> String { { let val_str = recurse_expr( - (*frame.expr).clone(), + frame.expr.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2636,7 +2636,7 @@ pub fn shared_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -2673,9 +2673,9 @@ pub fn shared_tco_if( let syntax = spec.block_syntax.clone(); match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2799,14 +2799,14 @@ pub fn shared_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( @@ -3218,8 +3218,8 @@ pub fn emit_unified_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), @@ -4100,7 +4100,7 @@ pub fn emit_typed_cast_shared( { let expr_str = recurse(expr.clone()); let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); - let src_ty = match (*expr.inferred).clone().as_deref().cloned() { + let src_ty = match expr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { emit_node_type(n, target.clone(), source_indices.clone()) } diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index d7ed120dbc9..7f8694ce9af 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -602,7 +602,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> bool { - (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_type_def_item(item: Rc) -> bool { - ((item.connective.clone() != Connective::NoConnective) && ((*item.transport).clone() == None)) + ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) } pub fn is_bare_leaf_item(item: Rc) -> bool { - (((((item.connective.clone() == Connective::NoConnective) && ((*item.body).clone() == None)) + (((((item.connective.clone() == Connective::NoConnective) && (item.body.clone() == None)) && ((item.params.clone().len() as i64) == 0)) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) } @@ -684,26 +684,26 @@ pub fn is_type_decl_item( ) -> bool { ((is_bare_leaf_item(item.clone()) && !is_type_alias_return_node(resolved_type(item.clone()), source_indices)) - || (((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + || (((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0))) } pub fn is_function_item(item: Rc) -> bool { - (((*item.body).clone() != None) && ((*item.type_annotation).clone() == None)) + ((item.body.clone() != None) && (item.type_annotation.clone() == None)) } pub fn is_data_def_item(item: Rc) -> bool { - (((*item.body).clone() != None) && ((*item.type_annotation).clone() != None)) + ((item.body.clone() != None) && (item.type_annotation.clone() != None)) } pub fn is_service_def_item(item: Rc) -> bool { - (((*item.transport).clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) } pub fn is_resource_def_item(item: Rc) -> bool { - ((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) > 0)) - || (((((*item.transport).clone() == None) && ((item.children.clone().len() as i64) == 0)) + (((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) + || ((((item.transport.clone() == None) && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) > 0)) - && ((*item.body).clone() == None))) + && (item.body.clone() == None))) } diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index b6f4b4b93a8..52bba1b4908 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -130,7 +130,7 @@ pub fn emit_go(typed: Rc) -> Rc { __result.push(emit_go_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -138,7 +138,7 @@ pub fn emit_go(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -465,7 +465,7 @@ pub fn emit_go_module( let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let si = (*typed_module.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), m.clone()); + let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( v1_rt::concat( @@ -478,7 +478,7 @@ pub fn emit_go_module( ), pkg_name, ); - let imports_str = emit_go_imports(typed_module.items.clone(), module_imports(m), si); + let imports_str = emit_go_imports(typed_module.items.clone(), module_imports(Rc::new(m)), si); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { @@ -686,9 +686,9 @@ pub fn emit_go_typed_item( ) -> String { { let env = (*scope.type_env).clone(); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), env) + emit_go_type_def_from_connective(item.clone(), Rc::new(env)) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -707,7 +707,7 @@ pub fn emit_go_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -716,7 +716,7 @@ pub fn emit_go_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -725,18 +725,18 @@ pub fn emit_go_typed_item( if is_data_def_item(item.clone()) { emit_go_data_def( item_text, - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), 0, ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, env) + emit_go_service_def(item.clone(), registry, Rc::new(env)) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), env) + emit_go_resource_def(item.clone(), Rc::new(env)) } else { v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index c1a79a0e8e7..68541fa3465 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -118,7 +118,7 @@ pub fn emit_python(typed: Rc) -> Rc { __result.push(emit_py_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -126,7 +126,7 @@ pub fn emit_python(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -188,7 +188,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { __result.push({ let mod_name = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -367,9 +367,9 @@ pub fn emit_py_module( let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let si = (*scope.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), m.clone()); + let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(m), si); + let imports_str = emit_py_imports(module_imports(Rc::new(m)), si); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { @@ -583,9 +583,9 @@ pub fn emit_py_typed_item( ) -> String { { let env = (*scope.type_env).clone(); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), env) + emit_py_type_def_from_connective(item.clone(), Rc::new(env)) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -607,7 +607,7 @@ pub fn emit_py_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -616,7 +616,7 @@ pub fn emit_py_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) @@ -625,17 +625,17 @@ pub fn emit_py_typed_item( if is_data_def_item(item.clone()) { emit_py_data_def( item_text, - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry, scope.clone(), ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, env) + emit_py_service_def(item.clone(), registry, Rc::new(env)) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), env) + emit_py_resource_def(item.clone(), Rc::new(env)) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 970cf6d890b..0ad35602eb3 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -163,7 +163,7 @@ pub fn render_rust_type( if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr.clone()) { return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), _ => match find_property( n.properties.clone(), @@ -253,8 +253,8 @@ pub fn render_rust_type_without_applied_binding( match n.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -801,7 +801,7 @@ pub fn render_rust_applied_type_arg( ) { "()".to_string() } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), _ => render_rust_decl_type( n.clone(), @@ -1306,7 +1306,7 @@ pub fn alias_rhs_container_arg( arg: Rc, source_indices: Rc>>, ) -> Rc { - match (*arg.inferred).clone().as_deref().cloned() { + match arg.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if node_is_collection(rt.clone(), source_indices) { rt @@ -2081,7 +2081,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match (*wire_item.body).clone() { + match wire_item.body.clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve, source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2127,7 +2127,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match (*wc.body).clone() { + match wc.body.clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2178,7 +2178,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( break rust_serde_error_policy(v1_rt::concat("wire_contract: ambiguous VariantEncoding data alias: ".to_string(), alias_name.clone())); } } - None => match (*init.inferred).clone() { + None => match init.inferred.clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2227,7 +2227,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } } } - _ => match (*init.inferred).clone() { + _ => match init.inferred.clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2274,7 +2274,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => field_value_by_name(body, "encoding".to_string(), source_indices), None => None, } @@ -2292,7 +2292,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { Some(target_name) => (target_name == coproduct_name), None => false, @@ -2351,7 +2351,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match (*item.type_annotation).clone() { + match item.type_annotation.clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node) == "CoproductWireContract".to_string()) @@ -2404,7 +2404,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2429,7 +2429,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { Some(target_name) => { if { @@ -2584,7 +2584,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, tm: Rc| { let module_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2640,7 +2640,7 @@ pub fn build_scoped_data_item_index( { let module_name = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2666,7 +2666,7 @@ pub fn build_scoped_data_item_index( ) }, ); - module_imports((*typed_module.module).clone()) + module_imports(typed_module.module.clone()) .iter() .cloned() .fold( @@ -3242,7 +3242,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc) -> Rc { }); let mod_filename = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3470,7 +3470,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result.push(emit_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -3478,7 +3478,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -3506,7 +3506,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for m in typed.modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -3686,10 +3686,10 @@ pub fn build_module_export_sets( |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); let exported = get_exported_names( - (*tm.module).clone(), + tm.module.clone(), (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( @@ -3720,7 +3720,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3730,7 +3730,7 @@ pub fn emit_module_full( ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.clone()).iter().cloned() { + for imp in module_imports(Rc::new(m.clone())).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), @@ -3766,12 +3766,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); let imports_str = emit_imports( - module_imports(m.clone()), + module_imports(Rc::new(m.clone())), emit_info.clone(), registry.clone(), local_type_names, @@ -3786,14 +3786,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str) }; let this_mod_filename = - module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3851,7 +3851,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3866,7 +3866,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ), "::*;".to_string(), )); @@ -3887,12 +3887,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); - let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(Rc::new(m.clone())); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3949,7 +3949,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3967,26 +3967,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers) }; - let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename }; - let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4105,7 +4105,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>, tm: Rc| { let nm = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4118,7 +4118,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4177,7 +4177,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports((*tm.module).clone()), + Some(tm) => module_imports(tm.module.clone()), None => Rc::new(vec![]), } } @@ -4194,7 +4194,7 @@ pub fn module_name_from_filename( for tm in mods.iter().cloned() { __result.push(authored_name_at( source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); } __result @@ -4368,7 +4368,7 @@ pub fn type_name_is_rust_importable_in_module( item, name.clone(), module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm), registry, export_sets, @@ -4460,7 +4460,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4571,7 +4571,7 @@ pub fn reexport_source_module_name_with_visited( for imp in Rc::new({ let mut __result = Vec::new(); for imp in - module_imports((*tm.module).clone()).iter().cloned() + module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4622,7 +4622,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()) + for imp in module_imports(tm.module.clone()) .iter() .cloned() { @@ -4890,7 +4890,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5147,7 +5147,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5183,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5643,7 +5643,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5672,7 +5672,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry.clone(), export_sets.clone(), @@ -5800,8 +5800,8 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - if (((*n.inferred).clone() != None) - && is_type_variable((*n.inferred).clone().clone().unwrap())) + if ((n.inferred.clone() != None) + && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { @@ -5811,7 +5811,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - (*scope.type_env).clone(), + scope.type_env.clone(), name.clone(), ) { true @@ -5876,8 +5876,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -5929,8 +5929,8 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs = resolved_type(item.clone()); - if (((*rhs.inferred).clone() != None) - && is_compiler_error((*rhs.inferred).clone().clone().unwrap())) + if ((rhs.inferred.clone() != None) + && is_compiler_error(rhs.inferred.clone().clone().unwrap())) { false } else { @@ -7188,15 +7188,15 @@ pub fn emit_typed_item( let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - env, + Rc::new(env), emit_info.clone(), wire_contract_item, data_items, @@ -7454,8 +7454,8 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(env.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + authored_name(Rc::new(env.clone()), item.clone()), + item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); @@ -7501,7 +7501,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(env, item.clone()), + authored_name(Rc::new(env), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7515,7 +7515,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7526,7 +7526,7 @@ pub fn emit_typed_item( item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7538,8 +7538,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text, - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7553,7 +7553,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - env, + Rc::new(env), ) } else { if is_resource_def_item(item.clone()) { @@ -7561,7 +7561,7 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - env, + Rc::new(env), ) } else { v1_rt::concat( @@ -7688,7 +7688,7 @@ pub fn emit_type_params_with_clone_bound( pub fn is_function_type_param(param: Rc) -> bool { { let type_expr = param_node_type_expr(param.clone()); - let type_expr_is_var = match (*type_expr.inferred).clone() { + let type_expr_is_var = match type_expr.inferred.clone() { Some(inf) => is_type_variable(inf), None => false, }; @@ -9225,7 +9225,7 @@ pub fn enum_variant_field_type_node( Some(variant) => { match find_child_named(variant, field_name, source_indices.clone()) { Some(field) => { - if ((*field.inferred).clone() != None) { + if (field.inferred.clone() != None) { resolved_type(field) } else { fallback @@ -9609,7 +9609,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9618,7 +9618,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9636,7 +9636,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si, emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9869,7 +9869,7 @@ pub fn emit_func_def( (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -10321,7 +10321,7 @@ pub fn emit_rust_param_type( __result }); let param_str = param_types.join(&", ".to_string()); - let ret_str = match (*n.inferred).clone().as_deref().cloned() { + let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_rust_fn_sig_type( rt, generic_param_names.clone(), @@ -10808,14 +10808,14 @@ pub fn positional_payload_scrut_type( Some(summary) => match v1_rt::map_get(&summary.field_type_map.clone(), "0".to_string()) { Some(payload_type) => payload_type, - None => match (*field_binding.inferred).clone().as_deref().cloned() { + None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt)) } _ => "".to_string(), }, }, - None => match (*field_binding.inferred).clone().as_deref().cloned() { + None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt)) } @@ -11355,13 +11355,13 @@ pub fn analyze_rc_match( } __result }); - let scrutinee_is_optional = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrutinee_is_optional = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } _ => false, }; - let scrutinee_is_rc_wrapped = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrutinee_is_rc_wrapped = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if (((rt.children.clone().len() as i64) == 0) && (rt.ident_span.clone() != None)) { v1_rt::set_contains(&shared_types, authored_name_at(source_indices.clone(), rt)) @@ -12009,7 +12009,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { + let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base, None => inferred_node.clone(), @@ -12019,8 +12019,8 @@ pub fn explicit_record_struct_name( }; let is_product = is_product_type(n.clone()); let is_coproduct = is_coproduct_type(n.clone()); - let n_is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let n_is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; @@ -12313,7 +12313,7 @@ pub fn emit_typed_expr_base( let variant_parent = effective_variant_parent( n.clone(), binding_kind, - (*texpr.inferred).clone(), + texpr.inferred.clone(), emit_info.clone(), si, ); @@ -12396,7 +12396,7 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); match find_child_named( @@ -12429,7 +12429,7 @@ pub fn field_access_field_is_boxed( shared_types, (*scope.type_env).clone().source_indices.clone(), )) - || is_recursive_type_by_name((*scope.type_env).clone(), field_ty_name)) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name)) } } } @@ -12457,7 +12457,7 @@ pub fn emit_typed_field_access( shared_types.clone(), emit_info.clone(), ); - let base_is_anon_record = match (*base.inferred).clone().as_deref().cloned() { + let base_is_anon_record = match base.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: bt, .. }) => { let is_product = is_product_type(bt.clone()); if (is_product && (bt.ident_span.clone() == None)) { @@ -12656,7 +12656,7 @@ pub fn type_needs_rc_seen( }; } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); - if ((*normed.inferred).clone() != None) { + if (normed.inferred.clone() != None) { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { @@ -12768,8 +12768,8 @@ pub fn rust_empty_map_kv_type_str( pub fn type_node_child_is_type_variable(c: Rc) -> bool { { let ch = child_type_node(c); - if ((*ch.inferred).clone() != None) { - is_type_variable((*ch.inferred).clone().clone().unwrap()) + if (ch.inferred.clone() != None) { + is_type_variable(ch.inferred.clone().clone().unwrap()) } else { false } @@ -12800,13 +12800,13 @@ pub fn rust_empty_set_element_type_str( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; - let elem_is_error = if ((*elem_node.inferred).clone() != None) { - is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_error = if (elem_node.inferred.clone() != None) { + is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -12837,8 +12837,8 @@ pub fn emit_rust_empty_set_expr( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -12929,7 +12929,7 @@ pub fn emit_rust_expr_var( emit_var_ref( n, binding_kind, - (*expr.inferred).clone(), + expr.inferred.clone(), expr.span.clone().start.clone(), shared_types, registry, @@ -13018,7 +13018,7 @@ pub fn emit_rust_expr_call( emit_typed_call_expr( f, expr.children.clone(), - (*expr.inferred).clone(), + expr.inferred.clone(), registry, scope.clone(), depth, @@ -13057,7 +13057,7 @@ pub fn emit_rust_expr_method_call( r, m, a, - (*expr.inferred).clone(), + expr.inferred.clone(), method_semantics, registry, scope.clone(), @@ -13172,7 +13172,7 @@ pub fn emit_rust_expr_record_lit( let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13686,7 +13686,7 @@ pub fn is_map_typed_expr( texpr: Rc, source_indices: Rc>>, ) -> bool { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => node_is_keyed_collection(n, source_indices), _ => false, } @@ -13712,7 +13712,7 @@ pub fn emit_discriminant_call_lowering( 1024, ); let ty_name = resolved_type_name(arg, (*scope.type_env).clone().source_indices.clone()); - match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { + match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13721,7 +13721,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name((*scope.type_env).clone(), child.clone()); + authored_name(scope.type_env.clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13983,7 +13983,7 @@ pub fn emit_typed_call( emit_info.clone(), 1024, ); - let type_name = if ((*base_arg.inferred).clone() != None) { + let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( (*scope.type_env).clone().source_indices.clone(), resolved_type(base_arg), @@ -14683,13 +14683,13 @@ pub fn collection_element_type( match rt.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child); - let elem_is_error = if ((*elem_node.inferred).clone() != None) { - is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_error = if (elem_node.inferred.clone() != None) { + is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { false }; - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -14733,7 +14733,7 @@ pub fn lambda_scope_from_children( let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { + Some(pn) => match pn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: resolved_type, .. @@ -14776,17 +14776,17 @@ pub fn lambda_param_type_strs( let idx = pair.0.clone(); let param_name = pair.1.clone(); let inferred_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { + Some(pn) => match pn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: param_type, .. }) => { - let param_is_error = if ((*param_type.inferred).clone() != None) { - is_compiler_error((*param_type.inferred).clone().clone().unwrap()) + let param_is_error = if (param_type.inferred.clone() != None) { + is_compiler_error(param_type.inferred.clone().clone().unwrap()) } else { false }; - let param_is_type_var = if ((*param_type.inferred).clone() != None) { - is_type_variable((*param_type.inferred).clone().clone().unwrap()) + let param_is_type_var = if (param_type.inferred.clone() != None) { + is_type_variable(param_type.inferred.clone().clone().unwrap()) } else { false }; @@ -15058,7 +15058,7 @@ pub fn emit_rust_fold_method_call( 1024, ); let elem_type_str = collection_element_type( - (*receiver.inferred).clone(), + receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15145,7 +15145,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type, None => match args.clone().first().cloned() { Some(init_arg) => { - if ((*arg_value(init_arg.clone()).inferred).clone() != None) { + if (arg_value(init_arg.clone()).inferred.clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15263,8 +15263,8 @@ pub fn emit_rust_fold_method_call( emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let acc_type_is_type_var = if ((*acc_type_node.inferred).clone() != None) { - is_type_variable((*acc_type_node.inferred).clone().clone().unwrap()) + let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { + is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) } else { false }; @@ -15473,15 +15473,15 @@ pub fn emit_rust_sort_by_method_call( emit_info.clone(), 1024, ); - let elem_type_str = match (*receiver.inferred).clone().as_deref().cloned() { + let elem_type_str = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let resolved = rt; let elem = for_each_element_type_node( resolved, (*scope.type_env).clone().source_indices.clone(), ); - let elem_is_type_var = if ((*elem.inferred).clone() != None) { - is_type_variable((*elem.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem.inferred.clone() != None) { + is_type_variable(elem.inferred.clone().clone().unwrap()) } else { false }; @@ -15549,7 +15549,7 @@ pub fn emit_rust_map_method_call( shared_types.clone(), emit_info.clone(), ); - let recv_is_optional = match (*receiver.inferred).clone().as_deref().cloned() { + let recv_is_optional = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -15846,7 +15846,7 @@ pub fn emit_rust_get_method_call( ), None => "compile_error!(\"get method missing index\")".to_string(), }; - let receiver_resolved = match (*receiver.inferred).clone().as_deref().cloned() { + let receiver_resolved = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }; @@ -15899,10 +15899,10 @@ pub fn emit_rust_with_method_call( emit_info.clone(), 1024, ); - let type_name = match (*receiver.inferred).clone().as_deref().cloned() { + let type_name = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let rt_is_error = if ((*rt.inferred).clone() != None) { - is_compiler_error((*rt.inferred).clone().clone().unwrap()) + let rt_is_error = if (rt.inferred.clone() != None) { + is_compiler_error(rt.inferred.clone().clone().unwrap()) } else { false }; @@ -16964,7 +16964,7 @@ pub fn emit_typed_match( emit_info.clone(), 1024, ); - let scrut_type = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrut_type = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -17422,7 +17422,7 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name((*scope.type_env).clone(), struct_name) { + match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node, field_name, @@ -17542,7 +17542,7 @@ pub fn is_already_optional( if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17583,7 +17583,7 @@ pub fn is_already_optional( if summary_says_optional { true } else { - match (*b.inferred).clone().as_deref().cloned() { + match b.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. }) => { @@ -17598,7 +17598,7 @@ pub fn is_already_optional( ) { true } else { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17606,7 +17606,7 @@ pub fn is_already_optional( } } } - _ => match (*texpr.inferred).clone().as_deref().cloned() { + _ => match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17615,7 +17615,7 @@ pub fn is_already_optional( } } } - _ => match (*texpr.inferred).clone().as_deref().cloned() { + _ => match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17638,11 +17638,11 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if ((*field_child.inferred).clone() != None) { + if (field_child.inferred.clone() != None) { { let field_type = resolved_type(field_child.clone()); - let ft_is_type_var = if ((*field_type.inferred).clone() != None) { - is_type_variable((*field_type.inferred).clone().clone().unwrap()) + let ft_is_type_var = if (field_type.inferred.clone() != None) { + is_type_variable(field_type.inferred.clone().clone().unwrap()) } else { false }; @@ -17669,13 +17669,13 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if ((*field_child.inferred).clone() != None) { + if (field_child.inferred.clone() != None) { { let field_type = resolved_type(field_child); - let ft_is_type_var = if ((*field_type.inferred).clone() != None) + let ft_is_type_var = if (field_type.inferred.clone() != None) { is_type_variable( - (*field_type.inferred).clone().clone().unwrap(), + field_type.inferred.clone().clone().unwrap(), ) } else { false @@ -18085,7 +18085,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); - match (*fval.inferred).clone().as_deref().cloned() { + match fval.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => v1_rt::rc_map_insert( @@ -18205,7 +18205,7 @@ pub fn emit_typed_record_lit( { let resolved_struct = (*resolve_node( resolved_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) .resolved) @@ -18249,8 +18249,8 @@ pub fn emit_typed_record_lit( let effective_parent = match context_lookup { Some(context_parent) => Some(context_parent), None => { - let rt_is_type_var = if ((*resolved_type.inferred).clone() != None) { - is_type_variable((*resolved_type.inferred).clone().clone().unwrap()) + let rt_is_type_var = if (resolved_type.inferred.clone() != None) { + is_type_variable(resolved_type.inferred.clone().clone().unwrap()) } else { false }; @@ -18624,7 +18624,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18888,7 +18888,7 @@ pub fn emit_typed_bin_op( } pub fn is_optional_typed_expr(e: Rc) -> bool { - match (*e.inferred).clone().as_deref().cloned() { + match e.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -18919,7 +18919,7 @@ pub fn is_string_typed_expr( e: Rc, source_indices: Rc>>, ) -> bool { - match (*e.inferred).clone().as_deref().cloned() { + match e.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); let inner = if is_optional { @@ -19242,7 +19242,7 @@ pub fn emit_rust_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -19279,9 +19279,9 @@ pub fn emit_rust_tco_if( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19558,8 +19558,8 @@ pub fn emit_rust_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19569,7 +19569,7 @@ pub fn emit_rust_tco_match( emit_info.clone(), 1024, ); - let tco_scrut_type = match (*s.inferred).clone().as_deref().cloned() { + let tco_scrut_type = match s.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -19732,14 +19732,14 @@ pub fn emit_rust_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19886,7 +19886,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - (*frame.expr).clone(), + frame.expr.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20829,7 +20829,7 @@ let prelude = match wire_opt.clone() { v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()) } else { { - let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + let wire_ty = match tn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => tn.clone(), }; @@ -20845,7 +20845,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -let raw = match (*ch.inferred).clone().as_deref().cloned() { +let raw = match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -21028,7 +21028,7 @@ pub fn emit_rest_http_method( source_indices: Rc>>, ) -> String { match transport_method(transport, source_indices.clone()) { - Some(m) => match (*m.inferred).clone().as_deref().cloned() { + Some(m) => match m.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { let method_name = expr_var_name_at(m, source_indices.clone()); Rc::new({ @@ -21440,7 +21440,7 @@ pub fn operation_response_200_resolved_type( { Some(p) => { let v = field_init_node_value(p); - match (*v.inferred).clone().as_deref().cloned() { + match v.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => Some(tn), _ => { let type_name = @@ -21551,7 +21551,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match (*state.node).clone() { + let next_node = match state.node.clone() { Some(n) => Some(for_each_element_type_node(n, source_indices.clone())), None => None, }; @@ -21584,7 +21584,7 @@ pub fn advance_wire_path_projection( }) } } else { - match (*state.node).clone() { + match state.node.clone() { Some(n) => match wire_child_for_segment(n, seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { expr: v1_rt::concat( @@ -21825,7 +21825,7 @@ pub fn emit_from_key_extraction( .to_string() } else { { - let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + let wire_ty = match tn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => tn.clone(), }; @@ -21858,7 +21858,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -match (*ch.inferred).clone().as_deref().cloned() { +match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -22803,7 +22803,7 @@ pub fn data_def_annotation_is_named_refinement( { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); ((((ann_name.clone() != "".to_string()) - && ((*annotation.type_annotation).clone() != None)) + && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name)) && !is_host_text_carrier_type( annotation.clone(), @@ -22828,7 +22828,7 @@ pub fn emit_data_def( let render_type_node = if ((annotation_type_node.children.clone().len() as i64) > 0) { annotation_type_node.clone() } else { - match (*value.inferred).clone().as_deref().cloned() { + match value.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => annotation_type_node.clone(), } @@ -23117,7 +23117,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23276,7 +23276,7 @@ pub fn emit_data_def_body( match effective_variant_parent( vname.clone(), bk, - (*value.inferred).clone(), + value.inferred.clone(), emit_info.clone(), (*scope.type_env).clone().source_indices.clone(), ) { @@ -23440,7 +23440,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23699,7 +23699,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match (*data_item.body).clone() { + Some(data_item) => match data_item.body.clone() { Some(body) => extract_literal_string(body), None => None, }, @@ -23772,7 +23772,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if ((*item.body).clone() == None) { + if (item.body.clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -23820,7 +23820,7 @@ pub fn collect_workflow_funcs( item.clone(), authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), registry.clone(), tm.items.clone(), @@ -23915,7 +23915,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )), None => "".to_string(), }; @@ -23936,7 +23936,7 @@ pub fn emit_main_rs( for m in modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index ab19ab22d2d..a45b11d9a64 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -254,7 +254,7 @@ pub fn infer_block_stmts( let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected.clone()); let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); - let stmt_rt = resolved_type(stmt_typed.clone()); + let stmt_rt = resolved_type(Rc::new(stmt_typed.clone())); let next_scope = scope_after_stmt_node(stmt.clone(), stmt_rt.clone(), scope.clone()); { @@ -267,7 +267,7 @@ pub fn infer_block_stmts( ); let __tco_1 = (remaining_count - 1); let __tco_2 = next_scope.clone(); - let __tco_3 = v1_rt::rc_list_push(typed_stmts, stmt_typed.clone()); + let __tco_3 = v1_rt::rc_list_push(typed_stmts, Rc::new(stmt_typed.clone())); let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags.clone()); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; @@ -385,7 +385,7 @@ pub fn merge_scope_from_imports( svc_locals: svc_locals.clone(), }), |acc: Rc, titem: Rc| { - if (((*titem.transport).clone() != None) + if ((titem.transport.clone() != None) && ((titem.children.clone().len() as i64) > 0)) { { @@ -398,7 +398,7 @@ pub fn merge_scope_from_imports( c.clone(), ), outputs: inferred_to_outputs( - (*c.inferred).clone(), + c.inferred.clone(), c.span.clone(), env.source_indices.clone(), ), @@ -429,11 +429,11 @@ pub fn merge_scope_from_imports( }) } } else { - if ((((((*titem.body).clone() != None) + if (((((titem.body.clone() != None) && ((titem.params.clone().len() as i64) == 0)) - && ((*titem.transport).clone() == None)) + && (titem.transport.clone() == None)) && (titem.connective.clone() == Connective::NoConnective)) - && ((*titem.inferred).clone() != None)) + && (titem.inferred.clone() != None)) { Rc::new(InferScopeComponents { svc_registry: acc.svc_registry.clone(), @@ -518,7 +518,7 @@ pub fn classify_field_recursion( source_indices: Rc>>, ) -> Option> { { - let type_expr = match (*field_node.inferred).clone().as_deref().cloned() { + let type_expr = match field_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => field_node_type_expr(field_node.clone()), }; @@ -773,7 +773,7 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(parent) => { let is_coproduct = (parent.connective.clone() == Connective::Disj); if is_coproduct { @@ -784,7 +784,7 @@ pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option ) { Some(authored_name_at( (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), )) } else { None @@ -812,7 +812,7 @@ pub fn variant_owner_node_authority() -> String { pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(owner) => { let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); if owner_is_coproduct { @@ -931,7 +931,7 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { Some(direct) => direct.children.clone(), None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ @@ -977,7 +977,7 @@ pub fn record_lit_expanded_from_expected( { Some(exp) } else { - match (*exp.inferred).clone().as_deref().cloned() { + match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -1047,7 +1047,7 @@ pub fn record_lit_instantiated_fields( if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for((*scope.type_env).clone(), exp.clone()) { + match lookup_type_for(scope.type_env.clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1092,15 +1092,15 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { .return_cardinality .clone(), uses: sf.uses.clone(), - body: (*sf.body).clone(), - transport: (*sf.transport).clone(), + body: sf.body.clone(), + transport: sf.transport.clone(), properties: sf.properties.clone(), - type_annotation: (*sf.type_annotation).clone(), + type_annotation: sf.type_annotation.clone(), is_self_recursive: sf.is_self_recursive.clone(), has_non_tail_self_call: sf .has_non_tail_self_call .clone(), - match_pattern: (*sf.match_pattern).clone(), + match_pattern: sf.match_pattern.clone(), expr_data: sf.expr_data.clone(), ident: None, })); @@ -1131,7 +1131,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1141,14 +1141,14 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match (*arg_value(receiver_arg).inferred) + match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1168,7 +1168,7 @@ pub fn set_union_other_operand_is_resolved_non_set( other_arg: Rc, scope: Rc, ) -> bool { - match (*arg_value(other_arg).inferred).clone().as_deref().cloned() { + match arg_value(other_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. }) => !node_is_set_collection(other_type, (*scope.type_env).clone().source_indices.clone()), @@ -1180,14 +1180,14 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { + match set_element_type_in_env(receiver_type, scope.type_env.clone()) { Some(elem_slot) => Some(child_type_node(elem_slot)), None => None, } } pub fn set_element_type_is_concrete(elem: Rc) -> bool { - match (*elem.inferred).clone() { + match elem.inferred.clone() { Some(inf) => !is_type_variable(inf), None => true, } @@ -1382,7 +1382,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) + Some(receiver_arg) => match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1390,7 +1390,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env(receiver_type, (*scope.type_env).clone()) { + }) => match map_value_type_in_env(receiver_type, scope.type_env.clone()) { Some(value_type) => { if (func_name.clone() == "lookup".to_string()) { witness_of_element(value_type) @@ -1409,7 +1409,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) + Some(receiver_arg) => match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1417,11 +1417,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_key_type_in_env(receiver_type, (*scope.type_env).clone()) { + }) => match map_key_type_in_env(receiver_type, scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type); Rc::new(Tier2bBt { - bt: (*lk.ty).clone(), + bt: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1443,7 +1443,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg).inferred) + Some(receiver_arg) => match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1451,12 +1451,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env(receiver_type, (*scope.type_env).clone()) + }) => match map_value_type_in_env(receiver_type, scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type); Rc::new(Tier2bBt { - bt: (*lv.ty).clone(), + bt: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1485,7 +1485,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match (*arg_value(insert_arg).inferred) + Some(insert_arg) => match arg_value(insert_arg).inferred .clone() .as_deref() .cloned() @@ -1497,7 +1497,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match (*arg_value(other_arg.clone()).inferred) + Some(other_arg) => match arg_value(other_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1506,7 +1506,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: other_type, .. }) => match set_element_type_in_env( other_type, - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(elem_slot) => Some(child_type_node(elem_slot)), None => None, @@ -1534,7 +1534,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match (*arg_value(receiver_arg.clone()).inferred) + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1606,7 +1606,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match (*arg_value(receiver_arg).inferred) + match arg_value(receiver_arg).inferred .clone() .as_deref() .cloned() @@ -1685,11 +1685,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type); Rc::new(MethodPipeFallback { - result_ty: (*lk.ty).clone(), + result_ty: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1700,11 +1700,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type); Rc::new(MethodPipeFallback { - result_ty: (*lv.ty).clone(), + result_ty: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1835,7 +1835,7 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - (*scope.type_env).clone(), + scope.type_env.clone(), scrutinee_type, )), PatternSubject::PatternDynamic { @@ -1908,7 +1908,7 @@ pub fn annotate_pattern_parent_enums( resolved_scrut, variant_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); @@ -1981,8 +1981,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2000,8 +2000,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2026,8 +2026,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2066,8 +2066,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2131,7 +2131,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for((*scope.type_env).clone(), scrut_type_name); + inductive_fields_for(scope.type_env.clone(), scrut_type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2191,7 +2191,7 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); @@ -2323,7 +2323,7 @@ pub fn extract_fold_init_info( ia.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*init_result.typed).clone(), + init_result.typed.clone(), ia.span.clone(), ia.span.clone(), ), @@ -2358,7 +2358,7 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), @@ -2485,8 +2485,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2505,7 +2505,7 @@ pub fn infer_method_args_with_fold( a.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -2527,8 +2527,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2598,7 +2598,7 @@ pub fn infer_arg_with_element_type( arg.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), arg.span.clone(), arg.span.clone(), ), @@ -2655,7 +2655,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span, @@ -2670,7 +2670,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span, @@ -2678,7 +2678,7 @@ pub fn infer_expr( } } } - None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { + None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( @@ -2689,7 +2689,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*fsig.inferred).clone(), + node: fsig.inferred.clone(), })), span.clone(), span, @@ -2706,7 +2706,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - (*fsig.inferred).clone(), + fsig.inferred.clone(), ), })), span.clone(), @@ -2748,19 +2748,19 @@ pub fn infer_expr( let base_result = infer_expr(base_expr, scope.clone(), None); let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); - let base_rt = resolved_type(base_typed.clone()); + let base_rt = resolved_type(Rc::new(base_typed.clone())); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { + if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; - let resolved_base_is_error = if ((*resolved_base.inferred).clone() != None) { - is_compiler_error((*resolved_base.inferred).clone().clone().unwrap()) + let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { + is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; @@ -2784,13 +2784,13 @@ pub fn infer_expr( Some(field_type) => { let field_summary = match field_summary_for_type( base_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ) { Some(s) => Some(s), None => field_summary_for_type( resolved_base, - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ), }; @@ -2799,7 +2799,7 @@ pub fn infer_expr( Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![base_typed]), + Rc::new(vec![Rc::new(base_typed)]), Some(Rc::new(InferredNode::Resolved { node: field_type })), span, node_name_span(texpr.clone()), @@ -2812,7 +2812,7 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); if base_is_type_var { { @@ -2824,7 +2824,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed]), + Rc::new(vec![Rc::new(base_typed)]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), @@ -2852,7 +2852,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed]), + Rc::new(vec![Rc::new(base_typed)]), Some(Rc::new(InferredNode::Resolved { node: svc_type, })), @@ -2915,7 +2915,7 @@ pub fn infer_expr( ); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); + let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -2947,7 +2947,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -2959,13 +2959,13 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type((*first_result.typed).clone()); + let first_type = resolved_type(first_result.typed.clone()); let elem_type = for_each_element_type_node( first_type, (*scope.type_env).clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - (*first_result.typed).clone(), + first_result.typed.clone(), elem_type.clone(), scope.clone(), ); @@ -2985,7 +2985,7 @@ pub fn infer_expr( first_arg.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*first_result.typed).clone(), + first_result.typed.clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3091,7 +3091,7 @@ pub fn infer_expr( ) { unify_record_lit_generics( formal_raw.clone(), - (*ar.typed).clone(), + ar.typed.clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3099,7 +3099,7 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type((*ar.typed).clone()), + resolved_type(ar.typed.clone()), generic_names.clone(), (*scope.type_env).clone().source_indices.clone(), st.subst.clone(), @@ -3118,7 +3118,7 @@ pub fn infer_expr( .source_indices .clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -3153,7 +3153,7 @@ pub fn infer_expr( { let resolved_type = match sig { Some(s) => substitute_generics( - (*s.inferred).clone(), + s.inferred.clone(), call_subst.clone(), (*scope.type_env).clone().source_indices.clone(), ), @@ -3175,7 +3175,7 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - direct_call_arg_mismatch_diags( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))))))))( value_params_for_check, typed_args, call_subst, @@ -3203,11 +3203,11 @@ pub fn infer_expr( } else { { let first_arg_type = match typed_args.clone().first().cloned() { - Some(ta) => resolved_type(arg_value(ta.clone())), + Some(ta) => resolved_type(arg_value(Rc::new(ta.clone()))), None => unit_type(), }; let method_receiver = match typed_args.clone().first().cloned() { - Some(ta) => arg_value(ta.clone()), + Some(ta) => arg_value(Rc::new(ta.clone())), None => internal_expr_error_node( "method bridge missing receiver".to_string(), span.clone(), @@ -3222,7 +3222,7 @@ pub fn infer_expr( match Rc::new({ let mut __result = Vec::new(); for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(a.clone())) { + if is_lambda_expr(arg_value(Rc::new(a.clone()))) { __result.push(a); } } @@ -3231,7 +3231,7 @@ pub fn infer_expr( .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg)), + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg))), None => call_fold_acc_type, } } else { @@ -3241,7 +3241,7 @@ pub fn infer_expr( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3252,7 +3252,7 @@ pub fn infer_expr( scope.service_registry.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let is_known_method = ((*method_resolution.result_type).clone() != None); + let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { { let receiver = method_receiver; @@ -3264,18 +3264,18 @@ pub fn infer_expr( .collect::>(), ); let base_result_type = - match (*method_resolution.result_type).clone() { + match method_resolution.result_type.clone() { Some(mt) => mt, None => error_type(), }; - let method_tv = if ((*method_resolution.semantics).clone() == None) + let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type, diagnostics: Rc::new(vec![]), }) } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()) + match (*method_resolution.semantics.clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3299,7 +3299,7 @@ pub fn infer_expr( remaining.clone().iter().cloned() { __result.push(resolved_type( - arg_value(a.clone()), + arg_value(Rc::new(a.clone())), )); } __result @@ -3344,13 +3344,13 @@ pub fn infer_expr( }; let bridge_result_type = (*method_tv.ty).clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if ((*method_resolution.semantics) + let returns_receiver_self = if (method_resolution.semantics .clone() == None) { false } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()) + match (*method_resolution.semantics.clone().clone().unwrap()) .clone() { MethodSemantics::AlgebraMethodSemantics { @@ -3365,7 +3365,7 @@ pub fn infer_expr( }; let final_receiver = if ((returns_receiver_self && is_fully_resolved( - bridge_result_type.clone(), + Rc::new(bridge_result_type.clone()), (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( @@ -3380,19 +3380,19 @@ pub fn infer_expr( connective: receiver.connective.clone(), params: receiver.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: bridge_result_type.clone(), + node: Rc::new(bridge_result_type.clone()), })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), - body: (*receiver.body).clone(), - transport: (*receiver.transport).clone(), + body: receiver.body.clone(), + transport: receiver.transport.clone(), properties: receiver.properties.clone(), - type_annotation: (*receiver.type_annotation).clone(), + type_annotation: receiver.type_annotation.clone(), is_self_recursive: receiver.is_self_recursive.clone(), has_non_tail_self_call: receiver .has_non_tail_self_call .clone(), - match_pattern: (*receiver.match_pattern).clone(), + match_pattern: receiver.match_pattern.clone(), expr_data: receiver.expr_data.clone(), ident: None, }) @@ -3404,10 +3404,10 @@ pub fn infer_expr( for ta in remaining.iter().cloned() { __result.push(make_arg_node( arg_name_at( - ta.clone(), + Rc::new(ta.clone()), (*scope.type_env).clone().source_indices.clone(), ), - arg_value(ta.clone()), + arg_value(Rc::new(ta.clone())), span.clone(), span.clone(), )); @@ -3418,7 +3418,7 @@ pub fn infer_expr( typed: make_named_expr_node( func_name, Rc::new(ExprData::ExprMethodCall { - method_semantics: (*method_resolution.semantics) + method_semantics: method_resolution.semantics .clone(), }), v1_rt::concat( @@ -3426,7 +3426,7 @@ pub fn infer_expr( remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: bridge_result_type, + node: Rc::new(bridge_result_type), })), span, node_name_span(texpr.clone()), @@ -3593,7 +3593,7 @@ match bare_s { }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: bt, + node: Rc::new(bt), })), span, node_name_span(texpr.clone()), @@ -3655,7 +3655,7 @@ match bare_s { Some(ctor_result) => ctor_result, None => { let type_match = lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), func_name.clone(), ); let resolved_type = match type_match.clone() @@ -3713,8 +3713,8 @@ match bare_s { let recv_typed = (*recv_result.typed).clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( - resolved_type(recv_typed.clone()), - (*scope.type_env).clone(), + resolved_type(Rc::new(recv_typed.clone())), + scope.type_env.clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), @@ -3729,11 +3729,11 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( - recv_typed.clone(), + Rc::new(recv_typed.clone()), recv_elem_type.clone(), scope.clone(), ); @@ -3769,7 +3769,7 @@ match bare_s { match Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(a.clone())) { + if is_lambda_expr(arg_value(Rc::new(a.clone()))) { __result.push(a); } } @@ -3778,14 +3778,14 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg)), + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg))), None => fold_acc_type, } } else { fold_acc_type }; let method_resolution = resolve_known_method_node( - recv_typed.clone(), + Rc::new(recv_typed.clone()), recv_rt.clone(), method_name.clone(), if (fold_info.clone() != None) { @@ -3796,7 +3796,7 @@ match bare_s { scope.service_registry.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let pipe_fb = match (*method_resolution.result_type).clone() { + let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { result_ty: rt, kernel_diags: Rc::new(vec![]), @@ -3809,13 +3809,13 @@ match bare_s { ), }; let base_result_type = (*pipe_fb.result_ty).clone(); - let method_tv_mc = if ((*method_resolution.semantics).clone() == None) { + let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: Rc::new(base_result_type), diagnostics: Rc::new(vec![]), }) } else { - match (*(*method_resolution.semantics).clone().clone().unwrap()).clone() { + match (*method_resolution.semantics.clone().clone().unwrap()).clone() { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. @@ -3823,7 +3823,7 @@ match bare_s { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( - base_result_type.clone(), + Rc::new(base_result_type.clone()), (*scope.type_env).clone().source_indices.clone(), )) { @@ -3831,7 +3831,7 @@ match bare_s { let mc_arg_types = Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - __result.push(resolved_type(arg_value(a.clone()))); + __result.push(resolved_type(arg_value(Rc::new(a.clone())))); } __result }); @@ -3853,26 +3853,26 @@ match bare_s { } } else { Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: Rc::new(base_result_type), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: Rc::new(base_result_type), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: Rc::new(base_result_type), diagnostics: Rc::new(vec![]), }), } }; let result_type = (*method_tv_mc.ty).clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); - let method_semantics = if ((*method_resolution.semantics).clone() != None) { - (*method_resolution.semantics).clone() + let method_semantics = if (method_resolution.semantics.clone() != None) { + method_resolution.semantics.clone() } else { Some(Rc::new(MethodSemantics::PlainMethodSemantics)) }; @@ -3882,8 +3882,8 @@ match bare_s { Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![recv_typed]), typed_mc_arg_nodes), - Some(Rc::new(InferredNode::Resolved { node: result_type })), + v1_rt::concat(Rc::new(vec![Rc::new(recv_typed)]), typed_mc_arg_nodes), + Some(Rc::new(InferredNode::Resolved { node: Rc::new(result_type) })), span, node_name_span(texpr.clone()), ); @@ -3905,8 +3905,8 @@ match bare_s { let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); - let scrut_rt = resolved_type(scrut_typed.clone()); - let scrut_subject = pattern_subject_from_inferred((*scrut_typed.inferred).clone()); + let scrut_rt = resolved_type(Rc::new(scrut_typed.clone())); + let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); let scrut_provenance = classify_binding_provenance(scrut, scope.clone()); let arm_infer_results = Rc::new({ let mut __result = Vec::new(); @@ -3953,18 +3953,18 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, - body_typed.clone(), + Rc::new(body_typed.clone()), span.clone(), ), diagnostics: v1_rt::concat( pattern_diags.clone(), v1_rt::concat(guard_diags.clone(), body_diags.clone()), ), - body_type: resolved_type(body_typed.clone()), + body_type: resolved_type(Rc::new(body_typed.clone())), }) }); } @@ -4054,7 +4054,7 @@ match bare_s { }), }; if !is_fully_resolved( - (*original.body_type).clone(), + original.body_type.clone(), (*scope.type_env).clone().source_indices.clone(), ) { { @@ -4106,11 +4106,11 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, - body_typed.clone(), + Rc::new(body_typed.clone()), span.clone(), ), diagnostics: v1_rt::concat( @@ -4120,7 +4120,7 @@ match bare_s { body_diags.clone(), ), ), - body_type: resolved_type(body_typed.clone()), + body_type: resolved_type(Rc::new(body_typed.clone())), }) } } else { @@ -4162,7 +4162,7 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => check_match_exhaustiveness( + } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))))))))( resolved_scrutinee, typed_arms.clone(), (*scope.type_env).clone(), @@ -4174,7 +4174,7 @@ match bare_s { }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![scrut_typed]), typed_arms), + v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed)]), typed_arms), Some(Rc::new(InferredNode::Resolved { node: result_type })), span, ); @@ -4201,8 +4201,8 @@ match bare_s { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type((*then_result.typed).clone()); - let else_rt = resolved_type((*else_result.typed).clone()); + let then_rt = resolved_type(then_result.typed.clone()); + let else_rt = resolved_type(else_result.typed.clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -4229,8 +4229,8 @@ match bare_s { let then_diags = then_result.diagnostics.clone(); let else_typed = (*else_result.typed).clone(); let else_diags = else_result.diagnostics.clone(); - let then_rt = resolved_type(then_typed.clone()); - let else_rt = resolved_type(else_typed.clone()); + let then_rt = resolved_type(Rc::new(then_typed.clone())); + let else_rt = resolved_type(Rc::new(else_typed.clone())); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), @@ -4267,7 +4267,7 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed, else_typed]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed), Rc::new(else_typed)]), Some(Rc::new(InferredNode::Resolved { node: unified })), span, ); @@ -4282,7 +4282,7 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed)]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), span, ); @@ -4321,13 +4321,13 @@ match bare_s { let val_result = infer_expr(val_expr, scope.clone(), val_expected); let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let val_type = resolved_type(val_typed.clone()); + let val_type = resolved_type(Rc::new(val_typed.clone())); if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( let_name, Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed]), + Rc::new(vec![Rc::new(val_typed)]), Some(Rc::new(InferredNode::Resolved { node: val_type })), span, node_name_span(texpr.clone()), @@ -4343,7 +4343,7 @@ match bare_s { scope.clone(), let_name.clone(), val_type, - classify_binding_provenance(val_typed.clone(), scope.clone()), + classify_binding_provenance(Rc::new(val_typed.clone()), scope.clone()), ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); @@ -4352,8 +4352,8 @@ match bare_s { let let_texpr2 = make_named_expr_node( let_name, Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed, body_typed.clone()]), - (*body_typed.inferred).clone(), + Rc::new(vec![Rc::new(val_typed), Rc::new(body_typed.clone())]), + body_typed.inferred.clone(), span, node_name_span(texpr.clone()), ); @@ -4421,7 +4421,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type((*r.typed).clone()), + Some(r) => resolved_type(r.typed.clone()), None => unit_type(), } } else { @@ -4477,7 +4477,7 @@ match bare_s { Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: (*list_k.ty).clone(), + node: list_k.ty.clone(), })), span, ); @@ -4501,7 +4501,7 @@ match bare_s { let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), - resolved_type(left_typed.clone()), + resolved_type(Rc::new(left_typed.clone())), (*scope.type_env).clone().source_indices.clone(), ); let bo_texpr = make_expr_node( @@ -4509,9 +4509,9 @@ match bare_s { op: op, algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![left_typed, right_typed]), + Rc::new(vec![Rc::new(left_typed), Rc::new(right_typed)]), Some(Rc::new(InferredNode::Resolved { - node: (*binop_info.result_type).clone(), + node: binop_info.result_type.clone(), })), span, ); @@ -4528,11 +4528,11 @@ match bare_s { let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), - UnaryOpKind::Neg => resolved_type(operand_typed.clone()), + UnaryOpKind::Neg => resolved_type(Rc::new(operand_typed.clone())), }; let uo_texpr = make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op }), - Rc::new(vec![operand_typed]), + Rc::new(vec![Rc::new(operand_typed)]), Some(Rc::new(InferredNode::Resolved { node: result_type })), span, ); @@ -4673,8 +4673,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: (*lam_scope.type_env).clone(), - func_env: (*lam_scope.func_env).clone(), + type_env: lam_scope.type_env.clone(), + func_env: lam_scope.func_env.clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4709,7 +4709,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), None => None, }; @@ -4724,13 +4724,13 @@ match bare_s { inferred: param_type.clone(), return_cardinality: pn.return_cardinality.clone(), uses: pn.uses.clone(), - body: (*pn.body).clone(), - transport: (*pn.transport).clone(), + body: pn.body.clone(), + transport: pn.transport.clone(), properties: pn.properties.clone(), - type_annotation: (*pn.type_annotation).clone(), + type_annotation: pn.type_annotation.clone(), is_self_recursive: pn.is_self_recursive.clone(), has_non_tail_self_call: pn.has_non_tail_self_call.clone(), - match_pattern: (*pn.match_pattern).clone(), + match_pattern: pn.match_pattern.clone(), expr_data: pn.expr_data.clone(), }) }); @@ -4739,8 +4739,8 @@ match bare_s { }); let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), - (*body_typed.inferred).clone(), + v1_rt::concat(Rc::new(vec![Rc::new(body_typed.clone())]), typed_param_nodes), + body_typed.inferred.clone(), span, ); Rc::new(InferResult { @@ -4759,7 +4759,7 @@ match bare_s { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); make_interp_part_node( - (*r.typed).clone(), + r.typed.clone(), part_node.span.clone(), ) } @@ -4820,7 +4820,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: (*state.last_type).clone(), + node: state.last_type.clone(), })), span, ); @@ -4854,7 +4854,7 @@ match bare_s { let si = (*scope.type_env).clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( - (*inner_typed.inferred).clone(), + inner_typed.inferred.clone(), target_name, span.clone(), si, @@ -4866,7 +4866,7 @@ match bare_s { }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![inner_typed, target_type.clone()]), + Rc::new(vec![Rc::new(inner_typed), target_type.clone()]), Some(Rc::new(InferredNode::Resolved { node: target_type })), span, ); @@ -4887,11 +4887,11 @@ match bare_s { let coll_typed = (*coll_result.typed).clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( - resolved_type(coll_typed.clone()), + resolved_type(Rc::new(coll_typed.clone())), (*scope.type_env).clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( - coll_typed.clone(), + Rc::new(coll_typed.clone()), elem_type_node.clone(), scope.clone(), ); @@ -4907,8 +4907,8 @@ match bare_s { let fe_texpr = make_named_expr_node( variable, Rc::new(ExprData::ExprForEach), - Rc::new(vec![coll_typed, body_typed.clone()]), - (*body_typed.inferred).clone(), + Rc::new(vec![Rc::new(coll_typed), Rc::new(body_typed.clone())]), + body_typed.inferred.clone(), span, node_name_span(texpr.clone()), ); @@ -4927,10 +4927,10 @@ match bare_s { let index_result = infer_expr(idx_key, scope.clone(), None); let index_typed = (*index_result.typed).clone(); let index_diags = index_result.diagnostics.clone(); - let index_check = match (*base_typed.inferred).clone().as_deref().cloned() { + let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match (*index_typed.inferred).clone().as_deref().cloned() { + }) => match index_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: index_type, .. }) => Some(check_index_access_node( @@ -4945,14 +4945,14 @@ match bare_s { _ => None, }; let access_failure_inferred = - match (*base_typed.inferred).clone().as_deref().cloned() { + match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - (*index_typed.inferred).clone() + index_typed.inferred.clone() } - _ => (*base_typed.inferred).clone(), + _ => base_typed.inferred.clone(), }; let idx_inferred = match index_check.clone() { - Some(checked) => (*checked.inferred).clone(), + Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid index access".to_string(), @@ -4965,7 +4965,7 @@ match bare_s { }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base_typed, index_typed]), + Rc::new(vec![Rc::new(base_typed), Rc::new(index_typed)]), idx_inferred, span, ); @@ -4991,13 +4991,13 @@ match bare_s { let end_result = infer_expr(end_expr, scope.clone(), None); let end_typed = (*end_result.typed).clone(); let end_diags = end_result.diagnostics.clone(); - let slice_check = match (*base_typed.inferred).clone().as_deref().cloned() { + let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. - }) => match (*start_typed.inferred).clone().as_deref().cloned() { + }) => match start_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: start_type, .. - }) => match (*end_typed.inferred).clone().as_deref().cloned() { + }) => match end_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: end_type, .. }) => { Some(check_slice_access_node( base_type, @@ -5015,19 +5015,19 @@ match bare_s { _ => None, }; let access_failure_inferred = - match (*base_typed.inferred).clone().as_deref().cloned() { + match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - match (*start_typed.inferred).clone().as_deref().cloned() { + match start_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - (*end_typed.inferred).clone() + end_typed.inferred.clone() } - _ => (*start_typed.inferred).clone(), + _ => start_typed.inferred.clone(), } } - _ => (*base_typed.inferred).clone(), + _ => base_typed.inferred.clone(), }; let slc_inferred = match slice_check.clone() { - Some(checked) => (*checked.inferred).clone(), + Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( access_failure_inferred, "invalid slice access".to_string(), @@ -5040,7 +5040,7 @@ match bare_s { }; let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![base_typed, start_typed, end_typed]), + Rc::new(vec![Rc::new(base_typed), Rc::new(start_typed), Rc::new(end_typed)]), slc_inferred, span, ); @@ -5058,8 +5058,8 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*inner_result.typed).clone()]), - (*(*inner_result.typed).clone().inferred).clone(), + Rc::new(vec![inner_result.typed.clone()]), + (*inner_result.typed).clone().inferred.clone(), span, ); Rc::new(InferResult { @@ -5097,7 +5097,7 @@ pub fn infer_variant_constructor_call( None => None, Some(parent_enum) => { let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), parent_enum) { + match lookup_type_by_name(scope.type_env.clone(), parent_enum) { Some(parent_node) => { match find_child_named(parent_node, func_name.clone(), si.clone()) { Some(variant_node) => { @@ -5175,13 +5175,13 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if (((*n.inferred).clone() != None) && is_type_variable((*n.inferred).clone().clone().unwrap())) + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && ((*n.inferred).clone() == None)) + && (n.inferred.clone() == None)) { { let name = authored_name_at(env.source_indices.clone(), n.clone()); @@ -5207,7 +5207,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && ((*n.inferred).clone() == None)) + && (n.inferred.clone() == None)) { is_user_generic_use_site(n.clone(), env.clone()) } else { @@ -5221,7 +5221,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((binding.connective.clone() == Connective::NoConnective) && ((binding.children.clone().len() as i64) == 0)) - && ((*binding.inferred).clone() != None)) + && (binding.inferred.clone() != None)) { true } else { @@ -5229,7 +5229,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { && ((binding.children.clone().len() as i64) > 0)) { (is_user_generic_use_site(binding.clone(), env.clone()) - || ((*binding.inferred).clone() != None)) + || (binding.inferred.clone() != None)) } else { false } @@ -5253,19 +5253,19 @@ pub fn peel_alias_once_for_field_access( if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { - break once.clone(); + break Rc::new(once.clone()); } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) - && ((*once.inferred).clone() == None)) + && (once.inferred.clone() == None)) { { let __tco_0 = once.clone(); - n = __tco_0; + n = Rc::new(__tco_0); continue; } } else { - break once.clone(); + break Rc::new(once.clone()); } } } @@ -5275,7 +5275,7 @@ pub fn structural_from_expanded_type(normed: Rc) -> Rc { match normed.connective.clone() { Connective::Conj => normed, Connective::Disj => normed, - _ => match (*normed.inferred).clone().as_deref().cloned() { + _ => match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => match target.connective.clone() { Connective::Conj => target, Connective::Disj => target, @@ -5296,7 +5296,7 @@ pub fn record_field_type_is_unresolved_param( if ((ft.connective.clone() == Connective::NoConnective) && ((ft.children.clone().len() as i64) == 0)) { - match (*ft.inferred).clone() { + match ft.inferred.clone() { Some(inf) => is_type_variable(inf), None => { let fname = authored_name_at(env.source_indices.clone(), ft); @@ -5410,11 +5410,11 @@ pub fn alias_chain_target_after_args( target.clone(), type_args, ); - let is_parameterized_alias = ((((*decl.inferred).clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: alias_body, .. }) => substitute_generics(alias_body, subst, env.source_indices.clone()), @@ -5583,13 +5583,13 @@ pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) - && ((*decl.inferred).clone() != None)) + && (decl.inferred.clone() != None)) { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target, _ => decl, } @@ -5598,7 +5598,7 @@ pub fn record_lit_alias_struct_fields( }; let expanded = expand_type_for_field_access( to_expand, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5619,7 +5619,7 @@ pub fn record_lit_construction_field_names( ) -> Option>> { { let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5652,7 +5652,7 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5811,7 +5811,7 @@ pub fn infer_record_lit( .cloned() { Some(sf) => { - let ft = match (*sf.inferred).clone().as_deref().cloned() { + let ft = match sf.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -5819,7 +5819,7 @@ pub fn infer_record_lit( || type_node_is_callable(ft.clone())) || field_type_is_optional_coproduct( ft.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), )) { Some(ft.clone()) @@ -5838,16 +5838,16 @@ pub fn infer_record_lit( let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { - let got_node = resolved_type(ar_typed.clone()); + let got_node = resolved_type(Rc::new(ar_typed.clone())); if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), (*scope.type_env).clone().source_indices.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { { let expected_for_shape = match lookup_type_for( - (*scope.type_env).clone(), + scope.type_env.clone(), with_required_cardinality(expected_node.clone()), ) { Some(resolved) => resolved.clone(), @@ -5875,7 +5875,7 @@ pub fn infer_record_lit( Rc::new(FieldInferResult { typed_field: make_field_init_node( fi_name.clone(), - ar_typed.clone(), + Rc::new(ar_typed.clone()), fi.span.clone(), node_name_span(fi.clone()), ), @@ -5910,7 +5910,7 @@ pub fn infer_record_lit( for fir in fi_infer_results.iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - (*fir.typed_field).clone(), + fir.typed_field.clone(), (*scope.type_env).clone().source_indices.clone(), ), span: (*fir.typed_field).clone().span.clone(), @@ -5918,7 +5918,7 @@ pub fn infer_record_lit( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*(*fir.infer_result.clone().typed).clone().inferred).clone(), + inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -5969,7 +5969,7 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); + lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { @@ -5979,7 +5979,7 @@ pub fn infer_record_lit( lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for((*scope.type_env).clone(), local_node) + lookup_type_for(scope.type_env.clone(), local_node) } None => None, } @@ -5999,7 +5999,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for fir in fi_infer_results.iter().cloned() { if (field_init_node_name_at( - (*fir.typed_field).clone(), + fir.typed_field.clone(), (*scope.type_env).clone().source_indices.clone(), ) == "value".to_string()) { @@ -6012,7 +6012,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - (*val_fir.infer_result.clone().typed).clone(), + val_fir.infer_result.clone().typed.clone(), )), None => raw_resolved, } @@ -6033,7 +6033,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6529,7 +6529,7 @@ pub fn build_per_field_for_let( ExprData::ExprCall { .. } => { let callee = expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { @@ -6589,7 +6589,7 @@ pub fn build_per_field_for_let( } => { let callee = expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { @@ -6692,7 +6692,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ) .iter() @@ -6823,10 +6823,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -6894,7 +6894,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), None => match v1_rt::map_get(&ctx.param_names.clone(), bname) { Some(t) => t, @@ -6904,7 +6904,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { let callee = expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { + let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { classify_call_via_provenance(val.clone(), param_map, ctx.clone()) @@ -6991,7 +6991,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - let type_based = match (*val.inferred).clone().as_deref().cloned() { + let type_based = match val.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if is_container_type(authored_name_at( (*ctx.type_env).clone().source_indices.clone(), @@ -7051,11 +7051,11 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) + && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { let fields = - inductive_fields_for((*ctx.type_env).clone(), elem); + inductive_fields_for(ctx.type_env.clone(), elem); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7488,7 +7488,7 @@ pub fn classify_argument( None => "".to_string(), }, }; - let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); + let fields = inductive_fields_for(ctx.type_env.clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7527,7 +7527,7 @@ pub fn classify_argument( (*ctx.type_env).clone().source_indices.clone(), ); let from_provenance = match lookup_func_sig( - (*ctx.func_env).clone(), + ctx.func_env.clone(), callee.clone(), ) { Some(sig) => { @@ -7557,7 +7557,7 @@ pub fn classify_argument( None => "".to_string(), }; let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), type_name, ); let cf = Rc::new({ @@ -7829,10 +7829,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), authored_name_at( (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -8063,11 +8063,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8115,7 +8115,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( @@ -8164,16 +8164,16 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: Rc::new(ExprData::ExprCall { call_semantics: cs, descent_evidence: Some(evidence), @@ -8232,7 +8232,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type, ); Rc::new({ @@ -8275,7 +8275,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() + && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8285,7 +8285,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), (*ctx.type_env).clone().source_indices.clone(), ); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8321,18 +8321,18 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { @@ -8346,14 +8346,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: (*ic.type_env).clone(), + type_env: ic.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: (*ic.func_env).clone(), + func_env: ic.func_env.clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8369,7 +8369,7 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { @@ -8383,14 +8383,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8406,11 +8406,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8419,14 +8419,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8451,16 +8451,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: v1_rt::concat(Rc::new(vec![annotated_scrut]), annotated_arms), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8504,7 +8504,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8520,7 +8520,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel, }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }) } @@ -8528,7 +8528,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( @@ -8540,7 +8540,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }), }; @@ -8559,16 +8559,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: annotated_children, connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8621,7 +8621,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8637,7 +8637,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8645,7 +8645,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8659,7 +8659,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8682,16 +8682,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: threaded.children.clone(), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8767,7 +8767,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type, ) .iter() @@ -8855,7 +8855,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), @@ -8875,14 +8875,14 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -8890,7 +8890,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -8948,16 +8948,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -8985,7 +8985,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), fe_var, @@ -8993,18 +8993,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; @@ -9017,16 +9017,16 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota children: Rc::new(vec![annotated_coll, annotated_body]), connective: body.connective.clone(), params: body.params.clone(), - inferred: (*body.inferred).clone(), + inferred: body.inferred.clone(), return_cardinality: body.return_cardinality.clone(), uses: body.uses.clone(), - body: (*body.body).clone(), - transport: (*body.transport).clone(), + body: body.body.clone(), + transport: body.transport.clone(), properties: body.properties.clone(), - type_annotation: (*body.type_annotation).clone(), + type_annotation: body.type_annotation.clone(), is_self_recursive: body.is_self_recursive.clone(), has_non_tail_self_call: body.has_non_tail_self_call.clone(), - match_pattern: (*body.match_pattern).clone(), + match_pattern: body.match_pattern.clone(), expr_data: body.expr_data.clone(), ident: None, }) @@ -9042,7 +9042,7 @@ pub fn resolved_type_name( n: Rc, source_indices: Rc>>, ) -> String { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => authored_name_at(source_indices, rt), _ => match n.children.clone().first().cloned() { Some(c) => authored_name_at(source_indices, c), @@ -9660,7 +9660,7 @@ pub fn classify_body_per_field( let terminal = (*unwrapped.expr).clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( - terminal, + Rc::new(terminal), param_names, param_types, type_env.clone(), @@ -9974,7 +9974,7 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = compose_callee_param_map( + let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))))))))( param_map.clone(), call_args.clone(), c.param_order.clone(), @@ -10008,7 +10008,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10016,7 +10016,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10235,7 +10235,7 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - (*sig.inferred).clone(), + sig.inferred.clone(), ) == parent_enum) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -10564,7 +10564,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10586,7 +10586,7 @@ pub fn populate_output_provenance( None => acc.clone(), } } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { if !expr_has_self_call( body.clone(), @@ -10605,7 +10605,7 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = match (*item.inferred) + let variant_prov = match item.inferred .clone() .as_deref() .cloned() @@ -10649,7 +10649,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10763,19 +10763,19 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: (*p.inferred).clone(), + inferred: p.inferred.clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: (*p.body).clone(), - transport: (*p.transport).clone(), + body: p.body.clone(), + transport: p.transport.clone(), properties: p.properties.clone(), - type_annotation: (*p.type_annotation).clone(), + type_annotation: p.type_annotation.clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: (*p.match_pattern).clone(), + match_pattern: p.match_pattern.clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -10826,19 +10826,19 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), - inferred: (*p.inferred).clone(), + inferred: p.inferred.clone(), return_cardinality: p.return_cardinality.clone(), uses: p.uses.clone(), - body: (*p.body).clone(), - transport: (*p.transport).clone(), + body: p.body.clone(), + transport: p.transport.clone(), properties: p.properties.clone(), - type_annotation: (*p.type_annotation).clone(), + type_annotation: p.type_annotation.clone(), is_self_recursive: p.is_self_recursive.clone(), has_non_tail_self_call: p.has_non_tail_self_call.clone(), - match_pattern: (*p.match_pattern).clone(), + match_pattern: p.match_pattern.clone(), expr_data: p.expr_data.clone(), ident: None, }), @@ -10890,16 +10890,16 @@ pub fn infer_transport_node( children: t.children.clone(), connective: t.connective.clone(), params: t.params.clone(), - inferred: (*t.inferred).clone(), + inferred: t.inferred.clone(), return_cardinality: t.return_cardinality.clone(), uses: t.uses.clone(), - body: (*t.body).clone(), - transport: (*t.transport).clone(), + body: t.body.clone(), + transport: t.transport.clone(), properties: prop_result.props.clone(), - type_annotation: (*t.type_annotation).clone(), + type_annotation: t.type_annotation.clone(), is_self_recursive: t.is_self_recursive.clone(), has_non_tail_self_call: t.has_non_tail_self_call.clone(), - match_pattern: (*t.match_pattern).clone(), + match_pattern: t.match_pattern.clone(), expr_data: t.expr_data.clone(), ident: None, })), @@ -10911,20 +10911,20 @@ pub fn infer_transport_node( pub fn infer_item(item: Rc, scope: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let typed_anno = (*item.type_annotation).clone(); + let typed_anno = item.type_annotation.clone(); let transport_scope = if ((item.params.clone().len() as i64) > 0) { build_params_scope(scope.clone(), item.params.clone()) } else { scope.clone() }; - let transport_result = infer_transport_node((*item.transport).clone(), transport_scope); - let typed_transport = (*transport_result.transport).clone(); + let transport_result = infer_transport_node(item.transport.clone(), transport_scope); + let typed_transport = transport_result.transport.clone(); let transport_diags = transport_result.diagnostics.clone(); let props_result = infer_auth_source_properties(item.properties.clone(), scope.clone()); let typed_properties = props_result.props.clone(); let props_diags = props_result.diagnostics.clone(); if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -10956,7 +10956,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc diagnostics: v1_rt::concat(transport_diags, props_diags), }) } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { { let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( @@ -10973,25 +10973,25 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ) }, ); - let fn_return_expected = if ((*item.inferred).clone() != None) { + let fn_return_expected = if (item.inferred.clone() != None) { Some(resolved_type(item.clone())) } else { None }; let body_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), fn_scope.clone(), fn_return_expected, ); let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); - let inferred_ret = if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + let inferred_ret = if (item.inferred.clone() != None) { + item.inferred.clone() } else { - (*body_typed.inferred).clone() + body_typed.inferred.clone() }; let is_recursive = expr_has_self_call( - body_typed.clone(), + Rc::new(body_typed.clone()), authored_name_at( (*scope.type_env).clone().source_indices.clone(), item.clone(), @@ -10999,7 +10999,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - annotate_descent_evidence( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))))))))( body_typed.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -11011,7 +11011,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.func_env).clone(), ) } else { - body_typed.clone() + Rc::new(body_typed.clone()) }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11037,7 +11037,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno, is_self_recursive: is_recursive, has_non_tail_self_call: expr_has_non_tail_self_call( - body_typed, + Rc::new(body_typed), authored_name_at( (*scope.type_env).clone().source_indices.clone(), item.clone(), @@ -11056,13 +11056,13 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.inferred).clone() != None)) + if (((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() != None)) { { let fn_scope = scope.clone(); let body_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), fn_scope, Some(resolved_type(item.clone())), ); @@ -11075,10 +11075,10 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ident_span: item.ident_span.clone(), children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(body_typed), + body: Some(Rc::new(body_typed)), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11096,27 +11096,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { { - let data_expected = if ((*item.type_annotation).clone() != None) { - Some((*item.type_annotation).clone().clone().unwrap()) + let data_expected = if (item.type_annotation.clone() != None) { + Some(item.type_annotation.clone().clone().unwrap()) } else { None }; let val_result = infer_expr( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), scope.clone(), data_expected, ); let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let inferred_ret = if ((*item.type_annotation).clone() != None) { + let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { - node: (*item.type_annotation).clone().clone().unwrap(), + node: item.type_annotation.clone().clone().unwrap(), })) } else { - (*val_typed.inferred).clone() + val_typed.inferred.clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11128,7 +11128,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(val_typed), + body: Some(Rc::new(val_typed)), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11147,7 +11147,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc } } else { if (((item.params.clone().len() as i64) > 0) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11165,8 +11165,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + inferred: if (item.inferred.clone() != None) { + item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11202,8 +11202,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if ((*item.inferred).clone() != None) { - (*item.inferred).clone() + inferred: if (item.inferred.clone() != None) { + item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, @@ -11265,7 +11265,7 @@ pub fn type_node_label( if (authored.clone() != "".to_string()) { authored } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id, _ => n.name.clone(), } @@ -11281,7 +11281,7 @@ pub fn param_is_generic_decl( let pt = param_node_type_expr(p.clone()); let pname = param_node_name_at(p.clone(), source_indices.clone()); let tname = type_node_label(pt.clone(), source_indices.clone()); - let type_expr_is_var = match (*pt.inferred).clone() { + let type_expr_is_var = match pt.inferred.clone() { Some(inf) => is_type_variable(inf), None => false, }; @@ -11304,7 +11304,7 @@ pub fn unify_generics( let f_bare = (((formal.children.clone().len() as i64) == 0) && (formal.connective.clone() == Connective::NoConnective)); if ((f_bare.clone() - || match (*formal.inferred).clone().as_deref().cloned() { + || match formal.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: _, .. }) => true, _ => false, }) @@ -11409,7 +11409,7 @@ pub fn unify_record_lit_field_walk( { Some(fi) => { let actual_value = field_init_node_value(fi.clone()); - let field_formal = match (*sf.inferred).clone().as_deref().cloned() { + let field_formal = match sf.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; @@ -11540,7 +11540,7 @@ pub fn substitute_generics_apply( source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => { match v1_rt::map_get(&subst, tv_id) { Some(c) => c, @@ -11581,7 +11581,7 @@ pub fn substitute_generics_apply( } __result }); - let new_inferred = match (*n.inferred).clone().as_deref().cloned() { + let new_inferred = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let new_rt = substitute_generics_apply( rt.clone(), @@ -11589,16 +11589,16 @@ pub fn substitute_generics_apply( source_indices.clone(), ); if v1_rt::rc_ptr_eq(new_rt.clone(), rt) { - (*n.inferred).clone() + n.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: new_rt })) } } - _ => (*n.inferred).clone(), + _ => n.inferred.clone(), }; if ((v1_rt::rc_vec_ptr_eq(new_children.clone(), n.children.clone()) && v1_rt::rc_vec_ptr_eq(new_params.clone(), n.params.clone())) - && (new_inferred.clone() == (*n.inferred).clone())) + && (new_inferred.clone() == n.inferred.clone())) { n.clone() } else { @@ -11612,13 +11612,13 @@ pub fn substitute_generics_apply( inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -11646,7 +11646,7 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps((*b.resolved).clone(), source_indices); + let deps0 = node_type_deps(b.resolved.clone(), source_indices); let is_bare_self = (((((*b.resolved).clone().connective.clone() == Connective::NoConnective) && (((*b.resolved).clone().children.clone().len() as i64) == 0)) @@ -11768,7 +11768,7 @@ pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12187,7 +12187,7 @@ pub fn build_type_env( ), "'".to_string(), ), - span: (*imp.target_module).clone().clone().unwrap().span.clone(), + span: imp.target_module.clone().clone().unwrap().span.clone(), }), module_name_str.clone(), )]), @@ -12198,7 +12198,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12241,9 +12241,9 @@ pub fn build_type_env( ) } } else { - if ((((*item.inferred).clone() != None) + if (((item.inferred.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { { let alias_node = Rc::new(Node { @@ -12253,7 +12253,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12277,7 +12277,7 @@ pub fn build_type_env( ) } } else { - if (((*item.transport).clone() == None) + if ((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12302,8 +12302,8 @@ pub fn build_type_env( } else { if (((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + && (item.body.clone() == None)) + && (item.transport.clone() == None)) { { let bare_node = Rc::new(Node { @@ -12313,7 +12313,7 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: item.params.clone(), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12342,8 +12342,8 @@ pub fn build_type_env( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -12363,7 +12363,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let param_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12489,7 +12489,7 @@ pub fn build_type_env( v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); @@ -12721,7 +12721,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12729,7 +12729,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12740,7 +12740,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12783,9 +12783,9 @@ pub fn build_type_env_unresolved( ) } } else { - if ((((*item.inferred).clone() != None) + if (((item.inferred.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.body).clone() == None)) + && (item.body.clone() == None)) { { let alias_node = Rc::new(Node { @@ -12795,7 +12795,7 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), body: None, @@ -12819,7 +12819,7 @@ pub fn build_type_env_unresolved( ) } } else { - if (((*item.transport).clone() == None) + if ((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) { { @@ -12844,8 +12844,8 @@ pub fn build_type_env_unresolved( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() == None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -12938,7 +12938,7 @@ pub fn build_type_env_unresolved( v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); @@ -13011,11 +13011,11 @@ pub fn build_item_info( name: item_name_str, module_name: module_name, kind: kind, - service_names: if ((*item.body).clone() == None) { + service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), source_indices.clone(), ) }, @@ -13028,30 +13028,30 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name, kind: kind, - service_names: if ((*item.body).clone() == None) { + service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { collect_typed_service_calls( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), source_indices.clone(), ) }, resource_names: res_names, params: item.params.clone(), - is_self_recursive: if ((*item.body).clone() == None) { + is_self_recursive: if (item.body.clone() == None) { false } else { expr_has_self_call( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), item_name_str.clone(), source_indices.clone(), ) }, - has_non_tail_self_call: if ((*item.body).clone() == None) { + has_non_tail_self_call: if (item.body.clone() == None) { false } else { expr_has_non_tail_self_call( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), item_name_str, true, source_indices.clone(), @@ -13078,17 +13078,17 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let ritem = (*resolved.item).clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) - && ((*ritem.inferred).clone() != None)) - && ((*ritem.body).clone() != None)); + && (ritem.inferred.clone() != None)) + && (ritem.body.clone() != None)); let func_sig = if (is_func || is_zero_arg_func) { { - let declared_rt = if ((*ritem.inferred).clone() != None) { - Some(resolved_type(ritem.clone())) + let declared_rt = if (ritem.inferred.clone() != None) { + Some(resolved_type(Rc::new(ritem.clone()))) } else { None }; Some(Rc::new(DeclaredFuncSig { - name: authored_name_at(env.source_indices.clone(), ritem.clone()), + name: authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), params: ritem.params.clone(), inferred: declared_rt, is_async: ((ritem.uses.clone().len() as i64) > 0), @@ -13102,7 +13102,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = if (((*ritem.transport).clone() != None) + let svc_entries = if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { Rc::new({ @@ -13115,13 +13115,13 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { Rc::new(vec![]) }; - let svc_local = if (((*ritem.transport).clone() != None) + let svc_local = if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { { let root = namespace_root_from_properties( ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), + authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), env.source_indices.clone(), ); Some(nominal_type_binding(root)) @@ -13130,12 +13130,12 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc None }; Rc::new(ItemContribution { - resolved_item: ritem.clone(), + resolved_item: Rc::new(ritem.clone()), resolve_diagnostics: resolved.diagnostics.clone(), func_sig: func_sig, svc_entries: svc_entries, svc_local: svc_local, - item_info: build_item_info(ritem, env.source_indices.clone(), module_name.clone()), + item_info: build_item_info(Rc::new(ritem), env.source_indices.clone(), module_name.clone()), }) } } @@ -13163,7 +13163,7 @@ pub fn fold_module_contributions( }); } Some(contribution) => { - let next_func_sigs = match (*contribution.func_sig).clone() { + let next_func_sigs = match contribution.func_sig.clone() { Some(sig) => { v1_rt::rc_map_insert(func_sigs.clone(), sig.name.clone(), sig.clone()) } @@ -13174,7 +13174,7 @@ pub fn fold_module_contributions( svc_registry.clone(), authored_name_at( source_indices.clone(), - (*contribution.resolved_item).clone(), + contribution.resolved_item.clone(), ), contribution.svc_entries.clone(), ) @@ -13198,7 +13198,7 @@ pub fn fold_module_contributions( .collect::>(), ); let __tco_1 = - v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); + v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); let __tco_2 = next_func_sigs.clone(); let __tco_3 = next_svc_registry.clone(); let __tco_4 = next_svc_locals.clone(); @@ -13241,7 +13241,7 @@ pub fn insert_variant_owner_checked( ) -> Rc { match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { Some(prev) => { - let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); + let prev_name = authored_name_at(source_indices.clone(), prev.resolved.clone()); let owner_name = authored_name_at(source_indices.clone(), owner.clone()); let same_owner = (((prev_name.clone() == owner_name.clone()) && ((*prev.resolved).clone().span.clone().file.clone() @@ -13390,7 +13390,7 @@ pub fn owner_of_exported_arm( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if !import_is_all(imp.clone()) { __result.push(imp); } @@ -13485,7 +13485,7 @@ pub fn exported_coproduct_item( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if !import_is_all(imp.clone()) { __result.push(imp); } @@ -13686,7 +13686,7 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: (*resolve_result.func_env).clone(), + func_env: resolve_result.func_env.clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, variant_locals: env_variant_locals, @@ -13743,9 +13743,9 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: (*resolved.module).clone(), + module: resolved.module.clone(), items: Rc::new(vec![]), - type_env: env.clone(), + type_env: Rc::new(env.clone()), type_env_cache: env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: v1_rt::rc_empty_map::>(), @@ -13757,13 +13757,13 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), (*resolved.module).clone()); + authored_name_at(source_indices.clone(), resolved.module.clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items((*resolved.module).clone()).iter().cloned() { + for item in module_items(resolved.module.clone()).iter().cloned() { __result.push(analyze_item( item.clone(), - env.clone(), + Rc::new(env.clone()), resolved_module_name.clone(), )); } @@ -13773,22 +13773,22 @@ pub fn typecheck_module( contributions, parent_index.clone(), resolved.resolved_imports.clone(), - env.clone(), + Rc::new(env.clone()), resolved_module_name.clone(), ); let data_locals = ctx.resolved_items.clone().iter().cloned().fold( ctx.locals.clone(), |acc: Rc>>, item: Rc| { - if (((((*item.body).clone() != None) && ((item.params.clone().len() as i64) == 0)) - && ((*item.inferred).clone() == None)) - && ((*item.type_annotation).clone() != None)) + if ((((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() == None)) + && (item.type_annotation.clone() != None)) { v1_rt::rc_map_insert( acc.clone(), authored_name_at(source_indices.clone(), item.clone()), Rc::new(TypeBinding { name: authored_name_at(source_indices.clone(), item.clone()), - resolved: (*item.type_annotation).clone().clone().unwrap(), + resolved: item.type_annotation.clone().clone().unwrap(), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ) @@ -13798,8 +13798,8 @@ pub fn typecheck_module( }, ); let infer_scope = Rc::new(InferScope { - type_env: env.clone(), - func_env: (*ctx.func_env).clone(), + type_env: Rc::new(env.clone()), + func_env: ctx.func_env.clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13822,7 +13822,7 @@ pub fn typecheck_module( } __result }); - let updated_func_env = populate_output_provenance( + let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))))))))( typed_items.clone(), (*ctx.func_env).clone(), env.clone(), @@ -13832,36 +13832,36 @@ pub fn typecheck_module( let mut __result = Vec::new(); for item in typed_items.iter().cloned() { __result.push( - if (item.is_self_recursive.clone() && ((*item.body).clone() != None)) { + if (item.is_self_recursive.clone() && (item.body.clone() != None)) { Rc::new(Node { name: item.name.clone(), span: item.span.clone(), ident_span: item.ident_span.clone(), children: item.children.clone(), params: item.params.clone(), - inferred: (*item.inferred).clone(), + inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), body: Some(annotate_descent_evidence( - (*item.body).clone().clone().unwrap(), - authored_name_at(source_indices.clone(), item.clone()), + item.body.clone().clone().unwrap(), + authored_name_at(source_indices.clone(), Rc::new(item.clone())), item.params.clone(), - env.clone(), + Rc::new(env.clone()), data_locals.clone(), updated_func_env.clone(), )), connective: item.connective.clone(), - transport: (*item.transport).clone(), + transport: item.transport.clone(), properties: item.properties.clone(), - type_annotation: (*item.type_annotation).clone(), + type_annotation: item.type_annotation.clone(), is_self_recursive: item.is_self_recursive.clone(), has_non_tail_self_call: item.has_non_tail_self_call.clone(), - match_pattern: (*item.match_pattern).clone(), + match_pattern: item.match_pattern.clone(), expr_data: item.expr_data.clone(), ident: None, }) } else { - item.clone() + Rc::new(item.clone()) }, ); } @@ -13869,7 +13869,7 @@ pub fn typecheck_module( }); let typed_base = module_node( resolved_module_name, - module_imports((*resolved.module).clone()), + module_imports(resolved.module.clone()), ctx.resolved_items.clone(), (*resolved.module).clone().span.clone(), ); @@ -13881,7 +13881,7 @@ pub fn typecheck_module( typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: env, + type_env: Rc::new(env), type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), @@ -14027,8 +14027,8 @@ pub fn topo_resolve_types( Some(binding) => { let pre = (*binding.resolved).clone(); let result = - resolve_node(pre.clone(), env.clone(), module_name.clone()); - let resolved = preserve_nominal_brand_on_resolve( + resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14090,8 +14090,8 @@ pub fn topo_resolve_types( match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { let pre = (*binding.resolved).clone(); - let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); - let resolved = preserve_nominal_brand_on_resolve( + let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14182,7 +14182,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); + let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14205,7 +14205,7 @@ pub fn collect_parent_envs( ), "'".to_string(), ), - span: (*imp.target_module).clone().clone().unwrap().span.clone(), + span: imp.target_module.clone().clone().unwrap().span.clone(), }), resolved_mod_name.clone(), )]), @@ -14557,7 +14557,7 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), (*typed.module).clone()), + authored_name_at(source_indices.clone(), typed.module.clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); @@ -14695,7 +14695,7 @@ pub fn direct_import_exporter_count( ) -> i64 { (Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { if { let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { @@ -14773,7 +14773,7 @@ pub fn rewire_type_env_import_str_binding_identity( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -14817,7 +14817,7 @@ pub fn rewire_type_env_import_str_binding_identity( }, ); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { bindings: (*m.type_env).clone().bindings.clone(), @@ -14831,7 +14831,7 @@ pub fn rewire_type_env_import_str_binding_identity( intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), + func_env: m.func_env.clone(), item_registry: m.item_registry.clone(), }) }); @@ -15052,14 +15052,14 @@ pub fn rewire_type_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, ); let shared_kernel = match modules.clone().iter().cloned().fold( None, - |acc: Optional, m: Rc| match acc.clone() { + |acc, m: Rc| match acc.clone() { Some(_) => acc.clone(), None => match (*m.type_env).clone().parents.clone().last().cloned() { Some(kernel) => Some(kernel.clone()), @@ -15073,7 +15073,7 @@ pub fn rewire_type_env_parent_links( source_indices.clone(), (*m.type_env).clone().intern_table.clone(), ), - None => compiler_kernel_type_env(source_indices.clone(), empty_intern_table()), + None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), }, }; Rc::new({ @@ -15082,7 +15082,7 @@ pub fn rewire_type_env_parent_links( __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = @@ -15090,7 +15090,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - (*parent.type_env).clone(), + parent.type_env.clone(), )]), None => Rc::new(vec![]), } @@ -15102,7 +15102,7 @@ pub fn rewire_type_env_parent_links( __result }); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { bindings: (*m.type_env).clone().bindings.clone(), @@ -15122,7 +15122,7 @@ pub fn rewire_type_env_parent_links( intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), + func_env: m.func_env.clone(), item_registry: m.item_registry.clone(), }) }); @@ -15142,7 +15142,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -15153,7 +15153,7 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = @@ -15170,9 +15170,9 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), - type_env: (*m.type_env).clone(), + type_env: m.type_env.clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: (*m.func_env).clone().local.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index 0a3eab54410..3e81ee3fec5 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -131,7 +131,7 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - (*parts.key_type).clone(), + parts.key_type.clone(), normed_index, source_indices.clone(), ) { @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality((*parts.value_type).clone()), + with_optional_cardinality(parts.value_type.clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b46b0e46826..233e1970848 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -284,7 +284,7 @@ pub fn build_struct_field_summaries( |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); - if ((*child.inferred).clone() == None) { + if (child.inferred.clone() == None) { acc.clone() } else { { @@ -452,7 +452,7 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match (*child.inferred) + |acc: Rc>, child: Rc| match child.inferred .clone() .as_deref() .cloned() @@ -462,8 +462,8 @@ pub fn build_field_type_map( source_indices.clone(), normalize_access_type_node(ft.clone()), ); - let ft_is_type_var = if ((*ft.inferred).clone() != None) { - is_type_variable((*ft.inferred).clone().clone().unwrap()) + let ft_is_type_var = if (ft.inferred.clone() != None) { + is_type_variable(ft.inferred.clone().clone().unwrap()) } else { false }; @@ -488,7 +488,7 @@ pub fn build_type_summary( { if (((item.connective.clone() == Connective::NoConnective) || (item.connective.clone() == Connective::Arrow)) - || ((*item.transport).clone() != None)) + || (item.transport.clone() != None)) { return None; } @@ -503,7 +503,7 @@ pub fn build_type_summary( let has_fn = { let mut __found = false; for child in item.children.clone().iter().cloned() { - if match (*child.inferred).clone().as_deref().cloned() { + if match child.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.connective.clone() == Connective::Arrow) } @@ -663,7 +663,7 @@ pub fn add_emit_item_summary( let v_has_fn = { let mut __found = false; for vc in variant.children.clone().iter().cloned() { - if match (*vc.inferred).clone().as_deref().cloned() { + if match vc.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => (rt.connective.clone() == Connective::Arrow), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 481902244d0..66dbe7cd5db 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -209,14 +209,14 @@ pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 739ca5e4f80..5271f9b41f5 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -164,26 +164,26 @@ pub fn inferred_to_outputs( pub fn item_kind(item: Rc) -> ItemKind { { let kind = if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { ItemKind::TypeItem } else { - if ((*item.transport).clone() != None) { + if (item.transport.clone() != None) { ItemKind::ServiceItem } else { - if (((*item.body).clone() != None) && ((item.uses.clone().len() as i64) > 0)) { + if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if (((*item.body).clone() != None) && ((item.params.clone().len() as i64) > 0)) + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { ItemKind::FnItem } else { - if (((*item.body).clone() != None) - && ((*item.type_annotation).clone() != None)) + if ((item.body.clone() != None) + && (item.type_annotation.clone() != None)) { ItemKind::DataItem } else { - if ((*item.body).clone() != None) { + if (item.body.clone() != None) { ItemKind::FnItem } else { ItemKind::OtherItem diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index fbc036619f9..bfb4b339f09 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } @@ -149,7 +149,7 @@ pub fn lookup_field_type_node( } } } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { lookup_field_type_node( target, @@ -235,8 +235,8 @@ pub fn resolve_scrutinee_type_node_seen( seen: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; @@ -246,9 +246,9 @@ pub fn resolve_scrutinee_type_node_seen( let normed = normalize_access_type_node(n); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) - && ((*normed.inferred).clone() != None)) + && (normed.inferred.clone() != None)) { - match (*normed.inferred).clone().as_deref().cloned() { + match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { resolve_scrutinee_type_node_seen(env.clone(), target, seen.clone()) } @@ -260,18 +260,18 @@ pub fn resolve_scrutinee_type_node_seen( { { let canonical = authored_name(env.clone(), normed.clone()); - if ((*normed.inferred).clone() != None) { + if (normed.inferred.clone() != None) { { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; - match (*normed.inferred).clone().as_deref().cloned() { + match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { if ((((authored_name(env.clone(), target.clone()) == canonical) - && ((*target.inferred).clone() == None)) + && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { @@ -303,7 +303,7 @@ pub fn resolve_scrutinee_type_node_seen( Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) == canonical) - && ((*resolved.inferred).clone() == None)) + && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) @@ -469,10 +469,10 @@ pub struct StructuralMethodLookup { } pub fn product_field_result_type(field: Rc) -> Option> { - match (*field.inferred).clone().as_deref().cloned() { + match field.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match (*rt.inferred).clone().as_deref().cloned() { + match rt.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Some(return_type), @@ -497,7 +497,7 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw) } else { - Some((*make_container_type("Witness".to_string(), raw).ty).clone()) + Some(make_container_type("Witness".to_string(), raw).ty.clone()) } } None => None, @@ -582,7 +582,7 @@ pub fn lookup_structural_method( { { let base_result = lookup_field_in_product( - (*enriched.ty).clone(), + enriched.ty.clone(), method_name.clone(), source_indices.clone(), ); @@ -611,8 +611,8 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: (*mfr.field_node).clone(), - result_type: (*mfr.result_type).clone(), + field_node: mfr.field_node.clone(), + result_type: mfr.result_type.clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), algebra_template: Some(t), @@ -658,7 +658,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: (*mfr.field_node).clone(), + method_def: mfr.field_node.clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -666,7 +666,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some((*mfr.result_type).clone()), + result_type: Some(mfr.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -684,7 +684,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some((*svc_result.result_type).clone()), + result_type: Some(svc_result.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index aea21c02675..bae25f94a90 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,24 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - (*make_map_type( + Rc::new((*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) .ty) - .clone() + .clone()) } pub fn list_of_type_variable(id: String) -> Rc { - (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() + make_container_type("List".to_string(), type_variable_node(id)).ty.clone() } pub fn list_of_element(element: Rc) -> Rc { - (*make_container_type("List".to_string(), element).ty).clone() + make_container_type("List".to_string(), element).ty.clone() } pub fn witness_of_element(element: Rc) -> Rc { - (*make_container_type("Witness".to_string(), element).ty).clone() + make_container_type("Witness".to_string(), element).ty.clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -129,9 +129,9 @@ pub fn builtin_function_registry() -> Rc>> { ) .ty) .clone(); - let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); - let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty); + let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), Rc::new(set_ty.clone())); + let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), Rc::new(set_ty.clone())); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty)); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 2ead641ed2f..7b2231d3838 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -80,14 +80,14 @@ pub fn expand_scrut_from_decl( ) -> Rc { { let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = ((((*decl.inferred).clone() != None) + let has_inferred_alias = (((decl.inferred.clone() != None) && (decl.connective.clone() == Connective::NoConnective)) && ((decl.children.clone().len() as i64) == 0)); if decl_is_disj { decl } else { if has_inferred_alias { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let subst = generic_use_slot_bindings(scrut_node, env.clone()); substitute_type_slots(target, subst, name, env.source_indices.clone()) @@ -114,13 +114,13 @@ pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc } else { { let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = (((*decl.inferred).clone() != None) + let has_inferred_body = ((decl.inferred.clone() != None) && (decl.connective.clone() == Connective::NoConnective)); if def_is_disj { decl } else { if has_inferred_body { - match (*decl.inferred).clone().as_deref().cloned() { + match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_is_disj = (target.connective.clone() == Connective::Disj); @@ -155,7 +155,7 @@ pub fn expand_scrut_type_for_variant_lookup( if (is_disj.clone() || is_witness.clone()) { break scrut_node.clone(); } else { - match (*scrut_node.inferred).clone().as_deref().cloned() { + match scrut_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); scrut_node = __tco_0; @@ -374,8 +374,8 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { pub fn pattern_subject_from_node(mut n: Rc) -> Rc { loop { - let is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; @@ -384,9 +384,9 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && ((*n.inferred).clone() != None)) + && (n.inferred.clone() != None)) { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let __tco_0 = target.clone(); n = __tco_0; diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 8630b2b4999..18ae25272a3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -90,8 +90,8 @@ pub fn unit_variant_in_coproduct( } pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc { - if ((ty.connective.clone() == Connective::NoConnective) && ((*ty.inferred).clone() != None)) { - match (*ty.inferred).clone().as_deref().cloned() { + if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { + match ty.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target, _ => ty, } @@ -144,7 +144,7 @@ pub fn collect_unit_variant_phantom_matches( Rc::new(vec![]), |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( env.clone(), - structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), + structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), variant_name.clone(), ) { Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), @@ -182,16 +182,16 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc, env: Rc, module_name: S Some(resolved) => { let structural = if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred).clone().as_deref().cloned() { + match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { (*resolve_node_bounded( target.clone(), @@ -268,17 +268,17 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S }; if ((((brand.clone() != "".to_string()) && (brand.clone() - != authored_name_at(source_indices.clone(), structural.clone()))) + != authored_name_at(source_indices.clone(), Rc::new(structural.clone())))) && !is_declared_container_alias_spelling(brand)) - && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices)) + && !is_transparent_primitive_alias_rhs(Rc::new(structural.clone()), source_indices)) { - with_authored_identity(n.clone(), structural) + with_authored_identity(n.clone(), Rc::new(structural)) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred).clone().as_deref().cloned() { + match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_resolved = (*resolve_node_bounded( target, @@ -288,7 +288,7 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S ) .resolved) .clone(); - with_authored_identity(n.clone(), target_resolved) + with_authored_identity(n.clone(), Rc::new(target_resolved)) } _ => resolved, } @@ -398,7 +398,7 @@ pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Op .cloned() { Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => Some((*b.resolved).clone()), + Some(b) => Some(b.resolved.clone()), None => None, }, None => None, @@ -458,7 +458,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { if is_container_type(n.name.clone()) { false } else { - if ((*decl.inferred).clone() != None) { + if (decl.inferred.clone() != None) { true } else { true @@ -481,8 +481,8 @@ pub fn substitute_type_slots( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_slot = (((((n.children.clone().len() as i64) == 0) && (n.connective.clone() == Connective::NoConnective)) - && ((*n.body).clone() == None)) - && ((*n.inferred).clone() == None)); + && (n.body.clone() == None)) + && (n.inferred.clone() == None)); if is_slot { match v1_rt::map_get( &slot_bindings, @@ -520,18 +520,18 @@ pub fn substitute_type_slots( children: substituted_args.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: (*child.inferred).clone(), + inferred: child.inferred.clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: child.properties.clone(), - type_annotation: (*child.type_annotation).clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: child.is_self_recursive.clone(), has_non_tail_self_call: child .has_non_tail_self_call .clone(), - match_pattern: (*child.match_pattern).clone(), + match_pattern: child.match_pattern.clone(), expr_data: child.expr_data.clone(), ident: None, }) @@ -548,7 +548,7 @@ pub fn substitute_type_slots( } __result }); - let new_inferred = match (*n.inferred).clone().as_deref().cloned() { + let new_inferred = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Some(Rc::new(InferredNode::Resolved { node: substitute_type_slots( @@ -559,7 +559,7 @@ pub fn substitute_type_slots( ), })) } - _ => (*n.inferred).clone(), + _ => n.inferred.clone(), }; Rc::new(Node { name: n.name.clone(), @@ -571,13 +571,13 @@ pub fn substitute_type_slots( inferred: new_inferred, return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -621,7 +621,7 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - (*resolve_node_bounded(target, env.clone(), module_name, (depth + 1)).resolved).clone() + resolve_node_bounded(target, env.clone(), module_name, (depth + 1)).resolved.clone() } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), @@ -637,9 +637,9 @@ pub fn resolve_alias_target( pub fn is_parametric_type_alias_decl(item: Rc) -> bool { ((((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) - && ((*item.inferred).clone() != None)) + && (item.body.clone() == None)) + && (item.transport.clone() == None)) + && (item.inferred.clone() != None)) } pub fn resolve_nominal_alias_rhs( @@ -687,13 +687,13 @@ pub fn resolve_nominal_alias_rhs( children: resolved_args, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -738,7 +738,7 @@ pub fn resolve_node_bounded( { let is_product = (n.connective.clone() == Connective::Conj); if is_product { - if ((*n.type_annotation).clone() != None) { + if (n.type_annotation.clone() != None) { match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( @@ -754,16 +754,16 @@ pub fn resolve_node_bounded( name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: Rc::new(vec![base_resolved]), + children: Rc::new(vec![Rc::new(base_resolved)]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -783,7 +783,7 @@ pub fn resolve_node_bounded( let child_results = Rc::new({ let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { - __result.push(if ((*child.inferred).clone() == None) { + __result.push(if (child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: child.clone(), diagnostics: Rc::new(vec![]), @@ -809,20 +809,20 @@ pub fn resolve_node_bounded( params: child.params.clone(), inferred: Some(Rc::new( InferredNode::Resolved { - node: rt_resolved.clone(), + node: Rc::new(rt_resolved.clone()), }, )), return_cardinality: child .return_cardinality .clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: (*child.type_annotation) + type_annotation: child.type_annotation .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -859,13 +859,13 @@ pub fn resolve_node_bounded( children: resolved_children, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -892,7 +892,7 @@ pub fn resolve_node_bounded( let inner_resolved = (*inner_result.resolved).clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { - resolved: with_optional_cardinality(inner_resolved), + resolved: with_optional_cardinality(Rc::new(inner_resolved)), diagnostics: inner_diags, }) } @@ -908,7 +908,7 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if ((*field_child.inferred).clone() == None) + if (field_child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), @@ -962,14 +962,14 @@ pub fn resolve_node_bounded( connective: field_child.connective.clone(), params: field_child.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: rt_resolved.clone(), + node: Rc::new(rt_resolved.clone()), })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), - body: (*field_child.body).clone(), - transport: (*field_child.transport).clone(), + body: field_child.body.clone(), + transport: field_child.transport.clone(), properties: v1_rt::concat(field_child.properties.clone(), rt_resolved.properties.clone()), - type_annotation: (*field_child.type_annotation).clone(), + type_annotation: field_child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1008,16 +1008,16 @@ pub fn resolve_node_bounded( children: resolved_fields.clone(), connective: variant_child.connective.clone(), params: variant_child.params.clone(), - inferred: (*variant_child.inferred).clone(), + inferred: variant_child.inferred.clone(), return_cardinality: variant_child .return_cardinality .clone(), uses: variant_child.uses.clone(), - body: (*variant_child.body).clone(), - transport: (*variant_child.transport).clone(), + body: variant_child.body.clone(), + transport: variant_child.transport.clone(), properties: variant_child.properties.clone(), - type_annotation: (*variant_child - .type_annotation) + type_annotation: variant_child + .type_annotation .clone(), is_self_recursive: false, has_non_tail_self_call: false, @@ -1053,13 +1053,13 @@ pub fn resolve_node_bounded( children: resolved_variants, connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1173,18 +1173,18 @@ pub fn resolve_node_bounded( Some(arg) => v1_rt::rc_map_insert( acc.clone(), slot_name.clone(), - arg.clone(), + Rc::new(arg.clone()), ), None => acc.clone(), } }, ); - let is_parameterized_alias = ((((*decl.inferred).clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() != None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias { { - let alias_target = match (*decl.inferred).clone().as_deref().cloned() { + let alias_target = match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { substitute_type_slots( target, @@ -1210,16 +1210,16 @@ pub fn resolve_node_bounded( children: (*target_result.resolved).clone().children.clone(), connective: (*target_result.resolved).clone().connective.clone(), params: Rc::new(vec![]), - inferred: (*(*target_result.resolved).clone().inferred).clone(), + inferred: (*target_result.resolved).clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: (*target_result.resolved).clone().properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1235,13 +1235,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: (*target_result.resolved).clone().properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive, has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1276,16 +1276,16 @@ pub fn resolve_node_bounded( children: substituted_children, connective: decl.connective.clone(), params: Rc::new(vec![]), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: decl.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }); @@ -1302,13 +1302,13 @@ pub fn resolve_node_bounded( })), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: decl.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive, has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -1350,7 +1350,7 @@ pub fn resolve_node_bounded( ); let val_resolved = (*val_result.resolved).clone(); let val_diags = val_result.diagnostics.clone(); - let key_param_name = if ((*key_child_node.inferred).clone() != None) { + let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { @@ -1358,7 +1358,7 @@ pub fn resolve_node_bounded( None => authored_name(env.clone(), key_child_node.clone()), } }; - let val_param_name = if ((*val_child_node.inferred).clone() != None) { + let val_param_name = if (val_child_node.inferred.clone() != None) { authored_name(env.clone(), val_child_node.clone()) } else { match container_param_name(type_name.clone(), 1) { @@ -1374,7 +1374,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: key_resolved, + node: Rc::new(key_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1396,7 +1396,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: val_resolved, + node: Rc::new(val_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1418,13 +1418,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_key_child, resolved_val_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1449,7 +1449,7 @@ pub fn resolve_node_bounded( ); let el_resolved = (*el_result.resolved).clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if ((*child_node.inferred).clone() + let el_param_name = if (child_node.inferred.clone() != None) { authored_name(env.clone(), child_node.clone()) @@ -1469,7 +1469,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: el_resolved, + node: Rc::new(el_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1491,13 +1491,13 @@ pub fn resolve_node_bounded( children: Rc::new(vec![resolved_child]), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -1516,7 +1516,7 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = match (*n.inferred) + let n_target_is_coproduct_container = match n.inferred .clone() .as_deref() .cloned() @@ -1552,9 +1552,9 @@ pub fn resolve_node_bounded( == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && ((*resolved.inferred).clone() != None)) + && (resolved.inferred.clone() != None)) { - match (*resolved.inferred) + match resolved.inferred .clone() .as_deref() .cloned() @@ -1612,10 +1612,10 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if ((*n.inferred).clone() != None) + let n_is_error = if (n.inferred.clone() != None) { is_compiler_error( - (*n.inferred).clone().clone().unwrap(), + n.inferred.clone().clone().unwrap(), ) } else { false @@ -1623,9 +1623,9 @@ pub fn resolve_node_bounded( let n_is_callable = ((n.params.clone().len() as i64) > 0); let n_is_type_var = - if ((*n.inferred).clone() != None) { + if (n.inferred.clone() != None) { is_type_variable( - (*n.inferred).clone().clone().unwrap(), + n.inferred.clone().clone().unwrap(), ) } else { false @@ -1787,10 +1787,10 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc::new(FieldResult { field: make_field_node( field_node_name_at(field.clone(), env.source_indices.clone()), - type_resolved, + Rc::new(type_resolved), field_node_cardinality(field.clone()), match default_resolved { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1816,22 +1816,22 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> connective: authored_type.connective.clone(), params: authored_type.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_resolved.clone(), + node: Rc::new(type_resolved.clone()), })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), - body: (*authored_type.body).clone(), - transport: (*authored_type.transport).clone(), + body: authored_type.body.clone(), + transport: authored_type.transport.clone(), properties: type_resolved.properties.clone(), - type_annotation: (*authored_type.type_annotation).clone(), + type_annotation: authored_type.type_annotation.clone(), is_self_recursive: authored_type.is_self_recursive.clone(), has_non_tail_self_call: authored_type.has_non_tail_self_call.clone(), - match_pattern: (*authored_type.match_pattern).clone(), + match_pattern: authored_type.match_pattern.clone(), expr_data: authored_type.expr_data.clone(), ident: None, }) } else { - type_resolved.clone() + Rc::new(type_resolved.clone()) }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), @@ -1879,7 +1879,7 @@ pub fn resolve_resource_use( Rc::new(ResourceUseResult { resource_use: make_resource_use_node( resource_use_name_at(ru.clone(), env.source_indices.clone()), - type_resolved, + Rc::new(type_resolved), ru.span.clone(), node_name_span(ru.clone()), ), @@ -1900,7 +1900,7 @@ pub fn resolve_named_arg( Rc::new(NamedArgResolveResult { arg: make_arg_node( arg_name_at(arg.clone(), env.source_indices.clone()), - value_expr, + Rc::new(value_expr), arg.span.clone(), node_name_span(arg.clone()), ), @@ -1925,7 +1925,7 @@ pub fn resolve_field_init( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(field_init.clone(), env.source_indices.clone()), - value_expr, + Rc::new(value_expr), field_init.span.clone(), node_name_span(field_init.clone()), ), @@ -1957,10 +1957,10 @@ pub fn resolve_match_arm( arm: make_arm_node( arm_pattern(arm.clone()), match guard_result { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, - body_expr, + Rc::new(body_expr), arm.span.clone(), ), diagnostics: v1_rt::concat(guard_diags, body_diags), @@ -1984,7 +1984,7 @@ pub fn resolve_string_part( let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { - expr: resolved_expr, + expr: Rc::new(resolved_expr), }), diagnostics: expr_diags, }) @@ -2016,7 +2016,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - (*val_result.expr).clone(), + val_result.expr.clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2082,7 +2082,7 @@ pub fn resolve_transport_binding( transport: make_transport_node( resolved_props, resolved_children, - (*transport.body).clone(), + transport.body.clone(), transport.span.clone(), ), diagnostics: v1_rt::concat(v1_rt::concat(prop_diags, child_diags), body_diags), @@ -2127,7 +2127,7 @@ pub fn resolve_expr_types( }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| (*r.expr).clone()), + expr: map_children(texpr.clone(), |child| r.expr.clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2153,7 +2153,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - (*vr.expr).clone(), + vr.expr.clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2185,7 +2185,7 @@ pub fn resolve_expr_types( descent_evidence: de, }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2222,7 +2222,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*rr.expr).clone(), + expr: rr.expr.clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2247,7 +2247,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - (*vr.expr).clone(), + vr.expr.clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2280,7 +2280,7 @@ pub fn resolve_expr_types( method_semantics: ms, }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2314,7 +2314,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*sr.expr).clone(), + expr: sr.expr.clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2349,12 +2349,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match (*child.match_pattern).clone() { + match child.match_pattern.clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some((*guard_r.expr).clone()), - (*body_r.expr).clone(), + Some(guard_r.expr.clone()), + body_r.expr.clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2378,12 +2378,12 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_arm_node( - match (*child.match_pattern).clone() { + match child.match_pattern.clone() { Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, None, - (*body_r.expr).clone(), + body_r.expr.clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2414,7 +2414,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprMatch), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2452,7 +2452,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprIf), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2486,7 +2486,7 @@ pub fn resolve_expr_types( let_binding_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprLet), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2515,7 +2515,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - (*vr.expr).clone(), + vr.expr.clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2544,7 +2544,7 @@ pub fn resolve_expr_types( authored_name_at(env.source_indices.clone(), texpr.clone()), Rc::new(ExprData::ExprRecordLit { parent_enum: pe }), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2581,7 +2581,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprListLit), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2613,8 +2613,8 @@ pub fn resolve_expr_types( op: op, algebra_field: af, }), - Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(lr.diagnostics.clone(), rr.diagnostics.clone()), @@ -2631,8 +2631,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op }), - Rc::new(vec![(*r.expr).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![r.expr.clone()]), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2658,8 +2658,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), - (*texpr.inferred).clone(), + v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2683,7 +2683,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - (*r.expr).clone(), + r.expr.clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2716,7 +2716,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2752,7 +2752,7 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprBlock), resolved_children, - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: all_diags, @@ -2777,8 +2777,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(r.diagnostics.clone(), tr.diagnostics.clone()), @@ -2804,8 +2804,8 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![cr.expr.clone(), br.expr.clone()]), + texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), ), @@ -2831,8 +2831,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![br.expr.clone(), ir.expr.clone()]), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat(br.diagnostics.clone(), ir.diagnostics.clone()), @@ -2865,11 +2865,11 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprSlice), Rc::new(vec![ - (*br.expr).clone(), - (*sr.expr).clone(), - (*er.expr).clone(), + br.expr.clone(), + sr.expr.clone(), + er.expr.clone(), ]), - (*texpr.inferred).clone(), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: v1_rt::concat( @@ -2889,8 +2889,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*r.expr).clone()]), - (*texpr.inferred).clone(), + Rc::new(vec![r.expr.clone()]), + texpr.inferred.clone(), texpr.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2980,7 +2980,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3072,25 +3072,25 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let ret_result = if is_parametric_type_alias_decl(item.clone()) { - match (*item.inferred).clone().as_deref().cloned() { + match item.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: authored_rhs, .. }) => resolve_nominal_alias_rhs(authored_rhs, env.clone(), module_name.clone()), _ => resolve_optional_node( - (*item.inferred).clone(), + item.inferred.clone(), env.clone(), module_name.clone(), ), } } else { - resolve_optional_node((*item.inferred).clone(), env.clone(), module_name.clone()) + resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; let ret_resolved = (*ret_result.resolved).clone(); let ret_diags = ret_result.diagnostics.clone(); - let resolved_ret = if ((*item.inferred).clone() == None) { + let resolved_ret = if (item.inferred.clone() == None) { None } else { - Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) + Some(Rc::new(InferredNode::Resolved { node: Rc::new(ret_resolved) })) }; let use_results = Rc::new({ let mut __result = Vec::new(); @@ -3117,59 +3117,59 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) } __result }); - let body_resolved = if ((*item.body).clone() == None) { + let body_resolved = if (item.body.clone() == None) { Rc::new(ExprResolveResult { expr: item.clone(), diagnostics: Rc::new(vec![]), }) } else { resolve_expr_types( - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_body = if ((*item.body).clone() == None) { + let resolved_body = if (item.body.clone() == None) { None } else { Some((*body_resolved.expr).clone()) }; - let body_diags = if ((*item.body).clone() == None) { + let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) } else { body_resolved.diagnostics.clone() }; - let anno_resolved = if ((*item.type_annotation).clone() == None) { + let anno_resolved = if (item.type_annotation.clone() == None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), }) } else { resolve_node( - (*item.type_annotation).clone().clone().unwrap(), + item.type_annotation.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_anno = if ((*item.type_annotation).clone() == None) { + let resolved_anno = if (item.type_annotation.clone() == None) { None } else { Some((*anno_resolved.resolved).clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); - let transport_resolved = if ((*item.transport).clone() == None) { + let transport_resolved = if (item.transport.clone() == None) { Rc::new(TransportResolveResult { transport: local_transport_node(no_span()), diagnostics: Rc::new(vec![]), }) } else { resolve_transport_binding( - (*item.transport).clone().clone().unwrap(), + item.transport.clone().clone().unwrap(), env.clone(), module_name.clone(), ) }; - let resolved_transport = if ((*item.transport).clone() == None) { + let resolved_transport = if (item.transport.clone() == None) { None } else { Some((*transport_resolved.transport).clone()) @@ -3201,7 +3201,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }); let child_results = if ((item.connective.clone() == Connective::Conj) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3226,16 +3226,16 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: child.children.clone(), connective: child.connective.clone(), params: child.params.clone(), - inferred: (*child.inferred).clone(), + inferred: child.inferred.clone(), return_cardinality: child.return_cardinality.clone(), uses: child.uses.clone(), - body: (*child.body).clone(), - transport: (*child.transport).clone(), + body: child.body.clone(), + transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), (*tr.resolved).clone().properties.clone(), ), - type_annotation: (*child.type_annotation).clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3250,7 +3250,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }) } else { if ((item.connective.clone() == Connective::Disj) - && ((*item.transport).clone() == None)) + && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); @@ -3282,18 +3282,18 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: field.children.clone(), connective: field.connective.clone(), params: field.params.clone(), - inferred: (*field.inferred).clone(), + inferred: field.inferred.clone(), return_cardinality: field .return_cardinality .clone(), uses: field.uses.clone(), - body: (*field.body).clone(), - transport: (*field.transport).clone(), + body: field.body.clone(), + transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), (*tr.resolved).clone().properties.clone(), ), - type_annotation: (*field.type_annotation).clone(), + type_annotation: field.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -3328,13 +3328,13 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) children: resolved_fields.clone(), connective: variant.connective.clone(), params: variant.params.clone(), - inferred: (*variant.inferred).clone(), + inferred: variant.inferred.clone(), return_cardinality: variant.return_cardinality.clone(), uses: variant.uses.clone(), - body: (*variant.body).clone(), - transport: (*variant.transport).clone(), + body: variant.body.clone(), + transport: variant.transport.clone(), properties: variant.properties.clone(), - type_annotation: (*variant.type_annotation).clone(), + type_annotation: variant.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index acc831618e4..b2f7a482d01 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,12 +210,12 @@ pub fn expand_transitive_services_once( let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { - let has_no_body = ((*item.body).clone() == None); + let has_no_body = (item.body.clone() == None); if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names((*item.body).clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), @@ -411,7 +411,7 @@ pub fn service_op_entry( Rc::new(OpEntry { name: authored_name_at(source_indices.clone(), child.clone()), outputs: inferred_to_outputs( - (*child.inferred).clone(), + child.inferred.clone(), child.span.clone(), source_indices.clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 3de114c6872..0d94999a2ee 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -99,10 +99,10 @@ pub fn collect_func_call_edges( let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( - (*if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) { + (*if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { collect_calls_in_expr( authored_name_at(source_indices.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), local_func_set.clone(), source_indices.clone(), ) @@ -226,7 +226,7 @@ pub fn declared_to_resolved(dsig: Rc) -> Rc { Rc::new(ResolvedFuncSig { name: dsig.name.clone(), params: dsig.params.clone(), - inferred: (*dsig.inferred).clone().clone().unwrap(), + inferred: dsig.inferred.clone().clone().unwrap(), is_async: dsig.is_async.clone(), output_provenance: dsig.output_provenance.clone(), variant_provenance: dsig.variant_provenance.clone(), @@ -243,7 +243,7 @@ pub fn merge_remaining_declared( .fold( resolved, |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -277,7 +277,7 @@ pub fn topo_resolve_loop( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -358,7 +358,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -394,7 +394,7 @@ pub fn topo_resolve_loop( cycle_accum.signatures.clone(), |acc: Rc>>, dsig: Rc| { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -427,7 +427,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if ((*dsig.inferred).clone() != None) { + if (dsig.inferred.clone() != None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -498,7 +498,7 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && ((*item.body).clone() != None)) + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { __result.push(item); } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index a7c06ff5980..db063913cb3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -83,14 +83,14 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn resolved_type(n: Rc) -> Rc { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => error_type(), } } pub fn child_type_node(ch: Rc) -> Rc { - if ((*ch.inferred).clone() != None) { + if (ch.inferred.clone() != None) { resolved_type(ch.clone()) } else { ch.clone() @@ -170,16 +170,16 @@ pub fn reground_alias_carrier_identity( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }) @@ -201,16 +201,16 @@ pub fn structural_carrier_template_name( children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), ident: None, }), @@ -242,7 +242,7 @@ pub fn is_fully_resolved( source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_is_type_var = match (*n.inferred).clone() { + let self_is_type_var = match n.inferred.clone() { Some(inf) => is_type_variable(inf), None => false, }; @@ -752,16 +752,16 @@ pub fn enrich_base_with_fields( children: fields, connective: Connective::Conj, params: base.params.clone(), - inferred: (*base.inferred).clone(), + inferred: base.inferred.clone(), return_cardinality: base.return_cardinality.clone(), uses: base.uses.clone(), - body: (*base.body).clone(), - transport: (*base.transport).clone(), + body: base.body.clone(), + transport: base.transport.clone(), properties: base.properties.clone(), - type_annotation: (*base.type_annotation).clone(), + type_annotation: base.type_annotation.clone(), is_self_recursive: base.is_self_recursive.clone(), has_non_tail_self_call: base.has_non_tail_self_call.clone(), - match_pattern: (*base.match_pattern).clone(), + match_pattern: base.match_pattern.clone(), expr_data: base.expr_data.clone(), ident: None, }) @@ -865,9 +865,9 @@ pub fn instantiate_algebra_type( ContainerSource::Named { name: n, .. } => n, }; let inner_b = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, (*inner_b.ty).clone()); + let built = make_container_type(kind_name, inner_b.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -877,15 +877,15 @@ pub fn instantiate_algebra_type( AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -893,7 +893,7 @@ pub fn instantiate_algebra_type( let fb = instantiate_algebra_type(first, base.clone(), source_indices.clone()); let sb = instantiate_algebra_type(second, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -929,7 +929,7 @@ pub fn instantiate_algebra_type( }); let rb = instantiate_algebra_type(r, base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, (*rb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))))))))(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -969,14 +969,14 @@ pub fn instantiate_algebra_field( __result }); let return_b = instantiate_algebra_type( - (*template.return_type).clone(), + template.return_type.clone(), base.clone(), source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - algebra_method_field(template.name.clone(), param_types, (*return_b.ty).clone()) + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))))))))(template.name.clone(), param_types, (*return_b.ty).clone()) } else { - algebra_value_field(template.name.clone(), (*return_b.ty).clone()) + algebra_value_field(template.name.clone(), return_b.ty.clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1295,8 +1295,8 @@ pub fn apply_type_substitution( for ch in receiver.children.clone().iter().cloned() { if !({ let inner = child_type_node(ch.clone()); - if ((*inner.inferred).clone() != None) { - is_type_variable((*inner.inferred).clone().clone().unwrap()) + if (inner.inferred.clone() != None) { + is_type_variable(inner.inferred.clone().clone().unwrap()) } else { ((inner.ident_span.clone() == None) || !is_kernel_type(authored_name_at( @@ -1456,9 +1456,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, (*inner_applied.ty).clone()); + let built = make_container_type(kind_name, inner_applied.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1473,7 +1473,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } @@ -1484,9 +1484,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1508,7 +1508,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1552,7 +1552,7 @@ pub fn apply_type_substitution( for pn in param_nodes.iter().cloned() { __result.push(make_param_node( "_".to_string(), - pn.clone(), + Rc::new(pn.clone()), None, no_span(), no_span(), @@ -1560,7 +1560,7 @@ pub fn apply_type_substitution( } __result }), - (*rb.ty).clone(), + rb.ty.clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1569,11 +1569,11 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self((*template.return_type).clone()) + is_receiver_self(template.return_type.clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable((*template.return_type).clone()) + has_type_variable(template.return_type.clone()) } pub fn has_type_variable(t: Rc) -> bool { @@ -1608,7 +1608,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - (*template.return_type).clone(), + template.return_type.clone(), subst, receiver_type.clone(), source_indices.clone(), @@ -1620,7 +1620,7 @@ pub fn callable_inferred(n: Rc) -> Rc { { let is_callable = ((n.params.clone().len() as i64) > 0); if is_callable { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: ret, .. }) => ret, None => error_type(), _ => error_type(), @@ -1634,7 +1634,7 @@ pub fn callable_inferred(n: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if (((*n.type_annotation).clone() != None) && has_structure.clone()) { + let unwrapped = if ((n.type_annotation.clone() != None) && has_structure.clone()) { n.children.clone().first().cloned() } else { None @@ -1663,7 +1663,7 @@ pub fn node_type_shape( let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_leaf { { - let __is_named_ref = match (*n.inferred).clone().as_deref().cloned() { + let __is_named_ref = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -1772,23 +1772,23 @@ pub fn node_type_compatible( mut source_indices: Rc>>, ) -> bool { loop { - let left_err = if ((*left.inferred).clone() != None) { - is_compiler_error((*left.inferred).clone().clone().unwrap()) + let left_err = if (left.inferred.clone() != None) { + is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if ((*right.inferred).clone() != None) { - is_compiler_error((*right.inferred).clone().clone().unwrap()) + let right_err = if (right.inferred.clone() != None) { + is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if ((*left.inferred).clone() != None) { - is_type_variable((*left.inferred).clone().clone().unwrap()) + let left_tv = if (left.inferred.clone() != None) { + is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if ((*right.inferred).clone() != None) { - is_type_variable((*right.inferred).clone().clone().unwrap()) + let right_tv = if (right.inferred.clone() != None) { + is_type_variable(right.inferred.clone().clone().unwrap()) } else { false }; @@ -2002,23 +2002,23 @@ pub fn node_type_equals( source_indices: Rc>>, ) -> bool { { - let left_err = if ((*left.inferred).clone() != None) { - is_compiler_error((*left.inferred).clone().clone().unwrap()) + let left_err = if (left.inferred.clone() != None) { + is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if ((*right.inferred).clone() != None) { - is_compiler_error((*right.inferred).clone().clone().unwrap()) + let right_err = if (right.inferred.clone() != None) { + is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if ((*left.inferred).clone() != None) { - is_type_variable((*left.inferred).clone().clone().unwrap()) + let left_tv = if (left.inferred.clone() != None) { + is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if ((*right.inferred).clone() != None) { - is_type_variable((*right.inferred).clone().clone().unwrap()) + let right_tv = if (right.inferred.clone() != None) { + is_type_variable(right.inferred.clone().clone().unwrap()) } else { false }; @@ -2263,7 +2263,7 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match (*left.inferred) + match left.inferred .clone() .as_deref() .cloned() @@ -2271,7 +2271,7 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match (*right.inferred) + }) => match right.inferred .clone() .as_deref() .cloned() @@ -2288,7 +2288,7 @@ pub fn node_type_equals_core( _ => false, }, None => { - ((*right.inferred).clone() == None) + (right.inferred.clone() == None) } _ => false, } @@ -2314,18 +2314,18 @@ pub fn node_type_deps( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if ((*n.inferred).clone() != None) { - is_type_variable((*n.inferred).clone().clone().unwrap()) + let n_is_type_var = if (n.inferred.clone() != None) { + is_type_variable(n.inferred.clone().clone().unwrap()) } else { false }; if n_is_type_var { return Rc::new(vec![]); } - let __is_named_ref = if ((*n.inferred).clone() == None) { + let __is_named_ref = if (n.inferred.clone() == None) { false } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) @@ -2341,7 +2341,7 @@ pub fn node_type_deps( let has_structure = (n.connective.clone() != Connective::NoConnective); let n_name = authored_name_at(source_indices.clone(), n.clone()); if __is_named_ref { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { Rc::new(vec![authored_name_at(source_indices.clone(), rt)]) } @@ -2353,12 +2353,12 @@ pub fn node_type_deps( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.extend( - (*match (*child.inferred).clone().as_deref().cloned() { + (*match child.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) } _ => { - if ((*child.inferred).clone() == None) { + if (child.inferred.clone() == None) { node_type_deps(child.clone(), source_indices.clone()) } else { Rc::new(vec![]) @@ -2372,8 +2372,8 @@ pub fn node_type_deps( __result }) } else { - if ((*n.inferred).clone() != None) { - match (*n.inferred).clone().as_deref().cloned() { + if (n.inferred.clone() != None) { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt, source_indices.clone()) } @@ -2611,14 +2611,14 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match (*(*m.field_node).clone().inferred) + Some(m) => match (*m.field_node).clone().inferred .clone() .as_deref() .cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { - match (*rt.inferred).clone().as_deref().cloned() { + match rt.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. }) => Rc::new(BinOpInferred { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 823881bcd3d..43ab91291d0 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -32,7 +32,7 @@ pub fn check_bare_containers( source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let has_structure = ((match (*n.body).clone() { + let has_structure = ((match n.body.clone() { Some(_) => true, None => false, } || ((n.uses.clone().len() as i64) > 0)) @@ -98,18 +98,18 @@ pub fn check_bare_containers( } __result }); - let type_ann_diags = match (*n.type_annotation).clone() { + let type_ann_diags = match n.type_annotation.clone() { Some(ta) => check_bare_containers(ta, module_name.clone(), source_indices.clone()), None => Rc::new(vec![]), }; - let body_diags = match (*n.body).clone() { + let body_diags = match n.body.clone() { Some(b) => check_bare_containers(b, module_name.clone(), source_indices.clone()), None => Rc::new(vec![]), }; let inferred_diags = if ((n.params.clone().len() as i64) > 0) { Rc::new(vec![]) } else { - match (*n.inferred).clone() { + match n.inferred.clone() { Some(inf) => match (*inf).clone() { InferredNode::Resolved { node: rn, .. } => { check_bare_containers(rn, module_name.clone(), source_indices.clone()) @@ -181,7 +181,7 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items((*m.module).clone()); + let items = module_items(m.module.clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { @@ -190,7 +190,7 @@ pub fn normalize_graph( item.clone(), authored_name_at( source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ), source_indices.clone(), )) diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 5e0e16ca8c2..7b93d49aedc 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -1158,13 +1158,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index d16159b48d5..f243f2d79c5 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -1942,7 +1942,7 @@ pub fn is_conj_with_children(n: Rc) -> bool { } pub fn child_inferred_or_empty(ch: Rc) -> Rc { - match (*ch.inferred).clone().as_deref().cloned() { + match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt, _ => error_type(), } @@ -1957,7 +1957,7 @@ pub fn node_inferred_to_outputs( let all_children_typed = { let mut __all = true; for ch in rt.children.clone().iter().cloned() { - if !(match (*ch.inferred).clone().as_deref().cloned() { + if !(match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }) { @@ -1975,7 +1975,7 @@ pub fn node_inferred_to_outputs( authored_name_at(source_indices.clone(), ch.clone()), child_inferred_or_empty(ch.clone()), Cardinality::Required, - (*ch.body).clone(), + ch.body.clone(), None, ch.span.clone(), node_name_span(ch.clone()), @@ -2073,7 +2073,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some((*r.module).clone()), + module: Some(r.module.clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2228,7 +2228,7 @@ pub fn parse_imports_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.import).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.import.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2276,7 +2276,7 @@ pub fn parse_items_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.item).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.item.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2584,7 +2584,7 @@ pub fn parse_item_prefix( let tokens = ret_result.tokens.clone(); let ctx = ret_result.ctx.clone(); let missing_required_ret = (form.return_required.clone() - && match (*ret_result.inferred).clone() { + && match ret_result.inferred.clone() { Some(_) => false, None => true, }); @@ -2626,7 +2626,7 @@ pub fn parse_item_prefix( name_span: name_span.clone(), type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: (*ret_result.inferred).clone(), + inferred: ret_result.inferred.clone(), uses: Rc::new(vec![]), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -2638,7 +2638,7 @@ pub fn parse_item_prefix( name_span: name_span, type_params: tp_result.params.clone(), params: params_result.params.clone(), - inferred: (*ret_result.inferred).clone(), + inferred: ret_result.inferred.clone(), uses: uses_result.uses.clone(), tokens: uses_result.tokens.clone(), ctx: uses_result.ctx.clone(), @@ -3412,7 +3412,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![(*rv.variant).clone()]), + Rc::new(vec![rv.variant.clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3494,7 +3494,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), - Rc::new(vec![first_variant]), + Rc::new(vec![Rc::new(first_variant)]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3561,7 +3561,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3580,7 +3580,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3617,7 +3617,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3636,7 +3636,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3764,7 +3764,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -4282,7 +4282,7 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), Cardinality::Required, None, None, @@ -4462,7 +4462,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4654,7 +4654,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*ret.type_expr).clone(), + node: ret.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4689,7 +4689,7 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), None, (*r.type_expr).clone().span.clone(), (*r.type_expr).clone().span.clone(), @@ -4741,7 +4741,7 @@ pub fn finish_type_expr_from_name( } let first_arg = (*r.type_expr).clone(); let type_args = - collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); + collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![Rc::new(first_arg)])); if has_err(type_args.err.clone()) { return Rc::new(TypeResult { type_expr: dummy_te.clone(), @@ -4897,7 +4897,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); + let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -4931,16 +4931,16 @@ pub fn maybe_optional( children: te.children.clone(), connective: te.connective.clone(), params: te.params.clone(), - inferred: (*te.inferred).clone(), + inferred: te.inferred.clone(), return_cardinality: Cardinality::CardOptional, uses: te.uses.clone(), - body: (*te.body).clone(), - transport: (*te.transport).clone(), + body: te.body.clone(), + transport: te.transport.clone(), properties: te.properties.clone(), - type_annotation: (*te.type_annotation).clone(), + type_annotation: te.type_annotation.clone(), is_self_recursive: te.is_self_recursive.clone(), has_non_tail_self_call: te.has_non_tail_self_call.clone(), - match_pattern: (*te.match_pattern).clone(), + match_pattern: te.match_pattern.clone(), expr_data: te.expr_data.clone(), ident: None, }); @@ -4998,7 +4998,7 @@ pub fn parse_field_list_acc( }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); + let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -5060,7 +5060,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let f = make_field_node( name, - te.clone(), + Rc::new(te.clone()), te.return_cardinality.clone(), None, from_key, @@ -5302,7 +5302,7 @@ pub fn parse_fn_after_kw( err: ret.err.clone(), }); } - let inferred = (*ret.inferred).clone(); + let inferred = ret.inferred.clone(); let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); let r = parse_block(skip_newlines(tokens.clone()), ctx.clone()); @@ -5324,7 +5324,7 @@ pub fn parse_fn_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5353,7 +5353,7 @@ pub fn parse_fn_body_from_prefix( let name_span = prefix.name_span.clone(); let type_params = prefix.type_params.clone(); let params = prefix.params.clone(); - let inferred = (*prefix.inferred).clone(); + let inferred = prefix.inferred.clone(); let ctx = prefix.ctx.clone(); let all_params = v1_rt::concat(type_params, params); let named_dummy = Rc::new(Node { @@ -5426,7 +5426,7 @@ pub fn parse_fn_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5615,7 +5615,7 @@ pub fn parse_block_item_after_kw( err: ret.err.clone(), }); } - let inferred = (*ret.inferred).clone(); + let inferred = ret.inferred.clone(); let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); let uses_r = if form.has_uses.clone() { @@ -5658,7 +5658,7 @@ pub fn parse_block_item_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5686,7 +5686,7 @@ pub fn parse_block_body_from_prefix( let name = prefix.name.clone(); let name_span = prefix.name_span.clone(); let params = prefix.params.clone(); - let inferred = (*prefix.inferred).clone(); + let inferred = prefix.inferred.clone(); let uses = prefix.uses.clone(); let ctx = prefix.ctx.clone(); let named_dummy = Rc::new(Node { @@ -5728,7 +5728,7 @@ pub fn parse_block_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5759,7 +5759,7 @@ pub fn parse_no_body_from_prefix( ident_span: Some(prefix.name_span.clone()), children: Rc::new(vec![]), params: prefix.params.clone(), - inferred: (*prefix.inferred).clone(), + inferred: prefix.inferred.clone(), return_cardinality: Cardinality::Required, uses: prefix.uses.clone(), body: None, @@ -5833,7 +5833,7 @@ pub fn parse_uses_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.resource_use).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.resource_use.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); @@ -5918,17 +5918,17 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - (*r3.type_expr).clone(), + r3.type_expr.clone(), start_span, r.span.clone(), ); @@ -6018,7 +6018,7 @@ pub fn parse_resource_config_acc( } let fi = make_field_init_node( field_name.clone(), - (*r3.expr).clone(), + r3.expr.clone(), zero_span.clone(), r.span.clone(), ); @@ -6057,7 +6057,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: (*r.type_expr).clone(), + node: r.type_expr.clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6223,12 +6223,12 @@ pub fn parse_service_after_kw( ); let svc_props = match r.config.clone() { Some(cfg) => service_config_properties( - (*cfg.endpoint).clone(), - (*cfg.auth).clone(), - (*cfg.auth_input).clone(), - (*cfg.auth_source).clone(), - (*cfg.rate_limit).clone(), - (*cfg.retry).clone(), + cfg.endpoint.clone(), + cfg.auth.clone(), + cfg.auth_input.clone(), + cfg.auth_source.clone(), + cfg.rate_limit.clone(), + cfg.retry.clone(), ), None => Rc::new(vec![]), }; @@ -6243,7 +6243,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some((*r.transport).clone()), + transport: Some(r.transport.clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6371,7 +6371,7 @@ pub fn parse_service_entries( let __tco_2 = (*r.transport).clone(); tokens = __tco_0; ctx = __tco_1; - transport = __tco_2; + transport = Rc::new(__tco_2); continue; } } else { @@ -6407,7 +6407,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); + let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6622,7 +6622,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6641,7 +6641,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6668,7 +6668,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6687,7 +6687,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6714,7 +6714,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6733,7 +6733,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -7288,7 +7288,7 @@ pub fn parse_operation_v2_inline( } let tokens = ret.tokens.clone(); let ctx = ret.ctx.clone(); - let outputs = match (*ret.inferred).clone().as_deref().cloned() { + let outputs = match ret.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_inferred_to_outputs(rt, ctx.source_indices.clone()) } @@ -7410,7 +7410,7 @@ pub fn parse_operation_v1_body( r2.mock_props.clone(), r2.exit_props.clone(), r2.modifier_props.clone(), - (*r2.transport).clone(), + r2.transport.clone(), start_span.clone(), ctx.source_indices.clone(), ); @@ -8042,7 +8042,7 @@ pub fn node_to_name_str( None => v1_rt::concat(opt_prefix, effective_name), } } else { - if ((*effective_n.type_annotation).clone() != None) { + if (effective_n.type_annotation.clone() != None) { match effective_n.children.clone().first().cloned() { Some(ch) => { v1_rt::concat(opt_prefix, node_to_name_str(ch, source_indices.clone())) @@ -8140,8 +8140,8 @@ pub fn parse_exit_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(code.clone(), ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let code_str = status_expr_to_str(Rc::new(code.clone()), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str.clone()); let entry = make_field_init_node( prop_name.clone(), @@ -8458,8 +8458,8 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(status.clone(), ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let status_str = status_expr_to_str(Rc::new(status.clone()), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str.clone()); let entry = make_field_init_node( prop_name.clone(), @@ -8617,11 +8617,11 @@ pub fn parse_mock_response_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(status.clone(), ctx.source_indices.clone()); + let status_str = status_expr_to_str(Rc::new(status.clone()), ctx.source_indices.clone()); let prop_name = v1_rt::concat("mock_".to_string(), status_str.clone()); let entry = make_field_init_node( prop_name.clone(), - body.clone(), + Rc::new(body.clone()), make_span(0, 0), make_span(0, 0), ); @@ -8844,7 +8844,7 @@ pub fn parse_resource_entries( let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); let __tco_2 = - v1_rt::rc_list_push(capabilities, (*r.capability).clone()); + v1_rt::rc_list_push(capabilities, r.capability.clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8964,7 +8964,7 @@ pub fn parse_resource_entries( } let fi = make_field_init_node( fname.clone(), - (*r3.expr).clone(), + r3.expr.clone(), make_span(0, 0), r.span.clone(), ); @@ -9169,7 +9169,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc { node_inferred_to_outputs(rt, ret.ctx.clone().source_indices.clone()) } @@ -9487,11 +9487,11 @@ pub fn parse_data_after_kw( inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some((*r.expr).clone()), + body: Some(r.expr.clone()), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), - type_annotation: Some(te), + type_annotation: Some(Rc::new(te)), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -9572,7 +9572,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9645,7 +9645,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, type_expr, None, start_span, name_span); + let p = make_param_node(name, Rc::new(type_expr), None, start_span, name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -9782,7 +9782,7 @@ pub fn parse_stmts_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.expr).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.expr.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -9917,7 +9917,7 @@ pub fn parse_constrained_assignment( let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![(*r3.expr).clone()]), + Rc::new(vec![r3.expr.clone()]), None, span, name_span, @@ -9928,17 +9928,17 @@ pub fn parse_constrained_assignment( ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: (*node.inferred).clone(), + inferred: node.inferred.clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: (*node.body).clone(), + body: node.body.clone(), connective: node.connective.clone(), - transport: (*node.transport).clone(), + transport: node.transport.clone(), properties: cr.constraints.clone(), - type_annotation: (*node.type_annotation).clone(), + type_annotation: node.type_annotation.clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: (*node.match_pattern).clone(), + match_pattern: node.match_pattern.clone(), expr_data: node.expr_data.clone(), ident: None, }); @@ -10020,10 +10020,10 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![(*r3.expr).clone()]), + Rc::new(vec![r3.expr.clone()]), None, span, name_span, @@ -10098,17 +10098,17 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> ident_span: node.ident_span.clone(), children: node.children.clone(), params: node.params.clone(), - inferred: (*node.inferred).clone(), + inferred: node.inferred.clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: (*node.body).clone(), + body: node.body.clone(), connective: node.connective.clone(), - transport: (*node.transport).clone(), + transport: node.transport.clone(), properties: cr.constraints.clone(), - type_annotation: (*node.type_annotation).clone(), + type_annotation: node.type_annotation.clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: (*node.match_pattern).clone(), + match_pattern: node.match_pattern.clone(), expr_data: node.expr_data.clone(), ident: None, }); @@ -10145,7 +10145,7 @@ pub fn parse_expr_bp( return r; } let lhs = (*r.expr).clone(); - parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) + parse_expr_loop(r.tokens.clone(), r.ctx.clone(), Rc::new(lhs), min_bp) } } @@ -10182,7 +10182,7 @@ pub fn parse_expr_loop( let __tco_2 = (*post.expr).clone(); tokens = __tco_0; ctx = __tco_1; - lhs = __tco_2; + lhs = Rc::new(__tco_2); continue; } } else { @@ -10241,7 +10241,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10253,7 +10253,7 @@ pub fn parse_expr_loop( let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; - lhs = __tco_2; + lhs = Rc::new(__tco_2); continue; } } else { @@ -10265,7 +10265,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10284,7 +10284,7 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - (*r.expr).clone(), + r.expr.clone(), ]), None, loop_span.clone(), @@ -10488,7 +10488,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { tokens = skip_newlines(__ec.clone()); @@ -11551,7 +11551,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some((*r.expr).clone()), + guard: Some(r.expr.clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12460,7 +12460,7 @@ pub fn parse_variant_pattern( } let fb = make_field_binding_node( "0".to_string(), - (*r.pattern).clone(), + r.pattern.clone(), span, kernel_span("0".to_string()), ); @@ -12546,7 +12546,7 @@ pub fn parse_variant_bindings_brace_acc( }); let fb = make_field_binding_node( field_name.clone(), - (*r2.pattern).clone(), + r2.pattern.clone(), bind_span.clone(), field_name_span.clone(), ); @@ -12638,7 +12638,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![condition, then_branch]), + Rc::new(vec![Rc::new(condition), Rc::new(then_branch)]), None, span, ), @@ -12742,7 +12742,7 @@ pub fn parse_let(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc) -> Option> { match (*inferred).clone() { - InferredNode::Resolved { node: n, .. } => Some(n), + InferredNode::Resolved { node: n, .. } => Some(n.clone()), InferredNode::CompilerError { .. } => None, InferredNode::TypeVariable { id: _, .. } => None, } @@ -182,7 +182,7 @@ pub fn is_compiler_error(inferred: Rc) -> bool { } pub fn has_inferred(n: Rc) -> bool { - ((*n.inferred).clone() != None) + (n.inferred.clone() != None) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -468,23 +468,23 @@ pub struct ErrorDAG { pub fn diagnostic_to_span(d: Rc) -> Rc { match (*d).clone() { - CompilerDiagnostic::UnresolvedImport { span: s, .. } => s, - CompilerDiagnostic::MissingExport { span: s, .. } => s, - CompilerDiagnostic::UnresolvedType { span: s, .. } => s, - CompilerDiagnostic::TypeMismatch { span: s, .. } => s, - CompilerDiagnostic::ArityMismatch { span: s, .. } => s, - CompilerDiagnostic::VariantNotFound { span: s, .. } => s, - CompilerDiagnostic::FieldNotFound { span: s, .. } => s, - CompilerDiagnostic::NonExhaustiveMatch { span: s, .. } => s, - CompilerDiagnostic::CircularDependency { span: s, .. } => s, - CompilerDiagnostic::DuplicateModule { span: s, .. } => s, - CompilerDiagnostic::MissingAnnotation { span: s, .. } => s, - CompilerDiagnostic::ParseError { span: s, .. } => s, - CompilerDiagnostic::InternalError { span: s, .. } => s, - CompilerDiagnostic::ComplexityUnknown { span: s, .. } => s, - CompilerDiagnostic::OwnershipViolation { span: s, .. } => s, - CompilerDiagnostic::VariantCollision { span: s, .. } => s, - CompilerDiagnostic::SoleConstructorViolation { span: s, .. } => s, + CompilerDiagnostic::UnresolvedImport { span: s, .. } => s.clone(), + CompilerDiagnostic::MissingExport { span: s, .. } => s.clone(), + CompilerDiagnostic::UnresolvedType { span: s, .. } => s.clone(), + CompilerDiagnostic::TypeMismatch { span: s, .. } => s.clone(), + CompilerDiagnostic::ArityMismatch { span: s, .. } => s.clone(), + CompilerDiagnostic::VariantNotFound { span: s, .. } => s.clone(), + CompilerDiagnostic::FieldNotFound { span: s, .. } => s.clone(), + CompilerDiagnostic::NonExhaustiveMatch { span: s, .. } => s.clone(), + CompilerDiagnostic::CircularDependency { span: s, .. } => s.clone(), + CompilerDiagnostic::DuplicateModule { span: s, .. } => s.clone(), + CompilerDiagnostic::MissingAnnotation { span: s, .. } => s.clone(), + CompilerDiagnostic::ParseError { span: s, .. } => s.clone(), + CompilerDiagnostic::InternalError { span: s, .. } => s.clone(), + CompilerDiagnostic::ComplexityUnknown { span: s, .. } => s.clone(), + CompilerDiagnostic::OwnershipViolation { span: s, .. } => s.clone(), + CompilerDiagnostic::VariantCollision { span: s, .. } => s.clone(), + CompilerDiagnostic::SoleConstructorViolation { span: s, .. } => s.clone(), } } @@ -497,10 +497,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("unresolved import: module '".to_string(), m), + v1_rt::concat("unresolved import: module '".to_string(), m.clone()), "' not found (imported by '".to_string(), ), - i, + i.clone(), ), "')".to_string(), ), @@ -514,19 +514,19 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("name '".to_string(), n), + v1_rt::concat("name '".to_string(), n.clone()), "' not found in module '".to_string(), ), - m, + m.clone(), ), "' (imported by '".to_string(), ), - i, + i.clone(), ), "')".to_string(), ), CompilerDiagnostic::UnresolvedType { name: n, .. } => v1_rt::concat( - v1_rt::concat("unresolved type '".to_string(), n), + v1_rt::concat("unresolved type '".to_string(), n.clone()), "'".to_string(), ), CompilerDiagnostic::TypeMismatch { @@ -536,10 +536,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("type mismatch: expected '".to_string(), e), + v1_rt::concat("type mismatch: expected '".to_string(), e.clone()), "', got '".to_string(), ), - g, + g.clone(), ), "'".to_string(), ), @@ -552,14 +552,14 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("type ".to_string(), n), + v1_rt::concat("type ".to_string(), n.clone()), " expects ".to_string(), ), - (e).to_string(), + (e.clone()).to_string(), ), " type arguments, got ".to_string(), ), - (g).to_string(), + (g.clone()).to_string(), ), CompilerDiagnostic::VariantNotFound { variant: v, @@ -568,10 +568,10 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("variant '".to_string(), v), + v1_rt::concat("variant '".to_string(), v.clone()), "' not found in type '".to_string(), ), - t, + t.clone(), ), "'".to_string(), ), @@ -582,23 +582,23 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("field '".to_string(), f), + v1_rt::concat("field '".to_string(), f.clone()), "' not found in type '".to_string(), ), - t, + t.clone(), ), "'".to_string(), ), CompilerDiagnostic::NonExhaustiveMatch { missing: ms, .. } => v1_rt::concat( "non-exhaustive match: missing variant(s) ".to_string(), - ms.join(&", ".to_string()), + ms.clone().join(&", ".to_string()), ), CompilerDiagnostic::CircularDependency { modules: ms, .. } => v1_rt::concat( "circular dependency detected: ".to_string(), - ms.join(&" -> ".to_string()), + ms.clone().join(&" -> ".to_string()), ), CompilerDiagnostic::DuplicateModule { name: n, .. } => v1_rt::concat( - v1_rt::concat("duplicate module declaration: '".to_string(), n), + v1_rt::concat("duplicate module declaration: '".to_string(), n.clone()), "'".to_string(), ), CompilerDiagnostic::MissingAnnotation { @@ -608,25 +608,25 @@ pub fn diagnostic_to_message(d: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("function '".to_string(), f), + v1_rt::concat("function '".to_string(), f.clone()), "' requires ".to_string(), ), - w, + w.clone(), ), " annotation".to_string(), ), - CompilerDiagnostic::ParseError { message: m, .. } => m, - CompilerDiagnostic::InternalError { message: m, .. } => m, + CompilerDiagnostic::ParseError { message: m, .. } => m.clone(), + CompilerDiagnostic::InternalError { message: m, .. } => m.clone(), CompilerDiagnostic::ComplexityUnknown { func_name: f, reason: r, .. } => v1_rt::concat( v1_rt::concat( - v1_rt::concat("complexity: ".to_string(), f), + v1_rt::concat("complexity: ".to_string(), f.clone()), ": ".to_string(), ), - r, + r.clone(), ), CompilerDiagnostic::OwnershipViolation { binding: b, @@ -638,14 +638,14 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("ownership: binding '".to_string(), b), + v1_rt::concat("ownership: binding '".to_string(), b.clone()), "' in '".to_string(), ), - f, + f.clone(), ), "' has ".to_string(), ), - (c).to_string(), + (c.clone()).to_string(), ), " consumers".to_string(), ), @@ -659,19 +659,19 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("variant '".to_string(), v), + v1_rt::concat("variant '".to_string(), v.clone()), "' appears in both '".to_string(), ), - e1, + e1.clone(), ), "' and '".to_string(), ), - e2, + e2.clone(), ), "'".to_string(), ), CompilerDiagnostic::SoleConstructorViolation { type_name: t, .. } => v1_rt::concat( - v1_rt::concat("sole_constructor type '".to_string(), t), + v1_rt::concat("sole_constructor type '".to_string(), t.clone()), "' cannot be constructed outside its defining module".to_string(), ), } @@ -770,7 +770,7 @@ pub fn default_ident_span(name: String, span: Rc) -> Option) -> Rc { match n.ident_span.clone() { - Some(s) => s, + Some(s) => s.clone(), None => n.span.clone(), } } @@ -878,13 +878,13 @@ pub fn make_arg_node( ) -> Rc { { let arg_name = match name { - Some(n) => n, + Some(n) => n.clone(), None => "".to_string(), }; Rc::new(Node { name: arg_name.clone(), span: span, - ident_span: default_ident_span(arg_name, name_span), + ident_span: default_ident_span(arg_name.clone(), name_span), children: Rc::new(vec![value]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -912,7 +912,7 @@ pub fn make_arm_node( ) -> Rc { { let children = match guard { - Some(g) => Rc::new(vec![g, body]), + Some(g) => Rc::new(vec![g.clone(), body]), None => Rc::new(vec![body]), }; Rc::new(Node { @@ -975,7 +975,7 @@ pub fn resource_use_name_at( pub fn resource_use_resource(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed resource-use: missing resource".to_string(), @@ -1048,8 +1048,8 @@ pub fn field_binding_name_at( } pub fn field_binding_pattern(n: Rc) -> Rc { - match (*n.match_pattern).clone() { - Some(p) => p, + match n.match_pattern.clone() { + Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), } } @@ -1111,7 +1111,7 @@ pub fn make_param_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr, dv]), + Some(dv) => Rc::new(vec![type_expr, dv.clone()]), None => Rc::new(vec![type_expr]), }; Rc::new(Node { @@ -1147,7 +1147,7 @@ pub fn make_resolved_param_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr.clone(), dv]), + Some(dv) => Rc::new(vec![type_expr.clone(), dv.clone()]), None => Rc::new(vec![type_expr.clone()]), }; Rc::new(Node { @@ -1196,11 +1196,11 @@ pub fn authored_name_at( match node.ident_span.clone() { Some(span) => match v1_rt::map_get(&source_indices, span.file.clone()) { Some(index) => { - let text = source_text_at(index, span); + let text = source_text_at(index.clone(), span.clone()); if (text.clone() == "".to_string()) { "".to_string() } else { - text + text.clone() } } None => { @@ -1238,7 +1238,7 @@ pub fn find_child_named( .first() .cloned() { - Some(ch) => Some(ch), + Some(ch) => Some(ch.clone()), None => None, } } @@ -1262,7 +1262,7 @@ pub fn has_child_named( pub fn param_node_type_expr(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed param: missing type_expr".to_string(), @@ -1294,7 +1294,7 @@ pub fn make_field_node( ) -> Rc { { let children = match default_value { - Some(dv) => Rc::new(vec![type_expr.clone(), dv]), + Some(dv) => Rc::new(vec![type_expr.clone(), dv.clone()]), None => Rc::new(vec![type_expr.clone()]), }; let props = match from_key { @@ -1303,7 +1303,7 @@ pub fn make_field_node( Rc::new(Node { name: fk.clone(), span: make_span(0, 0), - ident_span: default_ident_span(fk, make_span(0, 0)), + ident_span: default_ident_span(fk.clone(), make_span(0, 0)), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -1357,7 +1357,7 @@ pub fn field_node_name_at( pub fn field_node_type_expr(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed field: missing type_expr".to_string(), @@ -1387,7 +1387,7 @@ pub fn field_node_from_key( "from_key".to_string(), source_indices.clone(), ) { - Some(p) => Some(authored_name_at(source_indices.clone(), p)), + Some(p) => Some(authored_name_at(source_indices.clone(), p.clone())), None => None, } } @@ -1606,7 +1606,7 @@ pub fn function_size_effects() -> Rc>> { pub fn is_tree_size_preserving(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::TreeSizePreserving => true, FunctionSizeEffect::PropertyContraction { domain_size: _, .. } => true, _ => false, @@ -1617,7 +1617,7 @@ pub fn is_tree_size_preserving(func_name: String) -> bool { pub fn is_tree_size_reducing(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::TreeSizeReducing => true, _ => false, }, @@ -1627,7 +1627,7 @@ pub fn is_tree_size_reducing(func_name: String) -> bool { pub fn is_property_contraction(func_name: String) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { - v1_rt::Witness::Holds { value: effect, .. } => match (*effect).clone() { + v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::PropertyContraction { domain_size: _, .. } => true, _ => false, }, @@ -1637,7 +1637,7 @@ pub fn is_property_contraction(func_name: String) -> bool { pub fn expr_child_at(texpr: Rc, index: i64, role: String) -> Rc { match texpr.children.clone().get(index as usize).cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, v1_rt::concat("malformed node: missing ".to_string(), role), @@ -1655,14 +1655,14 @@ pub fn arg_name_at( if (name.clone() == "".to_string()) { None } else { - Some(name) + Some(name.clone()) } } } pub fn arg_value(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed arg: missing value".to_string(), @@ -1672,8 +1672,8 @@ pub fn arg_value(n: Rc) -> Rc { } pub fn arm_pattern(n: Rc) -> Rc { - match (*n.match_pattern).clone() { - Some(p) => p, + match n.match_pattern.clone() { + Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), } } @@ -1688,7 +1688,7 @@ pub fn arm_guard(n: Rc) -> Option> { pub fn arm_body(n: Rc) -> Rc { match n.children.clone().last().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed arm: missing body".to_string(), @@ -1706,7 +1706,7 @@ pub fn field_init_node_name_at( pub fn field_init_node_value(n: Rc) -> Rc { match n.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => make_expr_error_node( ExprErrorKind::InternalExprError, "malformed field-init: missing value".to_string(), @@ -1775,7 +1775,7 @@ pub fn field_access_field_at( pub fn expr_field_access_summary(texpr: Rc) -> Option> { match (*texpr.expr_data.clone()).clone() { - ExprData::ExprFieldAccess { summary: s, .. } => s, + ExprData::ExprFieldAccess { summary: s, .. } => s.clone(), _ => None, } } @@ -1792,7 +1792,7 @@ pub fn expr_call_descent_evidence(texpr: Rc) -> Option de, + } => de.clone(), _ => None, } } @@ -1825,7 +1825,7 @@ pub fn expr_method_call_semantics(texpr: Rc) -> Option ExprData::ExprMethodCall { method_semantics: ms, .. - } => ms, + } => ms.clone(), _ => None, } } @@ -1933,7 +1933,7 @@ pub fn record_lit_type_name_at( if (name.clone() == "".to_string()) { None } else { - Some(name) + Some(name.clone()) } } } @@ -2100,7 +2100,7 @@ pub fn rest_transport_node( let method_props = match method { Some(m) => Rc::new(vec![make_field_init_node( transport_method_key(), - m, + m.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2109,7 +2109,7 @@ pub fn rest_transport_node( let path_props = match path { Some(p) => Rc::new(vec![make_field_init_node( transport_path_template_key(), - p, + p.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2118,7 +2118,7 @@ pub fn rest_transport_node( let query_props = match query { Some(q) => Rc::new(vec![make_field_init_node( transport_query_key(), - q, + q.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2127,7 +2127,7 @@ pub fn rest_transport_node( let body_props = match request_body { Some(b) => Rc::new(vec![make_field_init_node( transport_body_key(), - b, + b.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2136,9 +2136,9 @@ pub fn rest_transport_node( let rf_props = match response_format { Some(rf) => Rc::new(vec![make_field_init_node( transport_response_format_key(), - rf, + rf.clone(), + zero_span.clone(), zero_span.clone(), - zero_span, )]), None => Rc::new(vec![]), }; @@ -2196,9 +2196,9 @@ pub fn shell_transport_node( let stdin_props = match stdin { Some(s) => Rc::new(vec![make_field_init_node( transport_stdin_key(), - s, + s.clone(), + zero_span.clone(), zero_span.clone(), - zero_span, )]), None => Rc::new(vec![]), }; @@ -2255,7 +2255,7 @@ pub fn find_property( .first() .cloned() { - Some(fi) => Some(field_init_node_value(fi)), + Some(fi) => Some(field_init_node_value(fi.clone())), None => None, } } @@ -2271,7 +2271,7 @@ pub fn find_property_string( let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; - Some(s) + Some(s.clone()) } _ => None, }, @@ -2298,7 +2298,7 @@ pub fn is_rest_transport( } pub fn is_shell_transport(t: Rc) -> bool { - ((*t.body).clone() != None) + (t.body.clone() != None) } pub fn is_file_transport( @@ -2328,7 +2328,7 @@ pub fn field_init_operation_modifier( if (fi_name.clone() == "readonly".to_string()) { Some(OperationModifier::Readonly) } else { - if (fi_name == "hermetic".to_string()) { + if (fi_name.clone() == "hermetic".to_string()) { Some(OperationModifier::Hermetic) } else { None @@ -2499,16 +2499,16 @@ pub fn map_children(node: Rc, transform: impl Fn(Rc) -> Rc + C }), connective: node.connective.clone(), params: node.params.clone(), - inferred: (*node.inferred).clone(), + inferred: node.inferred.clone(), return_cardinality: node.return_cardinality.clone(), uses: node.uses.clone(), - body: (*node.body).clone(), - transport: (*node.transport).clone(), + body: node.body.clone(), + transport: node.transport.clone(), properties: node.properties.clone(), - type_annotation: (*node.type_annotation).clone(), + type_annotation: node.type_annotation.clone(), is_self_recursive: node.is_self_recursive.clone(), has_non_tail_self_call: node.has_non_tail_self_call.clone(), - match_pattern: (*node.match_pattern).clone(), + match_pattern: node.match_pattern.clone(), expr_data: node.expr_data.clone(), }) } @@ -2654,7 +2654,7 @@ pub fn expr_has_non_tail_self_call( ); let else_bad = match if_else_branch(texpr.clone()) { Some(e) => expr_has_non_tail_self_call( - e, + e.clone(), fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2696,7 +2696,7 @@ pub fn expr_has_non_tail_self_call( ); let body_bad = match let_body(texpr.clone()) { Some(b) => expr_has_non_tail_self_call( - b, + b.clone(), fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2748,9 +2748,9 @@ pub fn expr_has_non_tail_self_call( } __found }; - let last_bad = match ss.last().cloned() { + let last_bad = match ss.clone().last().cloned() { Some(last_expr) => expr_has_non_tail_self_call( - last_expr, + last_expr.clone(), fn_name.clone(), in_tail.clone(), source_indices.clone(), @@ -2829,7 +2829,7 @@ pub fn service_config_properties( let auth_prop = match auth { Some(a) => Rc::new(vec![make_field_init_node( "svc_auth".to_string(), - a, + a.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2838,7 +2838,7 @@ pub fn service_config_properties( let auth_input_prop = match auth_input { Some(ai) => Rc::new(vec![make_field_init_node( "svc_auth_input".to_string(), - ai, + ai.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2847,7 +2847,7 @@ pub fn service_config_properties( let auth_source_prop = match auth_source { Some(src) => Rc::new(vec![make_field_init_node( "svc_auth_source".to_string(), - src, + src.clone(), zero_span.clone(), zero_span.clone(), )]), @@ -2865,9 +2865,9 @@ pub fn service_config_properties( let retry_prop = match retry { Some(r) => Rc::new(vec![make_field_init_node( "svc_retry".to_string(), - r, + r.clone(), + zero_span.clone(), zero_span.clone(), - zero_span, )]), None => Rc::new(vec![]), }; @@ -3048,7 +3048,7 @@ pub fn import_node( } pub fn import_is_all(n: Rc) -> bool { - ((*n.body).clone() != None) + (n.body.clone() != None) } pub fn import_specific_names_at( @@ -3402,7 +3402,7 @@ pub fn build_newline_index(file: String, source: String) -> Rc { Rc::new(NewlineIndex { file: file, offsets: offsets, - char_codes: char_codes, + char_codes: char_codes.clone(), }) } } @@ -3434,13 +3434,13 @@ pub fn byte_to_line_col(index: Rc, offset: i64) -> LineCol { .get((line.clone() - 2) as usize) .cloned() { - Some(o) => (o + 1), + Some(o) => (o.clone() + 1), None => 0, } }; - let col = ((clamped - line_start) + 1); + let col = ((clamped.clone() - line_start) + 1); LineCol { - line: line, + line: line.clone(), col: col, } } @@ -3468,8 +3468,8 @@ pub fn source_line_at(index: Rc, line: i64) -> String { .get((line.clone() - 1) as usize) .cloned() { - Some(o) => o, - None => src_len, + Some(o) => o.clone(), + None => src_len.clone(), }; v1_rt::chars_to_string(&index.char_codes.clone(), line_start, line_end) } @@ -3508,7 +3508,7 @@ pub fn intern(table: Rc, s: String) -> Rc { match v1_rt::map_get(&table.index.clone(), s.clone()) { Some(id) => Rc::new(InternResult { table: table.clone(), - id: id, + id: id.clone(), }), None => { let id = table.next_id.clone(); @@ -3518,7 +3518,7 @@ pub fn intern(table: Rc, s: String) -> Rc { index: v1_rt::rc_map_insert(table.index.clone(), s.clone(), id.clone()), next_id: (id.clone() + 1), }), - id: id, + id: id.clone(), }) } } @@ -3526,21 +3526,21 @@ pub fn intern(table: Rc, s: String) -> Rc { pub fn intern_str(table: Rc, id: i64) -> String { match table.strings.clone().get(id as usize).cloned() { - Some(s) => s, + Some(s) => s.clone(), None => "".to_string(), } } pub fn intern_find(table: Rc, s: String) -> Option { match v1_rt::map_get(&table.index.clone(), s) { - Some(id) => Some(id), + Some(id) => Some(id.clone()), None => None, } } pub fn intern_find_or_empty(table: Rc, s: String) -> i64 { match v1_rt::map_get(&table.index.clone(), s) { - Some(id) => id, + Some(id) => id.clone(), None => 0, } } @@ -3594,16 +3594,16 @@ pub fn with_optional_cardinality(n: Rc) -> Rc { children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: Cardinality::CardOptional, uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), }) } @@ -3617,16 +3617,16 @@ pub fn with_required_cardinality(n: Rc) -> Rc { children: n.children.clone(), connective: n.connective.clone(), params: n.params.clone(), - inferred: (*n.inferred).clone(), + inferred: n.inferred.clone(), return_cardinality: Cardinality::Required, uses: n.uses.clone(), - body: (*n.body).clone(), - transport: (*n.transport).clone(), + body: n.body.clone(), + transport: n.transport.clone(), properties: n.properties.clone(), - type_annotation: (*n.type_annotation).clone(), + type_annotation: n.type_annotation.clone(), is_self_recursive: n.is_self_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), - match_pattern: (*n.match_pattern).clone(), + match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), }) } From 721ad9a7163ef78a30d5d32c512cbec0424aaa79 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:15:13 +0000 Subject: [PATCH 14/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_artifact.rs | 2 +- src/v1/stage0/src/v1_compiler_coercion.rs | 16 +- src/v1/stage0/src/v1_compiler_compile.rs | 153 +- .../src/v1_compiler_compiler_tests_rust.rs | 32 +- src/v1/stage0/src/v1_compiler_complexity.rs | 1005 ++++---- src/v1/stage0/src/v1_compiler_emit.rs | 383 +-- .../src/v1_compiler_emit_core_support.rs | 14 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 65 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 40 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2143 +++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 1602 ++++++------ src/v1/stage0/src/v1_compiler_infer_access.rs | 12 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 8 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 7 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 32 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 12 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 90 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 6 +- .../stage0/src/v1_compiler_infer_patterns.rs | 82 +- .../stage0/src/v1_compiler_infer_resolve.rs | 294 ++- .../stage0/src/v1_compiler_infer_service.rs | 25 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 10 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 380 +-- src/v1/stage0/src/v1_compiler_languages.rs | 24 +- src/v1/stage0/src/v1_compiler_normalize.rs | 22 +- src/v1/stage0/src/v1_compiler_ownership.rs | 131 +- src/v1/stage0/src/v1_compiler_parse.rs | 1125 ++++----- src/v1/stage0/src/v1_compiler_resolve.rs | 30 +- .../stage0/src/v1_compiler_stage0_crates.rs | 4 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 90 +- src/v1/stage0/src/v1_compiler_trace.rs | 39 +- src/v1/stage0/src/v1_rt.rs | 33 - 32 files changed, 4252 insertions(+), 3659 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index d1404a95858..0a95131a9f2 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -94,7 +94,7 @@ pub fn plan_artifacts(rule: Rc) -> Rc { PartitionRule::Explicit { artifacts: arts, .. } => Rc::new(ArtifactPlan { - artifacts: arts, + artifacts: arts.clone(), boundaries: Rc::new(vec![]), }), } diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index c74e5868aab..6c8e64335a0 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -98,7 +98,7 @@ pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) pub fn render_cast(expr_str: String, type_str: String, target: RenderTarget) -> String { { let syntax = match target_cast_syntax(target) { - Some(s) => s, + Some(s) => s.clone(), None => Rc::new(CastSyntax { template: "{expr}".to_string(), cast_rules: Rc::new(vec![]), @@ -129,7 +129,7 @@ pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option String { match lookup_checkpoint(target, dag_name.clone()) { Some(cp) => cp.target_type.clone(), - None => dag_name, + None => dag_name.clone(), } } @@ -143,7 +143,7 @@ pub fn is_copy(target: RenderTarget, dag_name: String) -> Option { pub fn literal_suffix(target: RenderTarget, dag_name: String) -> Option { match lookup_checkpoint(target, dag_name) { Some(cp) => match cp.literal_suffix.clone() { - Some(s) => Some(s), + Some(s) => Some(s.clone()), None => Some("".to_string()), }, None => None, @@ -166,7 +166,7 @@ pub fn lookup_inhabitant(target: RenderTarget, algebra: String) -> Option Option { match container_template_algebra(container_name) { - Some(algebra) => match lookup_inhabitant(target, algebra) { + Some(algebra) => match lookup_inhabitant(target, algebra.clone()) { Some(inh) => Some(inh.template.clone()), None => None, }, @@ -240,7 +240,7 @@ pub fn checkpoint_tests(target: RenderTarget) -> Rc>> ), assertions: Rc::new({ let mut __result = Vec::new(); - for cp in cps.iter().cloned() { + for cp in cps.clone().iter().cloned() { __result.push(Rc::new(CoercionAssertion::CheckpointAssertion { target: target.clone(), dag_name: cp.dag_name.clone(), @@ -289,7 +289,7 @@ pub fn inhabitant_tests(target: RenderTarget) -> Rc>> v1_rt::concat("coercion_".to_string(), label), "_inhabitant_resolves_containers".to_string(), ), - assertions: assertions, + assertions: assertions.clone(), })]) } } @@ -321,7 +321,7 @@ pub fn copy_tests() -> Rc>> { } else { Rc::new(vec![Rc::new(CoercionTestEntry { test_name: "coercion_is_copy_from_checkpoint".to_string(), - assertions: copy_assertions, + assertions: copy_assertions.clone(), })]) } } @@ -401,7 +401,7 @@ pub fn template_application_tests() -> Rc>> { } else { Rc::new(vec![Rc::new(CoercionTestEntry { test_name: "coercion_template_application".to_string(), - assertions: assertions, + assertions: assertions.clone(), })]) } } diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 9be630bf6b9..8f308b2e03b 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -364,7 +364,7 @@ pub fn json_list(items: Rc>) -> String { pub fn json_optional_string(value: Option) -> String { match value { - Some(inner) => json_quote(inner), + Some(inner) => json_quote(inner.clone()), None => "null".to_string(), } } @@ -400,7 +400,7 @@ pub fn dag_emit_check_optional_ref_target( key_to_id: Rc>, ) -> Rc>> { match value { - Some(inner) => dag_emit_check_ref_target(inner, key_to_id), + Some(inner) => dag_emit_check_ref_target(inner.clone(), key_to_id), None => Rc::new(vec![]), } } @@ -410,7 +410,9 @@ pub fn dag_emit_check_inferred_ref_target( key_to_id: Rc>, ) -> Rc>> { match value.as_deref().cloned() { - Some(InferredNode::Resolved { node: n, .. }) => dag_emit_check_ref_target(n, key_to_id), + Some(InferredNode::Resolved { node: n, .. }) => { + dag_emit_check_ref_target(n.clone(), key_to_id) + } _ => Rc::new(vec![]), } } @@ -552,7 +554,7 @@ pub fn dag_graph_source_indices(typed: Rc) -> Rc, key_to_id: Rc>) -> String { match v1_rt::map_get(&key_to_id, dag_node_key(node)) { Some(id) => v1_rt::concat( - v1_rt::concat("{\"$ref\": ".to_string(), json_quote(id)), + v1_rt::concat("{\"$ref\": ".to_string(), json_quote(id.clone())), "}".to_string(), ), None => "{\"$ref\": null}".to_string(), @@ -564,7 +566,7 @@ pub fn json_optional_node_ref( key_to_id: Rc>, ) -> String { match value { - Some(inner) => serialize_node_ref(inner, key_to_id), + Some(inner) => serialize_node_ref(inner.clone(), key_to_id), None => "null".to_string(), } } @@ -574,14 +576,14 @@ pub fn json_optional_inferred_node_ref( key_to_id: Rc>, ) -> String { match value { - Some(inner) => serialize_inferred_node_ref(inner, key_to_id), + Some(inner) => serialize_inferred_node_ref(inner.clone(), key_to_id), None => "null".to_string(), } } pub fn json_optional_span(value: Option>) -> String { match value { - Some(inner) => serialize_span(inner), + Some(inner) => serialize_span(inner.clone()), None => "null".to_string(), } } @@ -751,28 +753,28 @@ pub fn serialize_literal(value: Rc) -> String { LiteralValue::LitStr { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitStr\", \"value\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), "}".to_string(), ), LiteralValue::LitInt { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitInt\", \"value\": ".to_string(), - (inner).to_string(), + (inner.clone()).to_string(), ), "}".to_string(), ), LiteralValue::LitFloat { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitFloat\", \"value\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), "}".to_string(), ), LiteralValue::LitBool { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitBool\", \"value\": ".to_string(), - json_bool(inner), + json_bool(inner.clone()), ), "}".to_string(), ), @@ -780,7 +782,7 @@ pub fn serialize_literal(value: Rc) -> String { LiteralValue::LitSymbol { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitSymbol\", \"value\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), "}".to_string(), ), @@ -820,14 +822,14 @@ pub fn serialize_match_pattern( MatchPattern::Bind { name: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Bind\", \"name\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), "}".to_string(), ), MatchPattern::LitPattern { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitPattern\", \"value\": ".to_string(), - serialize_literal(inner), + serialize_literal(inner.clone()), ), "}".to_string(), ), @@ -843,17 +845,17 @@ pub fn serialize_match_pattern( v1_rt::concat( v1_rt::concat( "{\"kind\": \"VariantPattern\", \"name\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), ", \"parent_enum\": ".to_string(), ), - json_optional_string(parent_enum), + json_optional_string(parent_enum.clone()), ), ", \"field_bindings\": ".to_string(), ), json_list(Rc::new({ let mut __result = Vec::new(); - for fb in field_bindings.iter().cloned() { + for fb in field_bindings.clone().iter().cloned() { __result.push(serialize_field_binding(fb.clone(), source_indices.clone())); } __result @@ -940,14 +942,14 @@ pub fn serialize_string_part( StringPart::Text { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Text\", \"value\": ".to_string(), - json_quote(inner), + json_quote(inner.clone()), ), "}".to_string(), ), StringPart::Interpolation { expr: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Interpolation\", \"expr\": ".to_string(), - serialize_node_ref(inner, key_to_id), + serialize_node_ref(inner.clone(), key_to_id), ), "}".to_string(), ), @@ -959,7 +961,7 @@ pub fn serialize_call_semantics(value: Option) -> String { Some(inner) => v1_rt::concat( v1_rt::concat( "{\"kind\": ".to_string(), - json_quote(call_semantics_name(inner)), + json_quote(call_semantics_name(inner.clone())), ), "}".to_string(), ), @@ -981,7 +983,7 @@ pub fn serialize_method_semantics( fold_accumulator_type, .. }) => { - let mn = authored_name_at(source_indices, method_def); + let mn = authored_name_at(source_indices.clone(), method_def.clone()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -991,7 +993,7 @@ pub fn serialize_method_semantics( ), ", \"fold_accumulator_type\": ".to_string(), ), - json_optional_node_ref(fold_accumulator_type, key_to_id), + json_optional_node_ref(fold_accumulator_type.clone(), key_to_id.clone()), ), "}".to_string(), ) @@ -1005,13 +1007,13 @@ pub fn serialize_method_semantics( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ServiceMethodSemantics\", \"service_name\": ".to_string(), - json_quote(service_name), + json_quote(service_name.clone()), ), ", \"op_params\": ".to_string(), ), json_list(Rc::new({ let mut __result = Vec::new(); - for p in op_params.iter().cloned() { + for p in op_params.clone().iter().cloned() { __result.push(serialize_param( p.clone(), source_indices.clone(), @@ -1071,7 +1073,7 @@ pub fn serialize_positive_descent_amount(steps: Rc) -> St PositiveDescentAmount::AdditionalStep { previous: p, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"AdditionalStep\", \"previous\": ".to_string(), - serialize_positive_descent_amount(p), + serialize_positive_descent_amount(p.clone()), ), "}".to_string(), ), @@ -1084,7 +1086,7 @@ pub fn serialize_proportional_divisor(d: Rc) -> String { ProportionalDivisor::StrictlyLarger { inner: i, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"StrictlyLarger\", \"inner\": ".to_string(), - serialize_proportional_divisor(i), + serialize_proportional_divisor(i.clone()), ), "}".to_string(), ), @@ -1097,14 +1099,14 @@ pub fn serialize_shrink_factor(factor: Rc) -> String { ShrinkFactor::ConstantShrink { steps: s, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ConstantShrink\", \"steps\": ".to_string(), - serialize_positive_descent_amount(s), + serialize_positive_descent_amount(s.clone()), ), "}".to_string(), ), ShrinkFactor::ProportionalShrink { divisor: d, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ProportionalShrink\", \"divisor\": ".to_string(), - serialize_proportional_divisor(d), + serialize_proportional_divisor(d.clone()), ), "}".to_string(), ), @@ -1122,18 +1124,18 @@ pub fn serialize_sub_value_relation(rel: Rc) -> String { v1_rt::concat( v1_rt::concat( "{\"_variant\": \"StrictSubValue\", \"field\": ".to_string(), - serialize_inductive_field(f), + serialize_inductive_field(f.clone()), ), ", \"factor\": ".to_string(), ), - serialize_shrink_factor(fac), + serialize_shrink_factor(fac.clone()), ), "}".to_string(), ), SubValueRelation::IteratedSubValue { field: f, .. } => v1_rt::concat( v1_rt::concat( "{\"_variant\": \"IteratedSubValue\", \"field\": ".to_string(), - serialize_inductive_field(f), + serialize_inductive_field(f.clone()), ), "}".to_string(), ), @@ -1146,11 +1148,11 @@ pub fn serialize_sub_value_relation(rel: Rc) -> String { v1_rt::concat( v1_rt::concat( "{\"_variant\": \"ArithmeticDescent\", \"param\": ".to_string(), - json_quote(p), + json_quote(p.clone()), ), ", \"factor\": ".to_string(), ), - serialize_shrink_factor(fac), + serialize_shrink_factor(fac.clone()), ), "}".to_string(), ), @@ -1168,7 +1170,7 @@ pub fn serialize_descent_evidence(de: Option>>>) -> match de { Some(evidence) => json_list(Rc::new({ let mut __result = Vec::new(); - for rel in evidence.iter().cloned() { + for rel in evidence.clone().iter().cloned() { __result.push(serialize_sub_value_relation(rel.clone())); } __result @@ -1190,7 +1192,7 @@ pub fn serialize_expr_data( ExprData::ExprLiteral { value: value, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprLiteral\", \"value\": ".to_string(), - serialize_literal(value), + serialize_literal(value.clone()), ), "}".to_string(), ), @@ -1199,11 +1201,11 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprError\", \"error_kind\": ".to_string(), - json_quote(expr_error_kind_name(kind)), + json_quote(expr_error_kind_name(kind.clone())), ), ", \"message\": ".to_string(), ), - json_quote(message), + json_quote(message.clone()), ), "}".to_string(), ), @@ -1219,20 +1221,20 @@ pub fn serialize_expr_data( ), ", \"binding_kind\": ".to_string(), ), - match binding_kind { + match binding_kind.clone() { Some(inner) => v1_rt::concat( v1_rt::concat( v1_rt::concat( "{\"kind\": ".to_string(), json_quote(var_binding_kind_name(inner.clone())), ), - match (*inner).clone() { + match (*inner.clone()).clone() { VarBindingKind::VariantValueBinding { parent_enum: parent_enum, .. } => v1_rt::concat( ", \"parent_enum\": ".to_string(), - json_quote(parent_enum), + json_quote(parent_enum.clone()), ), _ => "".to_string(), }, @@ -1259,8 +1261,8 @@ pub fn serialize_expr_data( ), ", \"summary\": ".to_string(), ), - match summary { - Some(inner) => serialize_field_summary(inner), + match summary.clone() { + Some(inner) => serialize_field_summary(inner.clone()), None => "null".to_string(), }, ), @@ -1296,11 +1298,11 @@ pub fn serialize_expr_data( ), ", \"call_semantics\": ".to_string(), ), - serialize_call_semantics(call_semantics), + serialize_call_semantics(call_semantics.clone()), ), ", \"descent_evidence\": ".to_string(), ), - serialize_descent_evidence(de), + serialize_descent_evidence(de.clone()), ), ", \"children\": ".to_string(), ), @@ -1332,7 +1334,7 @@ pub fn serialize_expr_data( ", \"method_semantics\": ".to_string(), ), serialize_method_semantics( - method_semantics, + method_semantics.clone(), source_indices.clone(), key_to_id.clone(), ), @@ -1361,12 +1363,12 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprBinOp\", \"op\": ".to_string(), - json_quote(bin_op_name(op)), + json_quote(bin_op_name(op.clone())), ), ", \"algebra_field\": ".to_string(), ), - match af { - Some(f) => json_quote(algebra_field_kind_name(f)), + match af.clone() { + Some(f) => json_quote(algebra_field_kind_name(f.clone())), None => "null".to_string(), }, ), @@ -1387,7 +1389,7 @@ pub fn serialize_expr_data( v1_rt::concat( v1_rt::concat( "{\"kind\": \"ExprUnaryOp\", \"op\": ".to_string(), - json_quote(unary_op_name(op)), + json_quote(unary_op_name(op.clone())), ), ", \"children\": ".to_string(), ), @@ -1464,7 +1466,7 @@ pub fn serialize_expr_data( ), ", \"parent_enum\": ".to_string(), ), - json_optional_string(parent_enum), + json_optional_string(parent_enum.clone()), ), ", \"children\": ".to_string(), ), @@ -1657,7 +1659,7 @@ pub fn serialize_inferred_node_ref( InferredNode::Resolved { node: node, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"Resolved\", \"node\": ".to_string(), - serialize_node_ref(node, key_to_id), + serialize_node_ref(node.clone(), key_to_id), ), "}".to_string(), ), @@ -1666,18 +1668,18 @@ pub fn serialize_inferred_node_ref( v1_rt::concat( v1_rt::concat( "{\"kind\": \"CompilerError\", \"message\": ".to_string(), - json_quote(message), + json_quote(message.clone()), ), ", \"span\": ".to_string(), ), - serialize_span(span), + serialize_span(span.clone()), ), "}".to_string(), ), InferredNode::TypeVariable { id: id, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"TypeVariable\", \"id\": ".to_string(), - json_quote(id), + json_quote(id.clone()), ), "}".to_string(), ), @@ -1856,7 +1858,7 @@ pub fn serialize_module_imports_json( } { json_list(Rc::new({ let mut __result = Vec::new(); - for imp in imports.iter().cloned() { + for imp in imports.clone().iter().cloned() { __result.push(serialize_import_node(imp.clone(), source_indices.clone())); } __result @@ -2006,11 +2008,12 @@ pub fn emit_dag_artifact(typed: Rc) -> Rc { if ((ref_errors.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: ref_errors, + diagnostics: ref_errors.clone(), }); } let source_indices = dag_graph_source_indices(typed.clone()); - let nodes_json = serialize_dag_nodes_table(order, source_indices, key_to_id.clone()); + let nodes_json = + serialize_dag_nodes_table(order.clone(), source_indices, key_to_id.clone()); let modules_json = Rc::new({ let mut __result = Vec::new(); for m in typed.modules.clone().iter().cloned() { @@ -2142,7 +2145,9 @@ pub fn emittable_graph(resolved: Rc) -> Option Some(Rc::new(EmittableGraph { graph: typed })), + Some(typed) => Some(Rc::new(EmittableGraph { + graph: typed.clone(), + })), None => None, } } @@ -2171,7 +2176,7 @@ pub fn emit_from_artifact_plan( if ((boundary_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: boundary_diags, + diagnostics: boundary_diags.clone(), }); } let results = Rc::new({ @@ -2190,7 +2195,7 @@ pub fn emit_from_artifact_plan( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in results.iter().cloned() { + for r in results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2232,14 +2237,14 @@ pub fn front_end_sources(sources: Rc>>) -> Rc empty_intern_table(), |t: Rc, p: Rc| pre_intern_tokens(p.tokens.clone(), t), ); - let parsed = prepared.iter().cloned().fold( + let parsed = prepared.clone().iter().cloned().fold( Rc::new(FrontendAccum { parse_results: Rc::new(vec![]), newline_indices: Rc::new(vec![]), intern_table: intern_table, }), |acc: Rc, p: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/compile.dag:37753:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let parsed = parse_with_table( p.tokens.clone(), @@ -2269,7 +2274,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let parse_diagnostics = collect_diagnostics(parse_results.clone()); let modules = Rc::new({ let mut __result = Vec::new(); - for p in parse_results.iter().cloned() { + for p in parse_results.clone().iter().cloned() { __result.extend( (*match p.module.clone() { Some(m) => Rc::new(vec![m.clone()]), @@ -2291,7 +2296,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc Rc::new(FrontendResult { graph: Some(graph.clone()), diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), - newline_indices: newline_indices, + newline_indices: newline_indices.clone(), intern_table: parsed.intern_table.clone(), }) } @@ -2356,7 +2361,7 @@ pub fn compile_to_resolved_with_options( source_indices: v1_rt::rc_empty_map::>(), complexity: empty_complexity_report(), ownership: Rc::new(vec![]), - newline_indices: newline_indices, + newline_indices: newline_indices.clone(), }), Some(graph) => { let source_indices = newline_indices.clone().iter().cloned().fold( @@ -2365,7 +2370,7 @@ pub fn compile_to_resolved_with_options( v1_rt::rc_map_insert(acc, index.file.clone(), index.clone()) }, ); - let norm = normalize_graph(graph, source_indices.clone()); + let norm = normalize_graph(graph.clone(), source_indices.clone()); let norm_diags = norm.diagnostics.clone(); let typed = reconcile( norm.graph.clone(), @@ -2387,7 +2392,7 @@ pub fn compile_to_resolved_with_options( let ownership = extract_ownership_proofs(typed.clone()); let ownership_diags = ownership_diagnostics(ownership.clone()); Rc::new(ResolvedPipelineResult { - graph: Some(typed), + graph: Some(typed.clone()), diagnostics: v1_rt::concat( v1_rt::concat( v1_rt::concat(frontend.diagnostics.clone(), norm_diags), @@ -2395,10 +2400,10 @@ pub fn compile_to_resolved_with_options( ), ownership_diags, ), - source_indices: source_indices, - complexity: complexity, - ownership: ownership, - newline_indices: newline_indices, + source_indices: source_indices.clone(), + complexity: complexity.clone(), + ownership: ownership.clone(), + newline_indices: newline_indices.clone(), }) } } @@ -2433,7 +2438,7 @@ pub fn emit_resolved_for_target( }), target, ); - let emit_result = emit_from_artifact_plan(emittable, artifact_plan.clone()); + let emit_result = emit_from_artifact_plan(emittable.clone(), artifact_plan.clone()); let emit_files = emit_result.files.clone(); let emit_diags = emit_result.diagnostics.clone(); let emit_errors = Rc::new({ @@ -2452,10 +2457,10 @@ pub fn emit_resolved_for_target( }; Rc::new(PipelineResult { files: final_files, - diagnostics: v1_rt::concat(resolved.diagnostics.clone(), emit_diags), + diagnostics: v1_rt::concat(resolved.diagnostics.clone(), emit_diags.clone()), complexity: resolved.complexity.clone(), ownership: resolved.ownership.clone(), - artifact_plan: artifact_plan, + artifact_plan: artifact_plan.clone(), newline_indices: resolved.newline_indices.clone(), }) } diff --git a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs index 985933310a1..b812888d2d5 100644 --- a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs +++ b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs @@ -135,14 +135,14 @@ pub fn render_coercion_test_rust(entry: Rc) -> String { pub fn first_or_empty(items: Rc>) -> String { match items.first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => "".to_string(), } } pub fn second_or_empty(items: Rc>) -> String { match items.get(1 as usize).cloned() { - Some(v) => v, + Some(v) => v.clone(), None => "".to_string(), } } @@ -161,15 +161,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(coerce_primitive_type(".to_string(), - render_target_rust_enum(t), + render_target_rust_enum(t.clone()), ), ", \"".to_string(), ), - name, + name.clone(), ), "\".into()), \"".to_string(), ), - expected, + expected.clone(), ), "\");\n".to_string(), ), @@ -185,15 +185,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(coerce_container_template(".to_string(), - render_target_rust_enum(t), + render_target_rust_enum(t.clone()), ), ", \"".to_string(), ), - name, + name.clone(), ), "\".into()), Some(\"".to_string(), ), - expected, + expected.clone(), ), "\".to_string()));\n".to_string(), ), @@ -209,15 +209,15 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( v1_rt::concat( " assert_eq!(is_copy(".to_string(), - render_target_rust_enum(t), + render_target_rust_enum(t.clone()), ), ", \"".to_string(), ), - name, + name.clone(), ), "\".into()), Some(".to_string(), ), - if expected { + if expected.clone() { "true".to_string() } else { "false".to_string() @@ -233,7 +233,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { } => { if ((arg_list.clone().len() as i64) == 1) { { - let arg0 = first_or_empty(arg_list); + let arg0 = first_or_empty(arg_list.clone()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -242,7 +242,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { v1_rt::concat( " assert_eq!(apply_inhabitant_template1(\"" .to_string(), - tmpl, + tmpl.clone(), ), "\".into(), \"".to_string(), ), @@ -250,7 +250,7 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { ), "\".into()), \"".to_string(), ), - expected, + expected.clone(), ), "\");\n".to_string(), ) @@ -259,8 +259,8 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { if ((arg_list.clone().len() as i64) == 2) { { let arg0 = first_or_empty(arg_list.clone()); - let arg1 = second_or_empty(arg_list); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" assert_eq!(apply_inhabitant_template2(\"".to_string(), tmpl), "\".into(), \"".to_string()), arg0), "\".into(), \"".to_string()), arg1), "\".into()), \"".to_string()), expected), "\");\n".to_string()) + let arg1 = second_or_empty(arg_list.clone()); + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" assert_eq!(apply_inhabitant_template2(\"".to_string(), tmpl.clone()), "\".into(), \"".to_string()), arg0), "\".into(), \"".to_string()), arg1), "\".into()), \"".to_string()), expected.clone()), "\");\n".to_string()) } } else { "".to_string() diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index c3e45272204..9cfd9c91d3c 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -328,7 +328,7 @@ pub fn method_size_effect( match method_semantics.as_deref().cloned() { Some(MethodSemantics::AlgebraMethodSemantics { size_effect: se, .. - }) => se, + }) => se.clone(), _ => None, } } @@ -340,7 +340,7 @@ pub fn method_callback_element_position( Some(MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - }) => match at { + }) => match at.clone() { Some(template) => template.callback_element_position.clone(), None => None, }, @@ -356,7 +356,7 @@ pub fn iteration_element_name( { let params = lambda_param_names_at(lambda, si); match method_callback_element_position(method_semantics) { - Some(pos) => params.get(pos as usize).cloned(), + Some(pos) => params.get(pos.clone() as usize).cloned(), None => None, } } @@ -433,7 +433,7 @@ pub fn parser_state_base_var( Some(base) => match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => Some(expr_var_name_at(base, si)), + } => Some(expr_var_name_at(base.clone(), si)), _ => None, }, None => None, @@ -449,24 +449,29 @@ pub fn parser_result_state_progress( result_name: String, ) -> DescentEvidence { match (*source).clone() { - ParserResultSource::ParserResultAdvance { input, .. } => strict_after_parser_witness(input), - ParserResultSource::ParserResultExpect { input, .. } => strict_after_parser_witness(input), + ParserResultSource::ParserResultAdvance { input, .. } => { + strict_after_parser_witness(input.clone()) + } + ParserResultSource::ParserResultExpect { input, .. } => { + strict_after_parser_witness(input.clone()) + } ParserResultSource::ParserResultEat { input, .. } => { if set_has(consumed_true_set, result_name) { - strict_after_parser_witness(input) + strict_after_parser_witness(input.clone()) } else { - input + input.clone() } } ParserResultSource::ParserResultCall { input, callee, .. } => { - if (set_has(consumed_true_set, result_name) || set_has(parser_always_advancing, callee)) + if (set_has(consumed_true_set, result_name) + || set_has(parser_always_advancing, callee.clone())) { - strict_after_parser_witness(input) + strict_after_parser_witness(input.clone()) } else { - input + input.clone() } } - ParserResultSource::ParserResultDirectState { input: p, .. } => p, + ParserResultSource::ParserResultDirectState { input: p, .. } => p.clone(), ParserResultSource::ParserResultOpaque => DescentEvidence::DescentUnknown, } } @@ -530,8 +535,8 @@ pub fn parser_state_expr_progress( if (name.clone() == state_param.name.clone()) { DescentEvidence::NonIncreasing } else { - match v1_rt::map_get(&env.state_aliases.clone(), name) { - Some(progress) => progress, + match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { + Some(progress) => progress.clone(), None => DescentEvidence::DescentUnknown, } } @@ -542,10 +547,10 @@ pub fn parser_state_expr_progress( Some(result_name) => { match v1_rt::map_get(&env.result_sources.clone(), result_name.clone()) { Some(source) => parser_result_state_progress( - source, + source.clone(), parser_always_advancing.clone(), consumed_true_set.clone(), - result_name, + result_name.clone(), ), None => DescentEvidence::DescentUnknown, } @@ -559,7 +564,7 @@ pub fn parser_state_expr_progress( ExprData::ExprCall { .. } => { match parser_passthrough_state_expr(expr.clone(), si.clone()) { Some(state_expr) => parser_state_expr_progress( - state_expr, + state_expr.clone(), state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -572,7 +577,9 @@ pub fn parser_state_expr_progress( ExprData::ExprIf => { let cond = if_condition(expr.clone()); let then_consumed = match parser_progress_flag_var(cond, si.clone()) { - Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), + Some(name) => { + v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) + } None => consumed_true_set.clone(), }; let then_progress = parser_state_expr_progress( @@ -585,7 +592,7 @@ pub fn parser_state_expr_progress( ); let else_progress = match if_else_branch(expr.clone()) { Some(eb) => parser_state_expr_progress( - eb, + eb.clone(), state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -608,7 +615,7 @@ pub fn parser_state_expr_progress( ); match let_body(expr.clone()) { Some(body) => parser_state_expr_progress( - body, + body.clone(), state_param.clone(), next_env, parser_always_advancing.clone(), @@ -634,8 +641,8 @@ pub fn parser_state_expr_progress( __result }); match arm_progresses.clone().first().cloned() { - Some(initial) => arm_progresses.iter().cloned().fold( - initial, + Some(initial) => arm_progresses.clone().iter().cloned().fold( + initial.clone(), |acc: DescentEvidence, p: DescentEvidence| { descent_evidence_lattice_meet(acc, p.clone()) }, @@ -676,7 +683,7 @@ pub fn parser_block_state_progress( .collect::>(), ); let final_env = leading.iter().cloned().fold( - env, + env.clone(), |acc_env: Rc, stmt: Rc| match (*stmt.expr_data.clone()) .clone() { @@ -696,7 +703,7 @@ pub fn parser_block_state_progress( }, ); parser_state_expr_progress( - last_stmt, + last_stmt.clone(), state_param.clone(), final_env, parser_always_advancing.clone(), @@ -720,7 +727,7 @@ pub fn parser_result_source_for_expr( let input_progress = match parser_state_arg_expr(expr.clone(), state_param.clone(), si.clone()) { Some(state_expr) => parser_state_expr_progress( - state_expr, + state_expr.clone(), state_param.clone(), env, parser_always_advancing, @@ -732,21 +739,21 @@ pub fn parser_result_source_for_expr( match (*parser_result_witness(expr.clone(), si.clone())).clone() { ParserResultWitness::ParserWitnessAdvance => { Rc::new(ParserResultSource::ParserResultAdvance { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessExpect => { Rc::new(ParserResultSource::ParserResultExpect { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessEat => { Rc::new(ParserResultSource::ParserResultEat { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessCall { callee: callee, .. } => { - match (*callee).clone() { + match (*callee.clone()).clone() { ParserCallIdentity::ParserCallHelper { helper: _, .. } => { Rc::new(ParserResultSource::ParserResultOpaque) } @@ -756,8 +763,8 @@ pub fn parser_result_source_for_expr( Rc::new(ParserResultSource::ParserResultOpaque) } _ => Rc::new(ParserResultSource::ParserResultCall { - input: input_progress, - callee: name, + input: input_progress.clone(), + callee: name.clone(), }), } } @@ -779,7 +786,9 @@ pub fn parser_result_source_for_expr( ); match progress.clone() { DescentEvidence::DescentUnknown => Rc::new(ParserResultSource::ParserResultOpaque), - _ => Rc::new(ParserResultSource::ParserResultDirectState { input: progress }), + _ => Rc::new(ParserResultSource::ParserResultDirectState { + input: progress.clone(), + }), } } } @@ -837,7 +846,7 @@ pub fn parser_call_edge_progress( match parser_state_arg_expr(call_node.clone(), state_param.clone(), si.clone()) { Some(state_expr) => { let input_progress = parser_state_expr_progress( - state_expr, + state_expr.clone(), state_param.clone(), env, parser_always_advancing.clone(), @@ -1006,8 +1015,10 @@ pub fn collect_parser_progress_edges( consumed_true_set.clone(), si.clone(), ); - let then_consumed = match parser_progress_flag_var(cond, si.clone()) { - Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), + let then_consumed = match parser_progress_flag_var(cond.clone(), si.clone()) { + Some(name) => { + v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) + } None => consumed_true_set.clone(), }; let then_edges = collect_parser_progress_edges( @@ -1023,7 +1034,7 @@ pub fn collect_parser_progress_edges( let else_edges = match if_else_branch(body.clone()) { Some(eb) => collect_parser_progress_edges( caller.clone(), - eb, + eb.clone(), state_param.clone(), scc_name_set.clone(), env.clone(), @@ -1049,7 +1060,7 @@ pub fn collect_parser_progress_edges( ); let next_env = parser_env_with_binding( let_binding_name_at(body.clone(), si.clone()), - value_expr, + value_expr.clone(), env.clone(), state_param.clone(), parser_always_advancing.clone(), @@ -1059,7 +1070,7 @@ pub fn collect_parser_progress_edges( let body_edges = match let_body(body.clone()) { Some(b) => collect_parser_progress_edges( caller.clone(), - b, + b.clone(), state_param.clone(), scc_name_set.clone(), next_env, @@ -1167,7 +1178,7 @@ pub fn parser_record_field_value( pub fn parser_expr_is_none(expr: Rc) -> bool { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -1200,7 +1211,7 @@ pub fn parser_success_progress( expr_var_name_at(expr.clone(), si.clone()), ) { Some(source) => parser_result_state_progress( - source, + source.clone(), parser_always_advancing.clone(), consumed_true_set.clone(), expr_var_name_at(expr.clone(), si.clone()), @@ -1223,14 +1234,14 @@ pub fn parser_success_progress( ExprData::ExprRecordLit { parent_enum: _, .. } => { match parser_record_field_value(expr.clone(), "err".to_string(), si.clone()) { Some(err_expr) => { - if parser_expr_is_none(err_expr) { + if parser_expr_is_none(err_expr.clone()) { match parser_record_field_value( expr.clone(), "state".to_string(), si.clone(), ) { Some(state_expr) => parser_state_expr_progress( - state_expr, + state_expr.clone(), state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -1249,7 +1260,9 @@ pub fn parser_success_progress( ExprData::ExprIf => { let cond = if_condition(expr.clone()); let then_consumed = match parser_progress_flag_var(cond, si.clone()) { - Some(name) => v1_rt::rc_map_insert(consumed_true_set.clone(), name, true), + Some(name) => { + v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) + } None => consumed_true_set.clone(), }; let then_progress = parser_success_progress( @@ -1262,7 +1275,7 @@ pub fn parser_success_progress( ); let else_progress = match if_else_branch(expr.clone()) { Some(eb) => parser_success_progress( - eb, + eb.clone(), state_param.clone(), env.clone(), parser_always_advancing.clone(), @@ -1285,9 +1298,9 @@ pub fn parser_success_progress( ); match let_body(expr.clone()) { Some(body) => parser_success_progress( - body, + body.clone(), state_param.clone(), - next_env, + next_env.clone(), parser_always_advancing.clone(), consumed_true_set.clone(), si.clone(), @@ -1334,7 +1347,7 @@ pub fn parser_success_progress( ); match expr.children.clone().last().cloned() { Some(last_stmt) => parser_success_progress( - last_stmt, + last_stmt.clone(), state_param.clone(), acc.env.clone(), parser_always_advancing.clone(), @@ -1381,7 +1394,7 @@ pub fn parser_member_is_always_advancing( __all } && (parser_success_progress( entry.body.clone(), - state_param, + state_param.clone(), empty_parser_progress_env(), proven.clone(), v1_rt::rc_empty_map::(), @@ -1413,7 +1426,7 @@ pub fn infer_parser_always_advancing_members_worklist( ); if set_has(proven.clone(), name.clone()) { { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } @@ -1431,8 +1444,7 @@ pub fn infer_parser_always_advancing_members_worklist( None => Rc::new(vec![]), }; { - let __tco_0 = - deduplicate(v1_rt::concat(rest.clone(), callers.clone())); + let __tco_0 = deduplicate(v1_rt::concat(rest, callers)); let __tco_1 = v1_rt::rc_map_insert(proven, name.clone(), true); queue = __tco_0; proven = __tco_1; @@ -1440,14 +1452,14 @@ pub fn infer_parser_always_advancing_members_worklist( } } else { { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } } } None => { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } @@ -1606,7 +1618,7 @@ pub fn same_progress_subgraph_has_cycle( { let same_cross_edges = Rc::new({ let mut __result = Vec::new(); - for edge in same_edges.iter().cloned() { + for edge in same_edges.clone().iter().cloned() { if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } @@ -1711,7 +1723,7 @@ pub fn classify_parser_scc_recursion_pattern( __all }; if (all_known - && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) { Some(lower_call_pattern(Rc::new( CallPattern::ParserAdvanceCall { @@ -1844,7 +1856,7 @@ pub fn max_path_self_calls_with_cont( ); let else_calls = match if_else_branch(body.clone()) { Some(eb) => max_path_self_calls_with_cont( - eb, + eb.clone(), func_name.clone(), continue_calls.clone(), si.clone(), @@ -1852,9 +1864,9 @@ pub fn max_path_self_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls + then_calls.clone() } else { - else_calls + else_calls.clone() }; (cond_calls + branch_max) } @@ -1875,7 +1887,7 @@ pub fn max_path_self_calls_with_cont( ); let body_calls = match let_body(body.clone()) { Some(b) => max_path_self_calls_with_cont( - b, + b.clone(), func_name.clone(), continue_calls.clone(), si.clone(), @@ -1960,12 +1972,12 @@ pub fn max_path_self_calls_block( continue_calls: i64, si: Rc>>, ) -> i64 { - v1_rt::reverse(stmts) - .iter() - .cloned() - .fold(continue_calls, |acc: i64, stmt: Rc| { + v1_rt::reverse(stmts).iter().cloned().fold( + continue_calls.clone(), + |acc: i64, stmt: Rc| { max_path_self_calls_with_cont(stmt.clone(), func_name.clone(), acc, si.clone()) - }) + }, + ) } pub fn count_target_calls( @@ -2071,7 +2083,7 @@ pub fn max_path_target_calls_with_cont( ); let else_calls = match if_else_branch(body.clone()) { Some(eb) => max_path_target_calls_with_cont( - eb, + eb.clone(), target_set.clone(), continue_calls.clone(), si.clone(), @@ -2079,9 +2091,9 @@ pub fn max_path_target_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls + then_calls.clone() } else { - else_calls + else_calls.clone() }; (cond_calls + branch_max) } @@ -2102,7 +2114,7 @@ pub fn max_path_target_calls_with_cont( ); let body_calls = match let_body(body.clone()) { Some(b) => max_path_target_calls_with_cont( - b, + b.clone(), target_set.clone(), continue_calls.clone(), si.clone(), @@ -2220,10 +2232,11 @@ pub fn target_call_has_arithmetic_descent( } else { match v1_rt::map_get(&func_index, callee.clone()) { Some(callee_entry) => { - let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee) { - Some(params) => params, - None => v1_rt::rc_empty_map::(), - }; + let callee_measure_params = + match v1_rt::map_get(&scc_measure_params, callee.clone()) { + Some(params) => params.clone(), + None => v1_rt::rc_empty_map::(), + }; { let mut __found = false; for pair in Rc::new( @@ -2359,7 +2372,7 @@ pub fn expr_descending_witness_source( } => { break v1_rt::map_get( &descending_witness_names, - expr_var_name_at(expr.clone(), si.clone()), + expr_var_name_at(expr.clone(), si), ); } ExprData::ExprBinOp { op, .. } => match op.clone() { @@ -2394,9 +2407,9 @@ pub fn condition_param_names( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(expr.clone(), si); + let name = expr_var_name_at(expr.clone(), si.clone()); match v1_rt::map_get(¶m_set, name.clone()) { - Some(_) => seed_string_map(name.clone(), name), + Some(_) => seed_string_map(name.clone(), name.clone()), None => v1_rt::rc_empty_map::(), } } @@ -2437,7 +2450,9 @@ pub fn recursive_measure_param_names( si.clone(), ); let else_names = match if_else_branch(body.clone()) { - Some(eb) => recursive_measure_param_names(eb, params.clone(), si.clone()), + Some(eb) => { + recursive_measure_param_names(eb.clone(), params.clone(), si.clone()) + } None => v1_rt::rc_empty_map::(), }; v1_rt::rc_map_merge( @@ -2467,7 +2482,7 @@ pub fn recursive_measure_param_names( v1_rt::rc_map_merge(scrut_names, arm_names) } ExprData::ExprLet => match let_body(body.clone()) { - Some(b) => recursive_measure_param_names(b, params.clone(), si.clone()), + Some(b) => recursive_measure_param_names(b.clone(), params.clone(), si.clone()), None => v1_rt::rc_empty_map::(), }, ExprData::ExprBlock => body.children.clone().iter().cloned().fold( @@ -2499,7 +2514,7 @@ pub fn recursive_param_name_for_arg( si: Rc>>, ) -> Option { match arg_name_at(arg_node, si.clone()) { - Some(name) => Some(name), + Some(name) => Some(name.clone()), None => Rc::new({ let mut __result = Vec::new(); for pair in Rc::new({ @@ -2535,7 +2550,7 @@ pub fn recursive_param_name_for_arg( pub fn is_descending_expr(expr: Rc) -> bool { match (*expr.expr_data.clone()).clone() { - ExprData::ExprBinOp { op, .. } => match op { + ExprData::ExprBinOp { op, .. } => match op.clone() { BinOp::Sub => match (*binop_left(expr.clone()).expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. @@ -2649,18 +2664,18 @@ pub fn is_children_of_param( ExprData::ExprFieldAccess { .. } => { let base = field_access_base(expr.clone()); let field = field_access_field_at(expr.clone(), si.clone()); - break (is_children_list_field(field.clone()) + break (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name.clone()), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }); } ExprData::ExprVar { binding_kind: _, .. } => { - break set_has(vars.clone(), expr_var_name_at(expr.clone(), si.clone())); + break set_has(vars, expr_var_name_at(expr.clone(), si.clone())); } ExprData::ExprMethodCall { method_semantics: ms, @@ -2698,14 +2713,14 @@ pub fn is_structural_children( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(base, si.clone())), + } => set_has(vars.clone(), expr_var_name_at(base.clone(), si.clone())), _ => false, }) } ExprData::ExprMethodCall { method_semantics: ms, .. - } => match method_size_effect(ms) { + } => match method_size_effect(ms.clone()) { Some(CollectionSizeEffect::ShrinkEffect) => is_structural_children( method_receiver(expr.clone()), param_name.clone(), @@ -2738,7 +2753,7 @@ pub fn is_child_descent_expr( ExprData::ExprMethodCall { method_semantics: ms, .. - } => match method_size_effect(ms) { + } => match method_size_effect(ms.clone()) { Some(CollectionSizeEffect::ProjectionEffect) => is_children_of_param( method_receiver(expr.clone()), param_name.clone(), @@ -2767,8 +2782,8 @@ pub fn is_tree_size_preserving_wrapper( pub fn wrapper_inner_arg(expr: Rc) -> Rc { match expr.children.clone().first().cloned() { - Some(arg_node) => arg_value(arg_node), - None => expr, + Some(arg_node) => arg_value(arg_node.clone()), + None => expr.clone(), } } @@ -2784,8 +2799,8 @@ pub fn is_sub_value_extractor(expr: Rc, si: Rc) -> Rc { match expr.children.clone().first().cloned() { - Some(arg_node) => arg_value(arg_node), - None => expr, + Some(arg_node) => arg_value(arg_node.clone()), + None => expr.clone(), } } @@ -2799,7 +2814,7 @@ pub fn is_list_shrink_expr( method_semantics: ms, .. } => { - let is_shrink = match method_size_effect(ms) { + let is_shrink = match method_size_effect(ms.clone()) { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }; @@ -2811,15 +2826,17 @@ pub fn is_list_shrink_expr( _ => false, }) && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { - unreachable!() - }; - (n > 0) + Some(arg_node) => { + match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { + unreachable!() + }; + (n.clone() > 0) + } + _ => false, } - _ => false, - }, + } None => false, }) } @@ -2833,21 +2850,23 @@ pub fn is_generalized_shrink(expr: Rc, si: Rc { - let is_shrink = match method_size_effect(ms) { + let is_shrink = match method_size_effect(ms.clone()) { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }; (is_shrink && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { - unreachable!() - }; - (n > 0) + Some(arg_node) => { + match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { + unreachable!() + }; + (n.clone() > 0) + } + _ => false, } - _ => false, - }, + } None => false, }) } @@ -2881,7 +2900,9 @@ pub fn is_tokens_consuming_call( ) -> bool { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => match consuming_tokens_arg(expr.clone(), si.clone()) { - Some(tokens_arg) => is_tokens_input_expr(tokens_arg, param_name, vars, si.clone()), + Some(tokens_arg) => { + is_tokens_input_expr(tokens_arg.clone(), param_name, vars, si.clone()) + } None => false, }, _ => false, @@ -2923,12 +2944,11 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone() == param_name.clone()) - || set_has(vars.clone(), vname.clone())); + break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field.clone() == param_name.clone()) { + if (field == param_name.clone()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2938,7 +2958,7 @@ pub fn is_tokens_input_expr( } => { let bname = expr_var_name_at(base.clone(), si.clone()); break ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())); + || set_has(vars, bname.clone())); } _ => { break false; @@ -3047,7 +3067,7 @@ pub fn expr_contains_descent( si.clone(), ) && match if_else_branch(expr.clone()) { Some(eb) => expr_contains_descent( - eb, + eb.clone(), param_name.clone(), vars.clone(), check_child.clone(), @@ -3059,7 +3079,7 @@ pub fn expr_contains_descent( } ExprData::ExprBlock => match expr.children.clone().last().cloned() { Some(last_stmt) => expr_contains_descent( - last_stmt, + last_stmt.clone(), param_name.clone(), vars.clone(), check_child.clone(), @@ -3079,9 +3099,9 @@ pub fn expr_contains_descent( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3091,7 +3111,7 @@ pub fn expr_contains_descent( .. } => { let receiver = method_receiver(expr.clone()); - match method_size_effect(ms) { + match method_size_effect(ms.clone()) { Some(CollectionSizeEffect::ShrinkEffect) => expr_contains_descent( receiver, param_name.clone(), @@ -3135,11 +3155,11 @@ pub fn collect_field_binding_names( || match (*field_binding_pattern(fb)).clone() { MatchPattern::Bind { name: binding_name, .. - } => v1_rt::rc_map_insert(vars, binding_name, true), + } => v1_rt::rc_map_insert(vars, binding_name.clone(), true), MatchPattern::VariantPattern { field_bindings: nested, .. - } => nested.iter().cloned().fold( + } => nested.clone().iter().cloned().fold( vars, |inner: Rc>, nested_fb: Rc| { collect_field_binding_names(nested_fb.clone(), inner) @@ -3173,8 +3193,8 @@ pub fn is_if_option_descent( Some(eb) => match (*eb.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(eb, si.clone()) == "none".to_string()), - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + } => (expr_var_name_at(eb.clone(), si.clone()) == "none".to_string()), + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -3374,7 +3394,7 @@ pub fn collect_descent_vars( } _ => false, }; - ((inner_is_descent || inner_is_var) || inner_is_param) + ((inner_is_descent.clone() || inner_is_var.clone()) || inner_is_param) } } else { false @@ -3388,9 +3408,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3416,7 +3436,10 @@ pub fn collect_descent_vars( || match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(inner, si.clone())), + } => set_has( + vars.clone(), + expr_var_name_at(inner.clone(), si.clone()), + ), _ => false, }) } @@ -3426,7 +3449,12 @@ pub fn collect_descent_vars( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); + && is_tokens_consuming_call( + val.clone(), + param_name.clone(), + vars.clone(), + si.clone(), + )); let val_is_descent = ((((((((is_direct_descent || is_descent_var) || is_option_descent) || is_match_descent) @@ -3446,7 +3474,7 @@ pub fn collect_descent_vars( }; match let_body(body.clone()) { Some(b) => collect_descent_vars( - b, + b.clone(), param_name.clone(), next_vars, check_child.clone(), @@ -3470,8 +3498,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -3533,7 +3562,7 @@ pub fn collect_descent_vars( ); let else_vars = match if_else_branch(body.clone()) { Some(eb) => collect_descent_vars( - eb, + eb.clone(), param_name.clone(), vars.clone(), check_child.clone(), @@ -3559,7 +3588,7 @@ pub fn collect_descent_vars( ), ExprData::ExprReturn => match body.children.clone().first().cloned() { Some(inner) => collect_descent_vars( - inner, + inner.clone(), param_name.clone(), vars.clone(), check_child.clone(), @@ -3641,15 +3670,15 @@ pub fn all_self_calls_descend_inc( let is_children_list = match (*val.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(val.clone()); - let field = field_access_field_at(val, si.clone()); + let field = field_access_field_at(val.clone(), si.clone()); (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3667,10 +3696,10 @@ pub fn all_self_calls_descend_inc( }; let body_ok = match let_body(body.clone()) { Some(b) => all_self_calls_descend_inc( - b, + b.clone(), func_name.clone(), param_name.clone(), - next_vars, + next_vars.clone(), check_child.clone(), check_list.clone(), si.clone(), @@ -3702,8 +3731,9 @@ pub fn all_self_calls_descend_inc( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -3779,7 +3809,7 @@ pub fn all_self_calls_descend_inc( ); let else_ok = match if_else_branch(body.clone()) { Some(eb) => all_self_calls_descend_inc( - eb, + eb.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -3895,7 +3925,7 @@ pub fn all_self_calls_descend_inc( if (is_iter && is_struct) { { let recv_ok = all_self_calls_descend_inc( - receiver, + receiver.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -4034,16 +4064,16 @@ pub fn matches_on_sub_value_field( ) -> bool { match unwrap_to_match(body) { Some(m) => { - let scrut = match_scrutinee(m); + let scrut = match_scrutinee(m.clone()); match (*scrut.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(scrut.clone()); - let field = field_access_field_at(scrut, si.clone()); + let field = field_access_field_at(scrut.clone(), si.clone()); (is_sub_value_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base, si.clone()) == param_name), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }) } @@ -4124,13 +4154,13 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left, si) == param_name) + ((expr_var_name_at(left.clone(), si) == param_name) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { unreachable!() }; - (n > 0) + (n.clone() > 0) } _ => false, }) @@ -4179,7 +4209,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname == param_name.clone()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4211,7 +4241,7 @@ pub fn classify_self_call_evidence( DescentEvidence::NonIncreasing => { DescentEvidence::Strict } - _ => inner_ev, + _ => inner_ev.clone(), } } } else { @@ -4221,7 +4251,7 @@ pub fn classify_self_call_evidence( si.clone(), ) { Some(inner) => classify_self_call_evidence( - inner, + inner.clone(), param_name.clone(), descent_vars.clone(), check_child.clone(), @@ -4242,9 +4272,9 @@ pub fn classify_self_call_evidence( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname == param_name.clone())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { @@ -4457,7 +4487,7 @@ pub fn collect_evidence_incremental( } _ => false, }; - ((inner_d || inner_v) || inner_p) + ((inner_d.clone() || inner_v.clone()) || inner_p) } } else { false @@ -4471,9 +4501,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -4499,7 +4529,10 @@ pub fn collect_evidence_incremental( || match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(inner, si.clone())), + } => set_has( + vars.clone(), + expr_var_name_at(inner.clone(), si.clone()), + ), _ => false, }) } @@ -4509,7 +4542,12 @@ pub fn collect_evidence_incremental( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); + && is_tokens_consuming_call( + val.clone(), + param_name.clone(), + vars.clone(), + si.clone(), + )); let next_vars = if ((((((((is_direct || is_var) || is_option) || is_match_descent) || is_wrapped) @@ -4528,10 +4566,10 @@ pub fn collect_evidence_incremental( }; let body_ev = match let_body(body.clone()) { Some(b) => collect_evidence_incremental( - b, + b.clone(), func_name.clone(), param_name.clone(), - next_vars, + next_vars.clone(), check_child.clone(), check_list.clone(), branching_only.clone(), @@ -4565,8 +4603,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -4663,7 +4702,7 @@ pub fn collect_evidence_incremental( None } else { collect_evidence_incremental( - then_branch, + then_branch.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -4676,9 +4715,9 @@ pub fn collect_evidence_incremental( let else_ev = if (branching_only.clone() && (else_path == 0)) { None } else { - match else_opt { + match else_opt.clone() { Some(eb) => collect_evidence_incremental( - eb, + eb.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -4791,7 +4830,7 @@ pub fn collect_evidence_incremental( if (is_iter && is_struct) { { let recv_ev = collect_evidence_incremental( - receiver, + receiver.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -5019,7 +5058,7 @@ pub fn construct_termination_proof( } }); let single_dim_proof = match structural_proof.clone() { - Some(_) => structural_proof, + Some(_) => structural_proof.clone(), None => match parser_state_param(params.clone(), si.clone()) { Some(state_param) => { let self_set = seed_bool_map(func_name.clone()); @@ -5035,7 +5074,7 @@ pub fn construct_termination_proof( ); if (((edges.clone().len() as i64) > 0) && { let mut __all = true; - for edge in edges.iter().cloned() { + for edge in edges.clone().iter().cloned() { if !(edge.progress.clone() == DescentEvidence::Strict) { __all = false; break; @@ -5056,7 +5095,7 @@ pub fn construct_termination_proof( }, }; match single_dim_proof.clone() { - Some(_) => single_dim_proof, + Some(_) => single_dim_proof.clone(), None => { let self_set = seed_bool_map(func_name.clone()); let func_entry = Rc::new(FuncEntry { @@ -5070,7 +5109,7 @@ pub fn construct_termination_proof( construct_scc_termination_proof( Rc::new(vec![func_name.clone()]), func_index, - self_set, + self_set.clone(), si.clone(), ) } @@ -5174,27 +5213,29 @@ pub fn construct_branching_termination_proof( pub fn proof_to_call_pattern(proof: Rc) -> Rc { match proof.dimensions.clone().first().cloned() { - Some(dim) => match (*dim).clone() { + Some(dim) => match (*dim.clone()).clone() { RankingDimension::TreeSize { param: p, .. } => { - Rc::new(CallPattern::ChildAccessorCall { accessor: p }) + Rc::new(CallPattern::ChildAccessorCall { + accessor: p.clone(), + }) } RankingDimension::ListLength { param: p, .. } => { Rc::new(CallPattern::CollectionShrinkCall { amount: Rc::new(PositiveDescentAmount::OneStep), - collection: p, + collection: p.clone(), }) } RankingDimension::ArithmeticValue { param: p, .. } => { Rc::new(CallPattern::ArithmeticSubtractCall { steps: Rc::new(PositiveDescentAmount::OneStep), - ring_param: p, + ring_param: p.clone(), }) } RankingDimension::TokenPosition { param: p, .. } => { - Rc::new(CallPattern::ParserAdvanceCall { witness: p }) + Rc::new(CallPattern::ParserAdvanceCall { witness: p.clone() }) } RankingDimension::SetCardinality { param: p, .. } => { - Rc::new(CallPattern::WorklistDrainCall { element: p }) + Rc::new(CallPattern::WorklistDrainCall { element: p.clone() }) } }, None => Rc::new(CallPattern::SameArgumentCall), @@ -5213,7 +5254,7 @@ pub fn classify_recursion_pattern( if (path_calls.clone() == 0) { { let outer = match params.clone().first().cloned() { - Some(p0) => param_node_name_at(p0, si.clone()), + Some(p0) => param_node_name_at(p0.clone(), si.clone()), None => "_fold_body".to_string(), }; lower_call_pattern(Rc::new(CallPattern::FoldBodyCall { @@ -5296,7 +5337,7 @@ pub fn classify_recursion_pattern( let first_call = if all_calls_arithmetic_only { Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.iter().cloned() { + for call_ev in all_evidence.clone().iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5345,10 +5386,10 @@ pub fn classify_recursion_pattern( __result }); match tree_rels.clone().first().cloned() { - Some(_) => tree_rels.first().cloned(), + Some(_) => tree_rels.clone().first().cloned(), None => Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.iter().cloned() { + for call_ev in all_evidence.clone().iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5373,7 +5414,9 @@ pub fn classify_recursion_pattern( }; let is_arithmetic_branching = match first_call.clone() { Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::ArithmeticDescent { .. } => (path_calls > 1), + SubValueRelation::ArithmeticDescent { .. } => { + (path_calls.clone() > 1) + } _ => false, }, None => false, @@ -5381,9 +5424,9 @@ pub fn classify_recursion_pattern( if is_arithmetic_branching { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } else { - match first_call { - Some(rel) => match sub_value_to_lowering_target(rel) { - Some(target) => target, + match first_call.clone() { + Some(rel) => match sub_value_to_lowering_target(rel.clone()) { + Some(target) => target.clone(), None => { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } @@ -5462,16 +5505,16 @@ pub fn classify_recursion_pattern( } None => false, }; - match proof { + match proof.clone() { Some(p) => { - if ((path_calls == 1) || proof_safe_for_branching) { - lower_call_pattern(proof_to_call_pattern(p)) + if ((path_calls.clone() == 1) || proof_safe_for_branching.clone()) { + lower_call_pattern(proof_to_call_pattern(p.clone())) } else { if branching_proof_safe { - match branching_proof { - Some(bp) => { - lower_call_pattern(proof_to_call_pattern(bp)) - } + match branching_proof.clone() { + Some(bp) => lower_call_pattern(proof_to_call_pattern( + bp.clone(), + )), None => lower_call_pattern(Rc::new( CallPattern::SameArgumentCall, )), @@ -5482,11 +5525,13 @@ pub fn classify_recursion_pattern( } } None => { - if (path_calls > 1) { - match branching_proof { + if (path_calls.clone() > 1) { + match branching_proof.clone() { Some(bp) => { if branching_proof_safe { - lower_call_pattern(proof_to_call_pattern(bp)) + lower_call_pattern(proof_to_call_pattern( + bp.clone(), + )) } else { lower_call_pattern(Rc::new( CallPattern::SameArgumentCall, @@ -5518,10 +5563,10 @@ pub fn bounded_recursive_cost( let p = size_bound_param(target.bound.clone()); match p { Some(v) => { - let var = v1_rt::concat("n_".to_string(), v); + let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var }), + upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), body: simplify_cost(per_iter), }) } @@ -5541,10 +5586,10 @@ pub fn bounded_scc_cost( let p = size_bound_param(target.bound.clone()); match p { Some(v) => { - let var = v1_rt::concat("n_".to_string(), v); + let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var }), + upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), body: simplify_cost(per_iter), }) } @@ -5552,7 +5597,7 @@ pub fn bounded_scc_cost( reason: v1_rt::concat( "same-argument mutual recursion in ".to_string(), match members.first().cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "scc".to_string(), }, ), @@ -5566,21 +5611,21 @@ pub fn is_unknown_cost(expr: Rc) -> bool { CostExpr::CostUnknown { reason: _, .. } => true, CostExpr::CostAdd { left: l, right: r, .. - } => (is_unknown_cost(l) || is_unknown_cost(r)), + } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), CostExpr::CostMul { left: l, right: r, .. - } => (is_unknown_cost(l) || is_unknown_cost(r)), + } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), CostExpr::CostMax { left: l, right: r, .. - } => (is_unknown_cost(l) || is_unknown_cost(r)), - CostExpr::CostSum { body: bd, .. } => is_unknown_cost(bd), + } => (is_unknown_cost(l.clone()) || is_unknown_cost(r.clone())), + CostExpr::CostSum { body: bd, .. } => is_unknown_cost(bd.clone()), _ => false, }) } pub fn extract_unknown_reason(mut expr: Rc) -> String { loop { - match (*expr.clone()).clone() { + match (*expr).clone() { CostExpr::CostUnknown { reason: r, .. } => { break r.clone(); } @@ -5660,7 +5705,7 @@ pub fn collect_local_call_edges_in_expr( if set_has(local_func_set.clone(), callee.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: callee, + callee: callee.clone(), })]) } else { Rc::new(vec![]) @@ -5750,7 +5795,7 @@ pub fn build_call_graph( pub fn scc_label(members: Rc>) -> String { match members.first().cloned() { - Some(name) => name, + Some(name) => name.clone(), None => "scc".to_string(), } } @@ -5781,7 +5826,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname == param_name.clone()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5807,14 +5852,14 @@ pub fn classify_scc_call_progress( ); match inner_progress.clone() { DescentEvidence::NonIncreasing => DescentEvidence::Strict, - _ => inner_progress, + _ => inner_progress.clone(), } } } else { if is_list_passthrough_call(arg_expr.clone(), si.clone()) { match list_passthrough_inner_arg(arg_expr.clone(), si.clone()) { Some(inner) => classify_scc_call_progress( - inner, + inner.clone(), param_name.clone(), descent_vars.clone(), si.clone(), @@ -5833,9 +5878,9 @@ pub fn classify_scc_call_progress( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname == param_name.clone())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { @@ -5905,7 +5950,7 @@ pub fn collect_scc_child_edges( { let callee_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { - Some(p) => p, + Some(p) => p.clone(), None => v1_rt::rc_empty_map::(), }; let progress = body.children.clone().iter().cloned().fold( @@ -5942,7 +5987,7 @@ pub fn collect_scc_child_edges( ); Rc::new(vec![Rc::new(ParserProgressEdge { caller: caller.clone(), - callee: callee, + callee: callee.clone(), progress: progress, })]) } @@ -5987,7 +6032,7 @@ pub fn collect_scc_child_edges( if (is_iter && is_struct) { { let recv_edges = collect_scc_child_edges( - receiver, + receiver.clone(), caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6184,7 +6229,7 @@ pub fn collect_scc_child_edges( } _ => false, }; - ((inner_d || inner_v) || inner_p) + ((inner_d.clone() || inner_v.clone()) || inner_p) } } else { false @@ -6198,9 +6243,9 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(descent_vars.clone(), bname)) + || set_has(descent_vars.clone(), bname.clone())) } _ => false, }) @@ -6228,7 +6273,7 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => set_has( descent_vars.clone(), - expr_var_name_at(inner, si.clone()), + expr_var_name_at(inner.clone(), si.clone()), ), _ => false, }) @@ -6240,7 +6285,7 @@ pub fn collect_scc_child_edges( }; let is_consuming_helper = (check_list.clone() && is_tokens_consuming_call( - val, + val.clone(), param_name.clone(), descent_vars.clone(), si.clone(), @@ -6263,10 +6308,10 @@ pub fn collect_scc_child_edges( }; let body_edges = match let_body(body.clone()) { Some(b) => collect_scc_child_edges( - b, + b.clone(), caller.clone(), param_name.clone(), - next_vars, + next_vars.clone(), target_set.clone(), check_child.clone(), check_list.clone(), @@ -6374,7 +6419,7 @@ pub fn collect_scc_child_edges( ); let else_edges = match else_opt { Some(eb) => collect_scc_child_edges( - eb, + eb.clone(), caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6475,7 +6520,7 @@ pub fn is_scc_container_child_descent( }); let unknown_edge_count = count_unknown_progress_edges(edges.clone()); (((unknown_edge_count == 0) && ((edges.clone().len() as i64) > 0)) - && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) } } @@ -6587,9 +6632,9 @@ pub fn pick_best_param_edges( candidate: Rc>, ) -> Rc> { if (count_known_in_edge_map(candidate.clone()) > count_known_in_edge_map(current.clone())) { - candidate + candidate.clone() } else { - current + current.clone() } } @@ -6900,17 +6945,20 @@ pub fn construct_scc_termination_proof( let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { param: if (cx_l2_param.clone() != "".to_string()) { - cx_l2_param + cx_l2_param.clone() } else { "scc".to_string() }, })]), }); if ((cx_l2_all_known && ((cx_l2_edges.clone().len() as i64) > 0)) - && (proof_has_non_descending_cycle(cx_l2_proof.clone(), members.clone(), cx_l2_edges) - == false)) + && (proof_has_non_descending_cycle( + cx_l2_proof.clone(), + members.clone(), + cx_l2_edges.clone(), + ) == false)) { - Some(cx_l2_proof) + Some(cx_l2_proof.clone()) } else { { let tree_edges = collect_scc_proof_edges_for_dim( @@ -6943,10 +6991,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tree_proof.clone(), members.clone(), - tree_edges, + tree_edges.clone(), ) == false)) { - Some(tree_proof) + Some(tree_proof.clone()) } else { { let list_edges = collect_scc_proof_edges_for_dim( @@ -6979,10 +7027,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( list_proof.clone(), members.clone(), - list_edges, + list_edges.clone(), ) == false)) { - Some(list_proof) + Some(list_proof.clone()) } else { { let parser_edges = collect_scc_parser_proof_edges( @@ -7015,10 +7063,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( parser_proof.clone(), members.clone(), - parser_edges, + parser_edges.clone(), ) == false)) { - Some(parser_proof) + Some(parser_proof.clone()) } else { { let lex_edges = collect_scc_independent_dim_edges( @@ -7058,10 +7106,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( lex_proof.clone(), members.clone(), - lex_edges, + lex_edges.clone(), ) == false)) { - Some(lex_proof) + Some(lex_proof.clone()) } else { { let tree_parser_edges = @@ -7112,10 +7160,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tp_proof.clone(), members.clone(), - tree_parser_edges, + tree_parser_edges.clone(), ) == false)) { - Some(tp_proof) + Some(tp_proof.clone()) } else { None } @@ -7151,7 +7199,7 @@ pub fn classify_scc_recursion_pattern( si.clone(), ); match proof { - Some(p) => lower_call_pattern(proof_to_call_pattern(p)), + Some(p) => lower_call_pattern(proof_to_call_pattern(p.clone())), None => { let scc_measure_params = build_scc_measure_params(members.clone(), func_index.clone(), si.clone()); @@ -7160,7 +7208,7 @@ pub fn classify_scc_recursion_pattern( func_index.clone(), si.clone(), ) { - Some(parser_target) => parser_target, + Some(parser_target) => parser_target.clone(), None => { let all_arithmetic = { let mut __all = true; @@ -7191,15 +7239,18 @@ pub fn classify_scc_recursion_pattern( if all_arithmetic { { let ring_param = match members.clone().first().cloned() { - Some(m0) => match v1_rt::map_get(&scc_measure_params, m0) { - Some(pmap) => { - match Rc::new(v1_rt::map_keys(&pmap)).first().cloned() { - Some(k) => k, + Some(m0) => { + match v1_rt::map_get(&scc_measure_params, m0.clone()) { + Some(pmap) => match Rc::new(v1_rt::map_keys(&pmap)) + .first() + .cloned() + { + Some(k) => k.clone(), None => "_scc_arithmetic".to_string(), - } + }, + None => "_scc_arithmetic".to_string(), } - None => "_scc_arithmetic".to_string(), - }, + } None => "_scc_arithmetic".to_string(), }; lower_call_pattern(Rc::new(CallPattern::ArithmeticSubtractCall { @@ -7312,9 +7363,9 @@ pub fn build_scc_index( ); Rc::new(SccResult { index: result.index.clone(), - topo_order: topo_order, + topo_order: topo_order.clone(), processing_order: finish.order.clone(), - call_graph: graph, + call_graph: graph.clone(), }) } } @@ -7323,9 +7374,9 @@ pub fn cost_seq(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a, + CostExpr::CostConst { value: 0, .. } => a.clone(), _ => Rc::new(CostExpr::CostAdd { - left: a, + left: a.clone(), right: b.clone(), }), }, @@ -7336,9 +7387,9 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a, + CostExpr::CostConst { value: 0, .. } => a.clone(), _ => Rc::new(CostExpr::CostMax { - left: a, + left: a.clone(), right: b.clone(), }), }, @@ -7387,7 +7438,7 @@ pub fn method_preserves_collection_size(method_semantics: Option match se { + } => match se.clone() { Some(CollectionSizeEffect::ShrinkEffect) => true, Some(CollectionSizeEffect::IdentityEffect) => true, _ => false, @@ -7405,12 +7456,12 @@ pub fn receiver_size_var( match (*recv.expr_data.clone()).clone() { ExprData::ExprVar { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: expr_var_name_at(recv.clone(), si.clone()), + collection: expr_var_name_at(recv.clone(), si), }); } ExprData::ExprFieldAccess { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: field_access_field_at(recv.clone(), si.clone()), + collection: field_access_field_at(recv.clone(), si), }); } ExprData::ExprMethodCall { @@ -7423,7 +7474,7 @@ pub fn receiver_size_var( }; if method_preserves_collection_size(method_semantics.clone()) { { - let __tco_0 = inner_recv.clone(); + let __tco_0 = inner_recv; recv = __tco_0; continue; } @@ -7444,8 +7495,8 @@ pub fn receiver_size_var( pub fn size_binder_name(size: Rc) -> String { match (*size).clone() { - SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c), - SizeExpr::SizeVar { name: n, .. } => n, + SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c.clone()), + SizeExpr::SizeVar { name: n, .. } => n.clone(), _ => "_i".to_string(), } } @@ -7467,7 +7518,7 @@ pub fn resolve_lambda_arg( .first() .cloned(); match f_arg { - Some(fa) => Some(arg_value(fa)), + Some(fa) => Some(arg_value(fa.clone())), None => Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { @@ -7496,7 +7547,7 @@ pub fn resolve_callback_cost( let fn_ref = expr_var_name_at(la.clone(), si.clone()); match v1_rt::map_get(&func_index, fn_ref.clone()) { Some(_) => get_or_compute_summary( - fn_ref, + fn_ref.clone(), func_index.clone(), scc_index, recv_r.table.clone(), @@ -7505,7 +7556,7 @@ pub fn resolve_callback_cost( si.clone(), ), None => cost_of_expr( - la, + la.clone(), func_index.clone(), scc_index, recv_r.table.clone(), @@ -7516,7 +7567,7 @@ pub fn resolve_callback_cost( } } _ => cost_of_expr( - la, + la.clone(), func_index.clone(), scc_index, recv_r.table.clone(), @@ -7585,7 +7636,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), @@ -7596,7 +7647,7 @@ pub fn cost_of_method_by_shape( let lambda_arg = resolve_lambda_arg(mc_args, si.clone()); let key_result = match lambda_arg { Some(la) => cost_of_expr( - la, + la.clone(), func_index, scc_index, recv_r.table.clone(), @@ -7634,7 +7685,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), @@ -7662,7 +7713,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), @@ -7721,29 +7772,29 @@ pub fn empty_complexity_report() -> Rc { pub fn simplify_cost(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr, + CostExpr::CostConst { value: _, .. } => expr.clone(), CostExpr::CostAdd { left: l, right: r, .. } => { - let sl = simplify_cost(l); - let sr = simplify_cost(r); + let sl = simplify_cost(l.clone()); + let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr, + CostExpr::CostConst { value: 0, .. } => sr.clone(), CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, - CostExpr::CostConst { value: b, .. } => { - Rc::new(CostExpr::CostConst { value: (a + b) }) - } + CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: b, .. } => Rc::new(CostExpr::CostConst { + value: (a.clone() + b.clone()), + }), _ => Rc::new(CostExpr::CostAdd { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), _ => Rc::new(CostExpr::CostAdd { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7752,21 +7803,21 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostMul { left: l, right: r, .. } => { - let sl = simplify_cost(l); - let sr = simplify_cost(r); + let sl = simplify_cost(l.clone()); + let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sr, + CostExpr::CostConst { value: 1, .. } => sr.clone(), _ => match (*sr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sl, + CostExpr::CostConst { value: 1, .. } => sl.clone(), _ => Rc::new(CostExpr::CostMul { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7775,29 +7826,29 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostMax { left: l, right: r, .. } => { - let sl = simplify_cost(l); - let sr = simplify_cost(r); + let sl = simplify_cost(l.clone()); + let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr, + CostExpr::CostConst { value: 0, .. } => sr.clone(), CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), CostExpr::CostConst { value: b, .. } => { - if (a > b) { - sl + if (a.clone() > b.clone()) { + sl.clone() } else { - sr + sr.clone() } } _ => Rc::new(CostExpr::CostMax { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), _ => Rc::new(CostExpr::CostMax { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7809,15 +7860,15 @@ pub fn simplify_cost(expr: Rc) -> Rc { body: bd, .. } => { - let sbd = simplify_cost(bd); + let sbd = simplify_cost(bd.clone()); match (*sbd.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } _ => Rc::new(CostExpr::CostSum { - binder: b, - upper: u, - body: sbd, + binder: b.clone(), + upper: u.clone(), + body: sbd.clone(), }), } } @@ -7826,11 +7877,11 @@ pub fn simplify_cost(expr: Rc) -> Rc { argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b, - argument: a, + base: b.clone(), + argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -7838,25 +7889,25 @@ pub fn simplify_cost(expr: Rc) -> Rc { pub fn format_size(size: Rc) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - v1_rt::concat(v1_rt::concat("|".to_string(), c), "|".to_string()) + v1_rt::concat(v1_rt::concat("|".to_string(), c.clone()), "|".to_string()) } - SizeExpr::SizeVar { name: n, .. } => n, - SizeExpr::SizeConst { value: v, .. } => (v).to_string(), + SizeExpr::SizeVar { name: n, .. } => n.clone(), + SizeExpr::SizeConst { value: v, .. } => (v.clone()).to_string(), SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( - v1_rt::concat(format_size(l), " + ".to_string()), - format_size(r), + v1_rt::concat(format_size(l.clone()), " + ".to_string()), + format_size(r.clone()), ), SizeExpr::SizeMax { left: l, right: r, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("max(".to_string(), format_size(l)), + v1_rt::concat("max(".to_string(), format_size(l.clone())), ", ".to_string(), ), - format_size(r), + format_size(r.clone()), ), ")".to_string(), ), @@ -7867,7 +7918,7 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { CostExpr::CostConst { value: v, .. } => { - if (v <= 0) { + if (v.clone() <= 0) { Rc::new(CostExpr::CostConst { value: 0 }) } else { Rc::new(CostExpr::CostConst { value: 1 }) @@ -7876,26 +7927,26 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostAdd { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l); - let nr = normalize_asymptotic(r); + let nl = normalize_asymptotic(l.clone()); + let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl + nl.clone() } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr, + CostExpr::CostConst { value: 0, .. } => nr.clone(), CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr, + _ => nr.clone(), }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostAdd { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7904,26 +7955,26 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostMax { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l); - let nr = normalize_asymptotic(r); + let nl = normalize_asymptotic(l.clone()); + let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl + nl.clone() } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr, + CostExpr::CostConst { value: 0, .. } => nr.clone(), CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr, + _ => nr.clone(), }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostMax { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7932,21 +7983,21 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostMul { left: l, right: r, .. } => { - let nl = normalize_asymptotic(l); - let nr = normalize_asymptotic(r); + let nl = normalize_asymptotic(l.clone()); + let nr = normalize_asymptotic(r.clone()); match (*nl.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nr, + CostExpr::CostConst { value: _, .. } => nr.clone(), _ => match (*nr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostMul { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7957,17 +8008,17 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { body: bd, .. } => { - let nbd = normalize_asymptotic(bd); + let nbd = normalize_asymptotic(bd.clone()); match (*nbd.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } _ => match (*u.clone()).clone() { - SizeExpr::SizeConst { value: _, .. } => nbd, + SizeExpr::SizeConst { value: _, .. } => nbd.clone(), _ => Rc::new(CostExpr::CostSum { - binder: b, - upper: u, - body: nbd, + binder: b.clone(), + upper: u.clone(), + body: nbd.clone(), }), }, } @@ -7977,11 +8028,11 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b, - argument: a, + base: b.clone(), + argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -7989,24 +8040,25 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { pub fn format_cost_class(expr: Rc) -> String { match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "O(1)".to_string(), - CostExpr::CostExtern { name: n, .. } => { - v1_rt::concat(v1_rt::concat("O(extern(".to_string(), n), "))".to_string()) - } + CostExpr::CostExtern { name: n, .. } => v1_rt::concat( + v1_rt::concat("O(extern(".to_string(), n.clone()), + "))".to_string(), + ), CostExpr::CostUnknown { reason: _, .. } => "O(?)".to_string(), CostExpr::CostSum { upper: u, body: bd, .. } => match (*bd.clone()).clone() { CostExpr::CostConst { value: _, .. } => v1_rt::concat( - v1_rt::concat("O(".to_string(), format_size(u)), + v1_rt::concat("O(".to_string(), format_size(u.clone())), ")".to_string(), ), _ => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), format_size(u)), + v1_rt::concat("O(".to_string(), format_size(u.clone())), " * ".to_string(), ), - format_cost_inner(bd), + format_cost_inner(bd.clone()), ), ")".to_string(), ), @@ -8016,10 +8068,10 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), format_cost_inner(l)), + v1_rt::concat("O(".to_string(), format_cost_inner(l.clone())), " + ".to_string(), ), - format_cost_inner(r), + format_cost_inner(r.clone()), ), ")".to_string(), ), @@ -8028,10 +8080,10 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(".to_string(), parenthesize_additive_cost(l)), + v1_rt::concat("O(".to_string(), parenthesize_additive_cost(l.clone())), " * ".to_string(), ), - parenthesize_additive_cost(r), + parenthesize_additive_cost(r.clone()), ), ")".to_string(), ), @@ -8040,15 +8092,15 @@ pub fn format_cost_class(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("O(max(".to_string(), format_cost_inner(l)), + v1_rt::concat("O(max(".to_string(), format_cost_inner(l.clone())), ", ".to_string(), ), - format_cost_inner(r), + format_cost_inner(r.clone()), ), "))".to_string(), ), CostExpr::CostLog { argument: a, .. } => v1_rt::concat( - v1_rt::concat("O(log ".to_string(), format_size(a)), + v1_rt::concat("O(log ".to_string(), format_size(a.clone())), ")".to_string(), ), } @@ -8060,34 +8112,34 @@ pub fn format_cost_inner(expr: Rc) -> String { CostExpr::CostSum { upper: u, body: bd, .. } => match (*bd.clone()).clone() { - CostExpr::CostConst { value: _, .. } => format_size(u), + CostExpr::CostConst { value: _, .. } => format_size(u.clone()), _ => v1_rt::concat( - v1_rt::concat(format_size(u), " * ".to_string()), - format_cost_inner(bd), + v1_rt::concat(format_size(u.clone()), " * ".to_string()), + format_cost_inner(bd.clone()), ), }, CostExpr::CostAdd { left: l, right: r, .. } => v1_rt::concat( - v1_rt::concat(format_cost_inner(l), " + ".to_string()), - format_cost_inner(r), + v1_rt::concat(format_cost_inner(l.clone()), " + ".to_string()), + format_cost_inner(r.clone()), ), CostExpr::CostMul { left: l, right: r, .. } => { let left_str = match (*l.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( - v1_rt::concat("(".to_string(), format_cost_inner(l)), + v1_rt::concat("(".to_string(), format_cost_inner(l.clone())), ")".to_string(), ), - _ => format_cost_inner(l), + _ => format_cost_inner(l.clone()), }; let right_str = match (*r.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( - v1_rt::concat("(".to_string(), format_cost_inner(r)), + v1_rt::concat("(".to_string(), format_cost_inner(r.clone())), ")".to_string(), ), - _ => format_cost_inner(r), + _ => format_cost_inner(r.clone()), }; v1_rt::concat(v1_rt::concat(left_str, " * ".to_string()), right_str) } @@ -8096,17 +8148,20 @@ pub fn format_cost_inner(expr: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("max(".to_string(), format_cost_inner(l)), + v1_rt::concat("max(".to_string(), format_cost_inner(l.clone())), ", ".to_string(), ), - format_cost_inner(r), + format_cost_inner(r.clone()), ), ")".to_string(), ), - CostExpr::CostLog { argument: a, .. } => v1_rt::concat("log ".to_string(), format_size(a)), - CostExpr::CostExtern { name: n, .. } => { - v1_rt::concat(v1_rt::concat("extern(".to_string(), n), ")".to_string()) + CostExpr::CostLog { argument: a, .. } => { + v1_rt::concat("log ".to_string(), format_size(a.clone())) } + CostExpr::CostExtern { name: n, .. } => v1_rt::concat( + v1_rt::concat("extern(".to_string(), n.clone()), + ")".to_string(), + ), CostExpr::CostUnknown { reason: _, .. } => "?".to_string(), }) } @@ -8184,11 +8239,11 @@ pub fn build_legend(size_names: Rc>) -> Rc { }) } else { if ((unique.clone().len() as i64) == 1) { - match unique.first().cloned() { + match unique.clone().first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( v1_rt::rc_empty_map::(), - name, + name.clone(), "n".to_string(), ), suffix: "".to_string(), @@ -8200,7 +8255,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { } } else { { - let indexed = unique.iter().cloned().fold( + let indexed = unique.clone().iter().cloned().fold( Rc::new(Legend { substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), @@ -8248,27 +8303,31 @@ pub fn build_legend(size_names: Rc>) -> Rc { pub fn substitute_size(size: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*size.clone()).clone() { - SizeExpr::SizeLen { collection: c, .. } => match v1_rt::map_get(&legend, c) { - Some(short) => Rc::new(SizeExpr::SizeVar { name: short }), - None => size, + SizeExpr::SizeLen { collection: c, .. } => match v1_rt::map_get(&legend, c.clone()) { + Some(short) => Rc::new(SizeExpr::SizeVar { + name: short.clone(), + }), + None => size.clone(), }, - SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n) { - Some(short) => Rc::new(SizeExpr::SizeVar { name: short }), - None => size, + SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n.clone()) { + Some(short) => Rc::new(SizeExpr::SizeVar { + name: short.clone(), + }), + None => size.clone(), }, SizeExpr::SizeAdd { left: l, right: r, .. } => Rc::new(SizeExpr::SizeAdd { - left: substitute_size(l, legend.clone()), - right: substitute_size(r, legend.clone()), + left: substitute_size(l.clone(), legend.clone()), + right: substitute_size(r.clone(), legend.clone()), }), SizeExpr::SizeMax { left: l, right: r, .. } => Rc::new(SizeExpr::SizeMax { - left: substitute_size(l, legend.clone()), - right: substitute_size(r, legend.clone()), + left: substitute_size(l.clone(), legend.clone()), + right: substitute_size(r.clone(), legend.clone()), }), - SizeExpr::SizeConst { value: _, .. } => size, + SizeExpr::SizeConst { value: _, .. } => size.clone(), } }) } @@ -8276,24 +8335,24 @@ pub fn substitute_size(size: Rc, legend: Rc>) pub fn substitute_cost(expr: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr, + CostExpr::CostConst { value: _, .. } => expr.clone(), CostExpr::CostAdd { left: l, right: r, .. } => Rc::new(CostExpr::CostAdd { - left: substitute_cost(l, legend.clone()), - right: substitute_cost(r, legend.clone()), + left: substitute_cost(l.clone(), legend.clone()), + right: substitute_cost(r.clone(), legend.clone()), }), CostExpr::CostMul { left: l, right: r, .. } => Rc::new(CostExpr::CostMul { - left: substitute_cost(l, legend.clone()), - right: substitute_cost(r, legend.clone()), + left: substitute_cost(l.clone(), legend.clone()), + right: substitute_cost(r.clone(), legend.clone()), }), CostExpr::CostMax { left: l, right: r, .. } => Rc::new(CostExpr::CostMax { - left: substitute_cost(l, legend.clone()), - right: substitute_cost(r, legend.clone()), + left: substitute_cost(l.clone(), legend.clone()), + right: substitute_cost(r.clone(), legend.clone()), }), CostExpr::CostSum { binder: b, @@ -8301,20 +8360,20 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) body: bd, .. } => Rc::new(CostExpr::CostSum { - binder: b, - upper: substitute_size(u, legend.clone()), - body: substitute_cost(bd, legend.clone()), + binder: b.clone(), + upper: substitute_size(u.clone(), legend.clone()), + body: substitute_cost(bd.clone(), legend.clone()), }), CostExpr::CostLog { base: b, argument: a, .. } => Rc::new(CostExpr::CostLog { - base: b, - argument: substitute_size(a, legend.clone()), + base: b.clone(), + argument: substitute_size(a.clone(), legend.clone()), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -8324,7 +8383,7 @@ pub fn classify_complexity(expr: Rc) -> String { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); let legend = build_legend(size_names); - let substituted = substitute_cost(normalized, legend.substitution.clone()); + let substituted = substitute_cost(normalized.clone(), legend.substitution.clone()); v1_rt::concat(format_cost_class(substituted), legend.suffix.clone()) } } @@ -8335,27 +8394,27 @@ pub fn collect_size_vars_from_size(size: Rc) -> Rc> { if (c.clone() == "__expr".to_string()) { Rc::new(vec![]) } else { - Rc::new(vec![c]) + Rc::new(vec![c.clone()]) } } SizeExpr::SizeVar { name: n, .. } => { if (n.clone() == "__k".to_string()) { Rc::new(vec![]) } else { - Rc::new(vec![n]) + Rc::new(vec![n.clone()]) } } SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( - collect_size_vars_from_size(l), - collect_size_vars_from_size(r), + collect_size_vars_from_size(l.clone()), + collect_size_vars_from_size(r.clone()), ), SizeExpr::SizeMax { left: l, right: r, .. } => v1_rt::concat( - collect_size_vars_from_size(l), - collect_size_vars_from_size(r), + collect_size_vars_from_size(l.clone()), + collect_size_vars_from_size(r.clone()), ), _ => Rc::new(vec![]), }) @@ -8365,17 +8424,20 @@ pub fn collect_size_vars(expr: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*expr).clone() { CostExpr::CostSum { upper: u, body: bd, .. - } => v1_rt::concat(collect_size_vars_from_size(u), collect_size_vars(bd)), + } => v1_rt::concat( + collect_size_vars_from_size(u.clone()), + collect_size_vars(bd.clone()), + ), CostExpr::CostAdd { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), + } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), CostExpr::CostMul { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), + } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), CostExpr::CostMax { left: l, right: r, .. - } => v1_rt::concat(collect_size_vars(l), collect_size_vars(r)), - CostExpr::CostLog { argument: a, .. } => collect_size_vars_from_size(a), + } => v1_rt::concat(collect_size_vars(l.clone()), collect_size_vars(r.clone())), + CostExpr::CostLog { argument: a, .. } => collect_size_vars_from_size(a.clone()), _ => Rc::new(vec![]), }) } @@ -8526,7 +8588,7 @@ pub fn cost_of_expr( let fname = expr_call_func_at(texpr.clone(), si.clone()); let callee_result = match v1_rt::map_get(&func_index, fname.clone()) { Some(entry) => get_or_compute_summary( - fname, + fname.clone(), func_index.clone(), scc_index.clone(), table, @@ -8566,11 +8628,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8583,11 +8645,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*args_result.summary.clone().work).clone(), (*callee_result.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*args_result.summary.clone().span).clone(), (*callee_result.summary.clone().span).clone(), ), @@ -8612,7 +8674,7 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(recv, si.clone()); + let size = receiver_size_var(recv.clone(), si.clone()); let binder = size_binder_name(size.clone()); let method_cost_result = if (ms.clone() == None) { None @@ -8624,13 +8686,13 @@ pub fn cost_of_expr( .. } => { let pc = node_is_collection(resolved_type(texpr.clone()), si.clone()); - match cs { + match cs.clone() { Some(shape) => Some(cost_of_method_by_shape( - shape, + shape.clone(), pc, recv_r.clone(), mc_args.clone(), - size, + size.clone(), binder, func_index.clone(), scc_index.clone(), @@ -8659,9 +8721,9 @@ pub fn cost_of_expr( } }; match method_cost_result { - Some(result) => result, + Some(result) => result.clone(), _ => { - let args_result = mc_args.iter().cloned().fold( + let args_result = mc_args.clone().iter().cloned().fold( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), @@ -8683,11 +8745,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8760,11 +8822,11 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( (*(*acc.result).clone().summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( (*(*acc.result).clone().summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8812,7 +8874,7 @@ pub fn cost_of_expr( let c = if_condition(texpr.clone()); let t = if_then_branch(texpr.clone()); let c_r = cost_of_expr( - c, + c.clone(), func_index.clone(), scc_index.clone(), table, @@ -8832,7 +8894,7 @@ pub fn cost_of_expr( let e_result = match if_else_branch(texpr.clone()) { Some(eb) => { let er = cost_of_expr( - eb, + eb.clone(), func_index.clone(), scc_index.clone(), t_r.table.clone(), @@ -8891,7 +8953,7 @@ pub fn cost_of_expr( match let_body(texpr.clone()) { Some(b) => { let b_r = cost_of_expr( - b, + b.clone(), func_index.clone(), scc_index.clone(), v_r.table.clone(), @@ -8901,11 +8963,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*v_r.summary.clone().work).clone(), (*b_r.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*v_r.summary.clone().span).clone(), (*b_r.summary.clone().span).clone(), ), @@ -8915,7 +8977,7 @@ pub fn cost_of_expr( table: b_r.table.clone(), }) } - None => v_r, + None => v_r.clone(), } } ExprData::ExprBlock => texpr.children.clone().iter().cloned().fold( @@ -8940,11 +9002,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*sr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*sr.summary.clone().span).clone(), ), @@ -8976,13 +9038,14 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(c, si.clone()); + let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size, bd_r.summary.clone().work.clone()); + let loop_work = + cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), @@ -9011,11 +9074,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), @@ -9048,11 +9111,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), @@ -9095,7 +9158,7 @@ pub fn get_or_compute_summary( ) -> Rc { match lookup_summary(table.clone(), func_name.clone()) { Some(cached) => Rc::new(SummaryResult { - summary: cached, + summary: cached.clone(), table: table.clone(), }), None => match v1_rt::map_get(&func_index, func_name.clone()) { @@ -9130,7 +9193,7 @@ pub fn get_or_compute_summary( None => Rc::new(vec![]), }; let is_scc = ((scc_members.clone().len() as i64) > 1); - let bounded = match target { + let bounded = match target.clone() { Some(t) => { if is_scc { Rc::new(ComplexitySummary { @@ -9140,9 +9203,9 @@ pub fn get_or_compute_summary( scc_members.clone(), ), span: bounded_scc_cost( - t, + t.clone(), result.summary.clone().span.clone(), - scc_members, + scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), certainty: Certainty::Conservative, @@ -9155,7 +9218,7 @@ pub fn get_or_compute_summary( func_name.clone(), ), span: bounded_recursive_cost( - t, + t.clone(), result.summary.clone().span.clone(), func_name.clone(), ), @@ -9178,7 +9241,7 @@ pub fn get_or_compute_summary( simplified.clone(), ); Rc::new(SummaryResult { - summary: simplified, + summary: simplified.clone(), table: final_table, }) } @@ -9243,8 +9306,8 @@ pub fn collect_call_evidence( } => { let callee = expr_call_func_at(body.clone(), si.clone()); let own = if (v1_rt::map_get(&target_set, callee) != None) { - match de { - Some(evidence) => Rc::new(vec![evidence]), + match de.clone() { + Some(evidence) => Rc::new(vec![evidence.clone()]), None => Rc::new(vec![]), } } else { @@ -9402,17 +9465,18 @@ pub fn max_path_descending( } => { let callee = expr_call_func_at(body.clone(), si.clone()); let own = if (callee == fn_name.clone()) { - match de { - Some(evidence) => match evidence.get(param_index.clone() as usize).cloned() - { - Some(rel) => match (*rel).clone() { - SubValueRelation::StrictSubValue { .. } => 1, - SubValueRelation::IteratedSubValue { field: _, .. } => 1, - SubValueRelation::ArithmeticDescent { .. } => 1, - _ => 0, - }, - None => 0, - }, + match de.clone() { + Some(evidence) => { + match evidence.clone().get(param_index.clone() as usize).cloned() { + Some(rel) => match (*rel.clone()).clone() { + SubValueRelation::StrictSubValue { .. } => 1, + SubValueRelation::IteratedSubValue { field: _, .. } => 1, + SubValueRelation::ArithmeticDescent { .. } => 1, + _ => 0, + }, + None => 0, + } + } None => 0, } } else { @@ -9448,15 +9512,18 @@ pub fn max_path_descending( ); let else_branch = if_else_branch(body.clone()); let else_count = match else_branch { - Some(eb) => { - max_path_descending(eb, fn_name.clone(), param_index.clone(), si.clone()) - } + Some(eb) => max_path_descending( + eb.clone(), + fn_name.clone(), + param_index.clone(), + si.clone(), + ), None => 0, }; let branch_max = if (then_count.clone() > else_count.clone()) { - then_count + then_count.clone() } else { - else_count + else_count.clone() }; (cond_count + branch_max) } @@ -9828,7 +9895,7 @@ pub fn build_complexity_report( None => acc.clone(), }, ); - let structural_bounds = analyze_structural_bounds(func_entries.clone(), si); + let structural_bounds = analyze_structural_bounds(func_entries.clone(), si.clone()); Rc::new(ComplexityReport { function_classes: result.classes.clone(), violations: result.violations.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 899380ce5c6..0f289bbabe9 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -294,8 +294,8 @@ pub fn emit_simple_expr( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => emit_literal(v, target.clone()), - ExprData::ExprError { message, .. } => emit_error_expr(message, target.clone()), + ExprData::ExprLiteral { value: v, .. } => emit_literal(v.clone(), target.clone()), + ExprData::ExprError { message, .. } => emit_error_expr(message.clone(), target.clone()), ExprData::ExprVar { binding_kind: _, .. } => emit_ident( @@ -307,13 +307,13 @@ pub fn emit_simple_expr( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { - Some(svc_name) => service_var_name(svc_name), + Some(svc_name) => service_var_name(svc_name.clone()), None => v1_rt::concat( v1_rt::concat( - emit_simple_expr(b, target.clone(), source_indices.clone()), + emit_simple_expr(b.clone(), target.clone(), source_indices.clone()), ".".to_string(), ), - emit_ident(f, target.clone()), + emit_ident(f.clone(), target.clone()), ), } } else { @@ -321,7 +321,7 @@ pub fn emit_simple_expr( let base_is_fn = match (*b.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. - } => match bk.as_deref().cloned() { + } => match bk.clone().as_deref().cloned() { Some(VarBindingKind::MatchBoundBinding) => false, Some(VarBindingKind::VariantValueBinding { parent_enum: _, @@ -331,7 +331,8 @@ pub fn emit_simple_expr( }, _ => false, }; - let base_str = emit_simple_expr(b, target.clone(), source_indices.clone()); + let base_str = + emit_simple_expr(b.clone(), target.clone(), source_indices.clone()); let base_call = if base_is_fn.clone() { v1_rt::concat(base_str, "()".to_string()) } else { @@ -339,9 +340,9 @@ pub fn emit_simple_expr( }; let field_str = v1_rt::concat( v1_rt::concat(base_call, ".".to_string()), - emit_ident(f, target.clone()), + emit_ident(f.clone(), target.clone()), ); - let needs_clone = (base_is_fn + let needs_clone = (base_is_fn.clone() && match target.clone() { RenderTarget::Rust => true, _ => false, @@ -505,7 +506,7 @@ pub fn emit_simple_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.iter().cloned() { + for p in fmt_parts.clone().iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -523,7 +524,7 @@ pub fn emit_simple_string_interp( apply_type_template1(interp.plain_template.clone(), fmt_str) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); apply_type_template2(interp.format_template.clone(), fmt_str, args_str) } } @@ -769,12 +770,12 @@ pub fn has_nested_records_node( loop { let is_product = (n.connective.clone() == Connective::Conj); let is_coproduct = (n.connective.clone() == Connective::Disj); - if is_product.clone() { + if is_product { break true; } else { - if is_coproduct.clone() { + if is_coproduct { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional.clone() { + if is_optional { { let __tco_0 = with_required_cardinality(n); n = __tco_0; @@ -785,7 +786,7 @@ pub fn has_nested_records_node( } } else { let is_map = node_is_keyed_collection(n.clone(), source_indices.clone()); - if is_map.clone() { + if is_map { match n.children.clone().get(1 as usize).cloned() { Some(val_child) => { let __tco_0 = child_type_node(val_child.clone()); @@ -823,19 +824,19 @@ pub fn emit_data_value_json( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*value.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitStr { value: s, .. } => v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_json_string(s)), + v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), "\"".to_string(), ), LiteralValue::LitSymbol { value: s, .. } => v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_json_string(s)), + v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), "\"".to_string(), ), - LiteralValue::LitInt { value: i, .. } => (i).to_string(), - LiteralValue::LitFloat { value: f, .. } => f, + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { - if b { + if b.clone() { "true".to_string() } else { "false".to_string() @@ -889,7 +890,7 @@ pub fn emit_data_value_json( } => v1_rt::concat( v1_rt::concat( "\"".to_string(), - escape_json_string(expr_var_name_at(value.clone(), source_indices)), + escape_json_string(expr_var_name_at(value.clone(), source_indices.clone())), ), "\"".to_string(), ), @@ -898,7 +899,7 @@ pub fn emit_data_value_json( .. } => v1_rt::concat( "-".to_string(), - emit_data_value_json(unaryop_operand(value.clone()), source_indices), + emit_data_value_json(unaryop_operand(value.clone()), source_indices.clone()), ), _ => "\"compile_error!(unsupported mock expression)\"".to_string(), } @@ -914,13 +915,13 @@ pub fn to_camel(name: String) -> String { .collect::>(), ); if ((parts.clone().len() as i64) == 0) { - name + name.clone() } else { { let first_part = match parts.clone().first().cloned() { Some(p) => Rc::new({ let mut __result = Vec::new(); - for c in Rc::new(p.chars().map(|c| c as i64).collect::>()) + for c in Rc::new(p.clone().chars().map(|c| c as i64).collect::>()) .iter() .cloned() { @@ -937,6 +938,7 @@ pub fn to_camel(name: String) -> String { let mut __result = Vec::new(); for pair in Rc::new( parts + .clone() .iter() .cloned() .enumerate() @@ -992,7 +994,7 @@ pub fn test_file_path(module_name: String, target: RenderTarget) -> String { { let conventions = test_conventions_for_target(target.clone()); let file_dir = match conventions.file_dir.clone() { - Some(dir) => dir, + Some(dir) => dir.clone(), None => "".to_string(), }; let filename = module_to_filename(module_name); @@ -1021,7 +1023,7 @@ pub fn reserved_prefix(target: RenderTarget) -> String { .clone()) .clone() { - ReservedWordStrategy::PrefixEscape { prefix: prefix, .. } => prefix, + ReservedWordStrategy::PrefixEscape { prefix: prefix, .. } => prefix.clone(), _ => "".to_string(), } } @@ -1034,7 +1036,7 @@ pub fn reserved_suffix(target: RenderTarget) -> String { .clone()) .clone() { - ReservedWordStrategy::SuffixEscape { suffix: suffix, .. } => suffix, + ReservedWordStrategy::SuffixEscape { suffix: suffix, .. } => suffix.clone(), _ => "".to_string(), } } @@ -1091,7 +1093,7 @@ pub fn apply_escape_pairs(s: String, pairs: Rc>>) -> String { pairs .iter() .cloned() - .fold(s, |acc: String, pair: Rc| { + .fold(s.clone(), |acc: String, pair: Rc| { Rc::new( acc.split(&pair.from.clone()) .map(|s| s.to_string()) @@ -1120,14 +1122,14 @@ pub fn is_null_coalesce(op: BinOp) -> bool { pub fn rust_literal_for_pattern(value: Rc) -> String { match (*value).clone() { - LiteralValue::LitStr { value: s, .. } => emit_string_literal(s, "".to_string()), + LiteralValue::LitStr { value: s, .. } => emit_string_literal(s.clone(), "".to_string()), LiteralValue::LitSymbol { value: s, .. } => { - emit_string_literal(s, ".to_string()".to_string()) + emit_string_literal(s.clone(), ".to_string()".to_string()) } - LiteralValue::LitInt { value: i, .. } => (i).to_string(), - LiteralValue::LitFloat { value: f, .. } => f, + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { - if b { + if b.clone() { emit_keyword("true".to_string(), RenderTarget::Rust) } else { emit_keyword("false".to_string(), RenderTarget::Rust) @@ -1145,18 +1147,18 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> String { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "String".to_string()) { - Some(sfx) => sfx, + Some(sfx) => sfx.clone(), None => emit_error_expr( "missing TypeCheckpoint for String literal suffix".to_string(), target.clone(), ), }; - emit_string_literal(s, suffix) + emit_string_literal(s.clone(), suffix) } - LiteralValue::LitInt { value: i, .. } => (i).to_string(), - LiteralValue::LitFloat { value: f, .. } => f, + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { - if b { + if b.clone() { emit_keyword("true".to_string(), target.clone()) } else { emit_keyword("false".to_string(), target.clone()) @@ -1165,16 +1167,16 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> String { LiteralValue::LitNull => emit_keyword("null".to_string(), target.clone()), LiteralValue::LitSymbol { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "Symbol".to_string()) { - Some(sfx) => sfx, + Some(sfx) => sfx.clone(), None => match literal_suffix(target.clone(), "String".to_string()) { - Some(sfx) => sfx, + Some(sfx) => sfx.clone(), None => emit_error_expr( "missing TypeCheckpoint for Symbol literal suffix".to_string(), target.clone(), ), }, }; - emit_string_literal(s, suffix) + emit_string_literal(s.clone(), suffix) } } } @@ -1185,7 +1187,7 @@ pub fn emit_bin_op_symbol( algebra_field: Option, ) -> String { match binop_symbol(target.clone(), op, algebra_field) { - Some(sym) => sym, + Some(sym) => sym.clone(), None => emit_error_expr( "missing OperatorSpec for BinOp in target language".to_string(), target.clone(), @@ -1198,7 +1200,7 @@ pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> Stri apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { - Some(template) => apply_type_template1(template, inner), + Some(template) => apply_type_template1(template.clone(), inner), None => { let spec = language_spec(target.clone()); v1_rt::concat( @@ -1215,7 +1217,7 @@ pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> Stri pub fn emit_map_type(key_type: String, val_type: String, target: RenderTarget) -> String { match coerce_container_template(target, "map".to_string()) { - Some(template) => apply_type_template2(template, key_type, val_type), + Some(template) => apply_type_template2(template.clone(), key_type, val_type), None => v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1239,8 +1241,8 @@ pub fn emit_node_type( pub fn named_type_vars_in_inferred(inferred: Option>) -> Rc> { match inferred.as_deref().cloned() { - Some(InferredNode::TypeVariable { id: var_id, .. }) => Rc::new(vec![var_id]), - Some(InferredNode::Resolved { node: rt, .. }) => named_type_vars_in_node(rt), + Some(InferredNode::TypeVariable { id: var_id, .. }) => Rc::new(vec![var_id.clone()]), + Some(InferredNode::Resolved { node: rt, .. }) => named_type_vars_in_node(rt.clone()), _ => Rc::new(vec![]), } } @@ -1298,7 +1300,7 @@ pub fn render_named_type_base( } else { Rc::new(vec![]) }; - let param_names = v1_rt::concat(explicit_params, inferred_params); + let param_names = v1_rt::concat(explicit_params.clone(), inferred_params); if ((param_names.clone().len() as i64) == 0) { base } else { @@ -1307,7 +1309,7 @@ pub fn render_named_type_base( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, spec.type_arg_open.clone()), - param_names.join(&", ".to_string()), + param_names.clone().join(&", ".to_string()), ), spec.type_arg_close.clone(), ) @@ -1340,14 +1342,14 @@ pub fn render_node_type( { let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((tn.clone() != "".to_string()) && (tn.clone() == var_id)) + ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) } _ => false, }; - if (n_is_type_var && is_named_type_var) { + if (n_is_type_var.clone() && is_named_type_var) { return coerce_primitive_type(target.clone(), tn.clone()); } - let label = if n_is_error { + let label = if n_is_error.clone() { "CompilerError".to_string() } else { "TypeVariable".to_string() @@ -1379,7 +1381,7 @@ pub fn render_node_type( let param_str = param_strs.clone().join(&repr.param_separator.clone()); let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_node_type( - rt, + rt.clone(), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1389,9 +1391,9 @@ pub fn render_node_type( let spec = language_spec(target.clone()); let result = match spec.callable_type_template.clone() { Some(t) => v1_rt::replace( - v1_rt::replace(t, "{params}".to_string(), param_str), + v1_rt::replace(t.clone(), "{params}".to_string(), param_str), "{return}".to_string(), - ret_str, + ret_str.clone(), ), None => { if (ret_str.clone() == "".to_string()) { @@ -1414,7 +1416,7 @@ pub fn render_node_type( param_str, ), "{return}".to_string(), - ret_str, + ret_str.clone(), ) } } @@ -1539,7 +1541,7 @@ pub fn render_node_type( let base = if (snake.clone() == "map".to_string()) { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { - emit_container(snake, "_".to_string(), target.clone()) + emit_container(snake.clone(), "_".to_string(), target.clone()) }; let conj_container_str = if shared.clone() { wrap_shared_type(target.clone(), base.clone()) @@ -1590,7 +1592,7 @@ pub fn render_node_type( None => false, }; let param_count = (n.params.clone().len() as i64); - let base = if bare_is_map { + let base = if bare_is_map.clone() { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { if bare_is_collection { @@ -1600,7 +1602,7 @@ pub fn render_node_type( { let inner = match n.params.clone().first().cloned() { Some(p) => render_node_type( - param_node_type_expr(p), + param_node_type_expr(p.clone()), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1610,7 +1612,7 @@ pub fn render_node_type( emit_container(to_snake(tn.clone()), inner, target.clone()) } } else { - if (param_count > 0) { + if (param_count.clone() > 0) { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1631,7 +1633,7 @@ pub fn render_node_type( coerce_primitive_type(target.clone(), tn.clone()), spec.type_arg_open.clone(), ), - param_strs.join(&", ".to_string()), + param_strs.clone().join(&", ".to_string()), ), spec.type_arg_close.clone(), ) @@ -1659,7 +1661,7 @@ pub fn render_node_type( { let k = match n.children.clone().first().cloned() { Some(kn) => render_node_type( - child_type_node(kn), + child_type_node(kn.clone()), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1668,7 +1670,7 @@ pub fn render_node_type( }; let v = match n.children.clone().get(1 as usize).cloned() { Some(vn) => render_node_type( - child_type_node(vn), + child_type_node(vn.clone()), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1688,7 +1690,7 @@ pub fn render_node_type( { let child_str = match n.children.clone().first().cloned() { Some(child) => render_node_type( - child_type_node(child), + child_type_node(child.clone()), target.clone(), shared_types.clone(), source_indices.clone(), @@ -1737,20 +1739,20 @@ pub fn render_node_type( return multi_tuple_str; } } - let type_base = coerce_primitive_type(target.clone(), tn); - let args_joined = child_strs.join(&", ".to_string()); + let type_base = coerce_primitive_type(target.clone(), tn.clone()); + let args_joined = child_strs.clone().join(&", ".to_string()); let spec = language_spec(target.clone()); let base = v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_base, spec.type_arg_open.clone()), + v1_rt::concat(type_base.clone(), spec.type_arg_open.clone()), args_joined, ), spec.type_arg_close.clone(), ); - if shared { - wrap_shared_type(target.clone(), base) + if shared.clone() { + wrap_shared_type(target.clone(), base.clone()) } else { - base + base.clone() } }) } @@ -1763,7 +1765,9 @@ pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> Strin if ((parts.clone().len() as i64) == 2) { match parts.clone().first().cloned() { Some(p0) => match parts.clone().get(1 as usize).cloned() { - Some(p1) => apply_type_template2(ts.pair_template.clone(), p0, p1), + Some(p1) => { + apply_type_template2(ts.pair_template.clone(), p0.clone(), p1.clone()) + } None => apply_type_template1( ts.multi_template.clone(), parts.clone().join(&ts.separator.clone()), @@ -1818,7 +1822,7 @@ pub fn service_fallback_transport(item: Rc) -> Rc { pub fn effective_operation_transport(op_node: Rc, fallback: Rc) -> Rc { match op_node.transport.clone() { - Some(op_transport) => op_transport, + Some(op_transport) => op_transport.clone(), None => fallback, } } @@ -2014,7 +2018,7 @@ pub fn service_field_decls(fs: ServiceFieldSet, t: Rc) -> } else { result.clone() }; - result + result.clone() } } @@ -2041,7 +2045,7 @@ pub fn service_field_ctors(fs: ServiceFieldSet, t: Rc) -> } else { result.clone() }; - result + result.clone() } } @@ -2093,12 +2097,15 @@ pub fn emit_unified_operation_method( let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); let all_params = if (sp.clone() == "".to_string()) { - params_str + params_str.clone() } else { if (params_str.clone() == "".to_string()) { - sp + sp.clone() } else { - v1_rt::concat(v1_rt::concat(sp, ", ".to_string()), params_str) + v1_rt::concat( + v1_rt::concat(sp.clone(), ", ".to_string()), + params_str.clone(), + ) } }; let receiver_str = service_receiver_str(spec.clone(), service_name); @@ -2112,7 +2119,12 @@ pub fn emit_unified_operation_method( _ => emit_ident(op_text.clone(), target.clone()), }; let eff_transport = effective_operation_transport(op_node.clone(), fallback_transport); - let body = render_transport_body(eff_transport, op_text, si, (method_depth.clone() + 1)); + let body = render_transport_body( + eff_transport, + op_text.clone(), + si.clone(), + (method_depth.clone() + 1), + ); let sig = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -2142,7 +2154,7 @@ pub fn emit_unified_operation_method( v1_rt::concat( v1_rt::concat( v1_rt::concat(sig, spec.block_syntax.clone().block_open.clone()), - make_indent((method_depth + 1)), + make_indent((method_depth.clone() + 1)), ), body, ) @@ -2156,7 +2168,7 @@ pub fn emit_unified_operation_method( ), "\n".to_string(), ), - make_indent(method_depth), + make_indent(method_depth.clone()), ), spec.block_syntax.clone().block_close.clone(), ) @@ -2187,7 +2199,7 @@ pub fn emit_unified_service_def( ); let methods = Rc::new({ let mut __result = Vec::new(); - for op_node in op_children.iter().cloned() { + for op_node in op_children.clone().iter().cloned() { __result.push(emit_unified_operation_method( safe_name.clone(), transport.clone(), @@ -2213,7 +2225,7 @@ pub fn emit_unified_service_def( spec.items.clone().struct_keyword.clone(), " ".to_string(), ), - safe_name, + safe_name.clone(), ), ":\n".to_string(), ), @@ -2538,7 +2550,7 @@ pub fn emit_shared_tco_expr( .clone(); match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si.clone()) == fn_name.clone()) { + if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), @@ -2552,7 +2564,7 @@ pub fn emit_shared_tco_expr( let inner = return_value(frame.expr.clone()); { let __tco_0 = Rc::new(TcoFrame { - expr: inner.clone(), + expr: inner, scope: frame.scope.clone(), depth: frame.depth.clone(), }); @@ -2686,7 +2698,7 @@ pub fn shared_tco_if( match e { Some(eb) => { let else_str = - recurse_tco(eb, frame.scope.clone(), (frame.depth.clone() + 1)); + recurse_tco(eb.clone(), frame.scope.clone(), (frame.depth.clone() + 1)); if syntax.significant_whitespace.clone() { v1_rt::concat( v1_rt::concat( @@ -2811,14 +2823,14 @@ pub fn shared_tco_let( let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( frame.scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { Some(b) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), - recurse_tco(b, next_scope, frame.depth.clone()), + recurse_tco(b.clone(), next_scope, frame.depth.clone()), ), None => let_line, } @@ -2845,10 +2857,12 @@ pub fn shared_tco_block( { let init_state = emit_init_stmts(ss.clone(), frame.scope.clone(), frame.depth.clone()); - let last_str = match ss.last().cloned() { - Some(last_expr) => { - recurse_tco(last_expr, init_state.scope.clone(), frame.depth.clone()) - } + let last_str = match ss.clone().last().cloned() { + Some(last_expr) => recurse_tco( + last_expr.clone(), + init_state.scope.clone(), + frame.depth.clone(), + ), None => spec.tco.clone().break_return.clone(), }; if ((init_state.text.clone().len() as i64) == 0) { @@ -3234,12 +3248,12 @@ pub fn emit_unified_tco_match( scrut_str, arm_list, frame.depth.clone(), - fn_name, - params, + fn_name.clone(), + params.clone(), registry.clone(), frame.scope.clone(), render_pattern.clone(), - render_init_stmts, + render_init_stmts.clone(), ), _ => { let arm_strs = Rc::new({ @@ -3364,8 +3378,8 @@ pub fn emit_unified_tco_match_arm( emit_match_arm_line( arm.clone(), target.clone(), - case_depth, - body_depth, + case_depth.clone(), + body_depth.clone(), body_str, guard_str, render_pattern.clone(), @@ -3472,15 +3486,15 @@ pub fn emit_unified_typed_func_body( v1_rt::concat(prefix, emit_let_binding(n.clone(), val_str, target.clone())); let next_scope = extend_scope( scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { Some(bd) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_unified_typed_func_body( - bd, + bd.clone(), target.clone(), registry.clone(), next_scope, @@ -3508,13 +3522,13 @@ pub fn emit_unified_typed_func_body( registry.clone(), |pat| emit_unified_pattern(pat.clone(), target.clone(), si.clone()), ); - let last_stmt = ss.last().cloned(); + let last_stmt = ss.clone().last().cloned(); let last_str = match last_stmt { Some(s) => v1_rt::concat( v1_rt::concat( v1_rt::concat(prefix, "return ".to_string()), emit_unified_typed_expr( - s, + s.clone(), target.clone(), registry.clone(), init_state.scope.clone(), @@ -3617,7 +3631,9 @@ pub fn is_tco_candidate( source_indices.clone(), ); let else_cand = match if_else_branch(texpr.clone()) { - Some(e) => is_tco_candidate(e, func_name.clone(), source_indices.clone()), + Some(e) => { + is_tco_candidate(e.clone(), func_name.clone(), source_indices.clone()) + } None => false, }; (then_cand || else_cand) @@ -3637,7 +3653,7 @@ pub fn is_tco_candidate( __found } ExprData::ExprLet => match let_body(texpr.clone()) { - Some(b) => is_tco_candidate(b, func_name.clone(), source_indices.clone()), + Some(b) => is_tco_candidate(b.clone(), func_name.clone(), source_indices.clone()), None => false, }, ExprData::ExprBlock => { @@ -3797,7 +3813,7 @@ pub fn escape_emoji_codepoints_inner( }; { let __tco_0 = (pos + 1); - let __tco_1 = next_acc.clone(); + let __tco_1 = next_acc; pos = __tco_0; acc = __tco_1; continue; @@ -3851,22 +3867,24 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { }; if is_reserved { match (*spec.reserved_words.clone().strategy.clone()).clone() { - ReservedWordStrategy::PrefixEscape { prefix: p, .. } => v1_rt::concat(p, sanitized), + ReservedWordStrategy::PrefixEscape { prefix: p, .. } => { + v1_rt::concat(p.clone(), sanitized.clone()) + } ReservedWordStrategy::SuffixEscape { suffix: s, .. } => emit_suffix_escape_ident( - sanitized, - s, + sanitized.clone(), + s.clone(), spec.reserved_words.clone().keywords.clone(), ), - ReservedWordStrategy::NoEscape => sanitized, + ReservedWordStrategy::NoEscape => sanitized.clone(), } } else { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => emit_suffix_escape_ident( - sanitized, - s, + sanitized.clone(), + s.clone(), spec.reserved_words.clone().keywords.clone(), ), - _ => sanitized, + _ => sanitized.clone(), } } } @@ -3879,7 +3897,7 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { VisibilitySpec::CaseVisibility { export_case: ec, .. } => { - let result = apply_naming_case(name, ec); + let result = apply_naming_case(name, ec.clone()); let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { @@ -3894,26 +3912,26 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => { emit_suffix_escape_ident( - result, - s, + result.clone(), + s.clone(), spec.reserved_words.clone().keywords.clone(), ) } ReservedWordStrategy::PrefixEscape { prefix: p, .. } => { - v1_rt::concat(p, result) + v1_rt::concat(p.clone(), result.clone()) } - ReservedWordStrategy::NoEscape => result, + ReservedWordStrategy::NoEscape => result.clone(), } } else { match (*spec.reserved_words.clone().strategy.clone()).clone() { ReservedWordStrategy::SuffixEscape { suffix: s, .. } => { emit_suffix_escape_ident( - result, - s, + result.clone(), + s.clone(), spec.reserved_words.clone().keywords.clone(), ) } - _ => result, + _ => result.clone(), } } } @@ -3929,8 +3947,8 @@ pub fn apply_bridge_method_overrides( match v1_rt::lookup(&overrides, name.clone()) { v1_rt::Witness::Holds { value: replacement, .. - } => replacement, - v1_rt::Witness::Violates { diagnostic: _, .. } => name, + } => replacement.clone(), + v1_rt::Witness::Violates { diagnostic: _, .. } => name.clone(), } } @@ -4044,9 +4062,9 @@ pub fn emit_expr_var_shared( emit_keyword("null".to_string(), target) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n, target) + emit_keyword(n.clone(), target) } else { - emit_ident(n, target) + emit_ident(n.clone(), target) } } } @@ -4060,7 +4078,7 @@ pub fn emit_expr_field_access_shared( ) -> String { if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { - Some(svc_name) => service_var_name(svc_name), + Some(svc_name) => service_var_name(svc_name.clone()), None => emit_field(expr.clone()), } } else { @@ -4102,7 +4120,7 @@ pub fn emit_typed_cast_shared( let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); let src_ty = match expr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { - emit_node_type(n, target.clone(), source_indices.clone()) + emit_node_type(n.clone(), target.clone(), source_indices.clone()) } _ => "".to_string(), }; @@ -4110,15 +4128,15 @@ pub fn emit_typed_cast_shared( expr_str } else { if can_cast(target.clone(), src_ty.clone(), ty_str.clone()) { - render_cast(expr_str, ty_str, target.clone()) + render_cast(expr_str, ty_str.clone(), target.clone()) } else { emit_error_expr( v1_rt::concat( v1_rt::concat( - v1_rt::concat("unsupported cast from ".to_string(), src_ty), + v1_rt::concat("unsupported cast from ".to_string(), src_ty.clone()), " to ".to_string(), ), - ty_str, + ty_str.clone(), ), target.clone(), ) @@ -4218,7 +4236,7 @@ pub fn emit_typed_index_shared( let is_map = node_is_keyed_collection(base_node.clone(), source_indices.clone()); if is_string_like( target.clone(), - authored_name_at(source_indices.clone(), base_node), + authored_name_at(source_indices.clone(), base_node.clone()), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -4255,7 +4273,7 @@ pub fn emit_typed_slice_shared( let base_node = normalize_access_type_node(resolved_type(base.clone())); if is_string_like(target.clone(), authored_name_at(source_indices, base_node)) { match spec.indexing.clone().string_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( "unsupported string slice for target".to_string(), target.clone(), @@ -4263,7 +4281,7 @@ pub fn emit_typed_slice_shared( } } else { match spec.indexing.clone().list_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr("unsupported slice for target".to_string(), target.clone()), } } @@ -4293,9 +4311,11 @@ pub fn emit_shared_expr( emit_bin_op: impl Fn(Rc) -> String + Clone, ) -> String { match (*texpr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => wrap_result(emit_literal(v, target.clone())), + ExprData::ExprLiteral { value: v, .. } => { + wrap_result(emit_literal(v.clone(), target.clone())) + } ExprData::ExprError { message, .. } => { - wrap_result(emit_error_expr(message, target.clone())) + wrap_result(emit_error_expr(message.clone(), target.clone())) } ExprData::ExprVar { binding_kind: _, .. @@ -4313,14 +4333,14 @@ pub fn emit_shared_expr( ExprData::ExprBinOp { .. } => emit_bin_op(texpr.clone()), ExprData::ExprUnaryOp { op: op, .. } => { let operand = unaryop_operand(texpr.clone()); - wrap_result(emit_unary_op(op, recurse(operand), target.clone())) + wrap_result(emit_unary_op(op.clone(), recurse(operand), target.clone())) } ExprData::ExprLambda => { let body = lambda_body(texpr.clone()); let raw_body = recurse(body.clone()); let final_body = match target.clone() { RenderTarget::Go => { - if go_lambda_emits_statement_body(body) { + if go_lambda_emits_statement_body(body.clone()) { raw_body } else { v1_rt::concat("return ".to_string(), raw_body) @@ -4382,7 +4402,7 @@ pub fn emit_default_bin_op( wrap_result(emit_null_coalesce(left_str, right_str, target)) } else { { - let op_str = emit_bin_op_symbol(op, target, algebra); + let op_str = emit_bin_op_symbol(op.clone(), target, algebra.clone()); wrap_result(v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4421,16 +4441,16 @@ pub fn emit_block_stmts_shared( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } Some(stmt) => { let raw = emit_expr(stmt.clone(), scope.clone(), depth.clone()); let line = if prepend_indent.clone() { - v1_rt::concat(make_indent(depth.clone()), raw.clone()) + v1_rt::concat(make_indent(depth.clone()), raw) } else { - raw.clone() + raw }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { @@ -4441,8 +4461,8 @@ pub fn emit_block_stmts_shared( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -4465,7 +4485,7 @@ pub fn emit_init_block_stmts_shared( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -4481,22 +4501,22 @@ pub fn emit_init_block_stmts_shared( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } Some(_) => { let raw = emit_expr(stmt.clone(), scope.clone(), depth.clone()); let line = if prepend_indent.clone() { - v1_rt::concat(make_indent(depth.clone()), raw.clone()) + v1_rt::concat(make_indent(depth.clone()), raw) } else { - raw.clone() + raw }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -4530,7 +4550,7 @@ pub fn emit_typed_let_shared( ); v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), - recurse(bd, next_scope), + recurse(bd.clone(), next_scope), ) } None => let_line, @@ -4556,7 +4576,7 @@ pub fn emit_typed_if_shared( Some(eb) => match es.if_value_form.clone() { IfValueForm::IfExpression => { let then_str = recurse(then_branch.clone(), (depth.clone() + 1)); - let else_str = recurse(eb, (depth.clone() + 1)); + let else_str = recurse(eb.clone(), (depth.clone() + 1)); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4597,7 +4617,7 @@ pub fn emit_typed_if_shared( } IfValueForm::ConditionalTernary => { let then_str = recurse(then_branch.clone(), depth.clone()); - let else_str = recurse(eb, depth.clone()); + let else_str = recurse(eb.clone(), depth.clone()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4617,7 +4637,7 @@ pub fn emit_typed_if_shared( } IfValueForm::IfStatement => { let result_type = match if_result_type { - Some(rt) => emit_node_type(rt, target.clone(), source_indices), + Some(rt) => emit_node_type(rt.clone(), target.clone(), source_indices), None => emit_node_type( resolved_type(then_branch.clone()), target.clone(), @@ -4625,7 +4645,7 @@ pub fn emit_typed_if_shared( ), }; let then_str = recurse(then_branch.clone(), depth.clone()); - let else_str = recurse(eb, depth.clone()); + let else_str = recurse(eb.clone(), depth.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func() ".to_string(), result_type), " { if ".to_string()), cond_str), bs.block_open.clone()), make_indent((depth.clone() + 1))), "return ".to_string()), then_str), "\n".to_string()), make_indent(depth.clone())), bs.else_clause.clone()), make_indent((depth.clone() + 1))), "return ".to_string()), else_str), "\n".to_string()), make_indent(depth.clone())), bs.block_close.clone()), " }()".to_string()) } }, @@ -4800,7 +4820,7 @@ pub fn emit_algebra_method_template( "arg".to_string(), first_arg_str, ); - Some(apply_named_template(tmpl, bindings)) + Some(apply_named_template(tmpl.clone(), bindings)) } None => None, }, @@ -4814,7 +4834,7 @@ pub fn emit_typed_first_arg_shared( recurse: impl Fn(Rc) -> String + Clone, ) -> String { match args.first().cloned() { - Some(a) => recurse(arg_value(a)), + Some(a) => recurse(arg_value(a.clone())), None => emit_error_expr("missing method argument".to_string(), target), } } @@ -4880,7 +4900,7 @@ pub fn emit_typed_string_interp_unified( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.iter().cloned() { + for p in fmt_parts.clone().iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -4898,7 +4918,7 @@ pub fn emit_typed_string_interp_unified( apply_type_template1(interp.plain_template.clone(), fmt_str) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); apply_type_template2(interp.format_template.clone(), fmt_str, args_str) } } @@ -4986,7 +5006,7 @@ pub fn emit_typed_record_lit_unified( } Some(tn) => { if ((fields.clone().len() as i64) == 0) { - v1_rt::concat(tn, rls.named_empty.clone()) + v1_rt::concat(tn.clone(), rls.named_empty.clone()) } else { { let field_strs = Rc::new({ @@ -5010,7 +5030,10 @@ pub fn emit_typed_record_lit_unified( }); let fields_str = field_strs.join(&rls.named_field_join.clone()); v1_rt::concat( - v1_rt::concat(v1_rt::concat(tn, rls.named_open.clone()), fields_str), + v1_rt::concat( + v1_rt::concat(tn.clone(), rls.named_open.clone()), + fields_str, + ), rls.named_close.clone(), ) } @@ -5100,7 +5123,7 @@ pub fn emit_typed_call_unified( let call_str = match target.clone() { RenderTarget::Go => { if is_go_v2rt_free_function(func.clone()) { - emit_go_v2rt_free_call(func.clone(), all_args) + emit_go_v2rt_free_call(func.clone(), all_args.clone()) } else { v1_rt::concat( v1_rt::concat( @@ -5125,11 +5148,11 @@ pub fn emit_typed_call_unified( ")".to_string(), ), }; - match callee { + match callee.clone() { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects { + if has_effects.clone() { v1_rt::concat(spec.async_call_prefix.clone(), call_str) } else { call_str @@ -5166,7 +5189,7 @@ pub fn emit_algebra_method_call_unified( first_arg_str, target.clone(), ) { - Some(result) => result, + Some(result) => result.clone(), None => { let function_name = bridge_method_name_unified(method_name.clone(), target.clone()); let arg_strs = Rc::new({ @@ -5176,7 +5199,7 @@ pub fn emit_algebra_method_call_unified( } __result }); - let all_args = v1_rt::concat(Rc::new(vec![recv_str]), arg_strs); + let all_args = v1_rt::concat(Rc::new(vec![recv_str.clone()]), arg_strs); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -5248,7 +5271,7 @@ pub fn emit_typed_method_call_unified( service_name: svc_name, .. } => { - let var_name = service_var_name(svc_name); + let var_name = service_var_name(svc_name.clone()); let arg_strs = Rc::new({ let mut __result = Vec::new(); for a in args.clone().iter().cloned() { @@ -5275,7 +5298,7 @@ pub fn emit_typed_method_call_unified( ) } MethodSemantics::AlgebraMethodSemantics { method_def, .. } => { - let mn = authored_name_at(source_indices, method_def); + let mn = authored_name_at(source_indices.clone(), method_def.clone()); let first_arg_str = emit_typed_first_arg_shared(args.clone(), target.clone(), recurse.clone()); emit_algebra_method_call_unified( @@ -5297,9 +5320,9 @@ pub fn emit_typed_method_call_unified( } } else { if is_typed_service_call_receiver(receiver.clone(), source_indices.clone()) { - match extract_typed_service_name(receiver.clone(), source_indices) { + match extract_typed_service_name(receiver.clone(), source_indices.clone()) { Some(svc_name) => { - let var_name = service_var_name(svc_name); + let var_name = service_var_name(svc_name.clone()); let arg_strs = Rc::new({ let mut __result = Vec::new(); for a in args.clone().iter().cloned() { @@ -5348,21 +5371,23 @@ pub fn emit_unified_pattern( source_indices: Rc>>, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n, target), - MatchPattern::LitPattern { value: v, .. } => emit_literal(v, target), + MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), target), + MatchPattern::LitPattern { value: v, .. } => emit_literal(v.clone(), target), MatchPattern::VariantPattern { name: n, parent_enum: pe, field_bindings: fbs, .. - } => emit_unified_variant_pattern(n, pe, fbs, target, source_indices), + } => { + emit_unified_variant_pattern(n.clone(), pe.clone(), fbs.clone(), target, source_indices) + } MatchPattern::Wildcard => "_".to_string(), } } pub fn go_variant_case_type(name: String, parent_enum: Option) -> String { match parent_enum { - Some(parent) => v1_rt::concat(parent, name), + Some(parent) => v1_rt::concat(parent.clone(), name), None => name, } } @@ -5460,10 +5485,10 @@ pub fn emit_match_arm_line( let pat = arm_pattern(arm); let case_kw = match (*pat.clone()).clone() { MatchPattern::Wildcard => match es.wildcard_case.clone() { - Some(wc) => wc, - None => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat)), + Some(wc) => wc.clone(), + None => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat.clone())), }, - _ => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat)), + _ => v1_rt::concat(bs.case_keyword.clone(), render_pattern(pat.clone())), }; v1_rt::concat( v1_rt::concat( @@ -5487,7 +5512,7 @@ pub fn emit_arm_guard( let es = language_spec(target.clone()).expression_semantics.clone(); match arm_guard(arm) { Some(g) => match es.guard_prefix.clone() { - Some(prefix) => v1_rt::concat(prefix, render_guard_expr(g)), + Some(prefix) => v1_rt::concat(prefix.clone(), render_guard_expr(g.clone())), None => emit_error_expr( "target does not support pattern guards".to_string(), target.clone(), @@ -5513,7 +5538,7 @@ pub fn emit_go_match_arm_bindings( } else { Rc::new({ let mut __result = Vec::new(); - for fb in fbs.iter().cloned() { + for fb in fbs.clone().iter().cloned() { __result.push(v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -5624,7 +5649,7 @@ pub fn emit_typed_match_unified( arms, depth.clone(), recurse, - render_pattern, + render_pattern.clone(), source_indices, ), _ => { @@ -6173,7 +6198,7 @@ pub fn emit_typed_tco_reassign_shared( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for pair in pairs.iter().cloned() { + for pair in pairs.clone().iter().cloned() { __result.push(emit_ident( param_node_name_at(pair.1.clone(), source_indices.clone()), target.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 7f8694ce9af..eee7c7acd88 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -157,7 +157,6 @@ pub fn to_string_helper(mut value: i64, mut acc: Rc>) -> Rc>) -> Rc String { let cp = ch.clone(); if ((cp.clone() >= 65) && (cp.clone() <= 90)) { { - let lower_cp = (cp + 32); + let lower_cp = (cp.clone() + 32); v1_rt::from_code_point(lower_cp) } } else { @@ -266,7 +265,7 @@ pub fn to_upper_char(ch: i64) -> String { let cp = ch.clone(); if ((cp.clone() >= 97) && (cp.clone() <= 122)) { { - let upper_cp = (cp - 32); + let upper_cp = (cp.clone() - 32); v1_rt::from_code_point(upper_cp) } } else { @@ -303,6 +302,7 @@ pub fn capitalize_first(s: String) -> String { let mut __result = Vec::new(); for pair in Rc::new( chars_list + .clone() .iter() .cloned() .enumerate() @@ -493,9 +493,11 @@ pub fn apply_named_template_nested( } __result }); - processed.join(&val) + processed.join(&val.clone()) + } + None => { + v1_rt::concat("TEMPLATE_ERROR_MISSING_BINDING_".to_string(), key.clone()) } - None => v1_rt::concat("TEMPLATE_ERROR_MISSING_BINDING_".to_string(), key), } } } diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 52bba1b4908..0820f1c5113 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -182,7 +182,7 @@ pub fn emit_go_v2rt_module() -> Rc { pub fn emit_go_mod(module_name: String) -> Rc { { let manifest_path = match scaffold_for_target(RenderTarget::Go).manifest_file.clone() { - Some(path) => path, + Some(path) => path.clone(), None => "go.mod".to_string(), }; let content = v1_rt::concat( @@ -426,7 +426,7 @@ pub fn emit_go_operation_test(projection: Rc, depth: i64) -> Str ), "\n".to_string(), ), - indent, + indent.clone(), ), "// TODO: add dry-run support to Go service emission for full invocation tests\n" .to_string(), @@ -478,11 +478,15 @@ pub fn emit_go_module( ), pkg_name, ); - let imports_str = emit_go_imports(typed_module.items.clone(), module_imports(Rc::new(m)), si); + let imports_str = emit_go_imports( + typed_module.items.clone(), + module_imports(Rc::new(m.clone())), + si.clone(), + ); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), imports_str) + v1_rt::concat("\n\n".to_string(), imports_str.clone()) }; let items_str = Rc::new({ let mut __result = Vec::new(); @@ -509,7 +513,7 @@ pub fn emit_go_module( "// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string(), ), - mod_name_str, + mod_name_str.clone(), ), "\n\n".to_string(), ), @@ -529,7 +533,7 @@ pub fn emit_go_module( v1_rt::concat( v1_rt::concat( v1_rt::concat(go_emit_module_root(), "/".to_string()), - mod_dir, + mod_dir.clone(), ), "/".to_string(), ), @@ -555,9 +559,15 @@ pub fn go_package_name(module_name: String) -> String { match parts.last().cloned() { Some(last_part) => Rc::new({ let mut __result = Vec::new(); - for c in Rc::new(last_part.chars().map(|c| c as i64).collect::>()) - .iter() - .cloned() + for c in Rc::new( + last_part + .clone() + .chars() + .map(|c| c as i64) + .collect::>(), + ) + .iter() + .cloned() { __result.push(to_lower_char(c.clone())); } @@ -631,7 +641,7 @@ pub fn emit_go_imports( "".to_string() } else { { - let imports_str = all_imports.join(&"\n".to_string()); + let imports_str = all_imports.clone().join(&"\n".to_string()); v1_rt::concat( v1_rt::concat("import (\n".to_string(), imports_str), "\n)".to_string(), @@ -688,7 +698,7 @@ pub fn emit_go_typed_item( let env = (*scope.type_env).clone(); let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), Rc::new(env)) + emit_go_type_def_from_connective(item.clone(), Rc::new(env.clone())) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -733,10 +743,10 @@ pub fn emit_go_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, Rc::new(env)) + emit_go_service_def(item.clone(), registry, Rc::new(env.clone())) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), Rc::new(env)) + emit_go_resource_def(item.clone(), Rc::new(env.clone())) } else { v1_rt::concat( v1_rt::concat( @@ -864,7 +874,7 @@ pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Str v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("\t".to_string(), go_export_ident(child_text)), + v1_rt::concat("\t".to_string(), go_export_ident(child_text.clone())), " ".to_string(), ), ty, @@ -1036,7 +1046,7 @@ pub fn emit_go_variant_struct(parent_name: String, child: Rc, env: Rc, env: Rc String { VisibilitySpec::CaseVisibility { export_case: ec, .. } => { - let result = apply_naming_case(name, ec); + let result = apply_naming_case(name, ec.clone()); if { let mut __found = false; for r in go_reserved().iter().cloned() { @@ -1820,9 +1835,9 @@ pub fn go_export_ident(name: String) -> String { } __found } { - v1_rt::concat(result, go_reserved_escape_suffix()) + v1_rt::concat(result.clone(), go_reserved_escape_suffix()) } else { - result + result.clone() } } _ => "__GO_VISIBILITY_SPEC_MISMATCH__".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 68541fa3465..27fd76562e4 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -165,7 +165,7 @@ pub fn py_derive_attribute() -> String { .derive_attribute .clone() { - Some(attr) => attr, + Some(attr) => attr.clone(), None => "@dataclass".to_string(), } } @@ -175,7 +175,7 @@ pub fn py_default_value() -> String { .default_value .clone() { - Some(value) => value, + Some(value) => value.clone(), None => "None".to_string(), } } @@ -216,7 +216,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { .module_init_file .clone() { - Some(path) => path, + Some(path) => path.clone(), None => "__init__.py".to_string(), }; Rc::new(TextFile { @@ -334,7 +334,7 @@ pub fn emit_py_operation_test(projection: Rc, depth: i64) -> Str __result }) .join(&"\n".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(language_spec(RenderTarget::Python).items.clone().func_keyword.clone(), " ".to_string()), test_name), "() -> None:\n".to_string()), indent.clone()), python_test_signature_comment(projection.clone())), "\n".to_string()), indent.clone()), mock_setup), "\n".to_string()), indent.clone()), "# TODO: add dry-run support to Python service emission for full invocation tests\n".to_string()), indent), "assert True # mock data setup verified\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(language_spec(RenderTarget::Python).items.clone().func_keyword.clone(), " ".to_string()), test_name), "() -> None:\n".to_string()), indent.clone()), python_test_signature_comment(projection.clone())), "\n".to_string()), indent.clone()), mock_setup), "\n".to_string()), indent.clone()), "# TODO: add dry-run support to Python service emission for full invocation tests\n".to_string()), indent.clone()), "assert True # mock data setup verified\n".to_string()) } } @@ -369,11 +369,11 @@ pub fn emit_py_module( let si = (*scope.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(Rc::new(m)), si); + let imports_str = emit_py_imports(module_imports(Rc::new(m.clone())), si.clone()); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str) + v1_rt::concat("\n".to_string(), imports_str.clone()) }; let items_str = Rc::new({ let mut __result = Vec::new(); @@ -399,7 +399,7 @@ pub fn emit_py_module( "# Generated by v1 compiler -- do not edit.\n".to_string(), "# Source module: ".to_string(), ), - mod_name_str, + mod_name_str.clone(), ), "\n\n".to_string(), ), @@ -537,7 +537,7 @@ pub fn emit_py_prelude(typed_module: Rc) -> String { }; let has_services = { let mut __found = false; - for item in items.iter().cloned() { + for item in items.clone().iter().cloned() { if is_service_item(item.clone()) { __found = true; break; @@ -556,7 +556,7 @@ pub fn emit_py_prelude(typed_module: Rc) -> String { } else { "".to_string() }; - let typing_import = if (has_structs || has_enums) { + let typing_import = if (has_structs.clone() || has_enums.clone()) { "from typing import Optional, Union\n".to_string() } else { "".to_string() @@ -585,7 +585,7 @@ pub fn emit_py_typed_item( let env = (*scope.type_env).clone(); let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), Rc::new(env)) + emit_py_type_def_from_connective(item.clone(), Rc::new(env.clone())) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -632,10 +632,10 @@ pub fn emit_py_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, Rc::new(env)) + emit_py_service_def(item.clone(), registry, Rc::new(env.clone())) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), Rc::new(env)) + emit_py_resource_def(item.clone(), Rc::new(env.clone())) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } @@ -919,7 +919,7 @@ pub fn emit_py_fn_def( ), ":\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ) @@ -960,7 +960,7 @@ pub fn emit_py_fn_def( ), ":\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), "return ".to_string(), ), @@ -1014,7 +1014,7 @@ pub fn emit_py_func_def( body, RenderTarget::Python, registry.clone(), - body_scope, + body_scope.clone(), (depth.clone() + 1), ); let items = language_spec(RenderTarget::Python).items.clone(); @@ -1045,7 +1045,7 @@ pub fn emit_py_func_def( ), ":\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ) @@ -1182,7 +1182,7 @@ pub fn emit_py_service_init( language_spec(RenderTarget::Python).service_fields.clone(), ); let assigns = service_field_ctors( - fs, + fs.clone(), language_spec(RenderTarget::Python).service_fields.clone(), ); if ((params.clone().len() as i64) == 0) { @@ -1190,7 +1190,7 @@ pub fn emit_py_service_init( } else { { let params_str = - v1_rt::concat("self, ".to_string(), params.join(&", ".to_string())); + v1_rt::concat("self, ".to_string(), params.clone().join(&", ".to_string())); let assigns_str = Rc::new({ let mut __result = Vec::new(); for a in assigns.iter().cloned() { @@ -1293,7 +1293,7 @@ pub fn emit_py_headers_dict( let all_entries = if (auth_entry.clone() == "".to_string()) { header_entries.join(&", ".to_string()) } else { - v1_rt::concat(auth_entry, header_entries.join(&", ".to_string())) + v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) }; v1_rt::concat( v1_rt::concat("headers = {".to_string(), all_entries), @@ -1473,7 +1473,7 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String let all_params = if (params_str.clone() == "".to_string()) { "self".to_string() } else { - v1_rt::concat("self, ".to_string(), params_str) + v1_rt::concat("self, ".to_string(), params_str.clone()) }; let ret = emit_node_type( resolved_type(cap_node.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 0ad35602eb3..1f1ff4efb8b 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -164,7 +164,7 @@ pub fn render_rust_type( return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), + Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => match find_property( n.properties.clone(), "__applied_type_args".to_string(), @@ -173,7 +173,7 @@ pub fn render_rust_type( Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { render_rust_applied_type_shared( - applied, + applied.clone(), Rc::new(vec![]), shared_types, corpus_repr.clone(), @@ -252,7 +252,7 @@ pub fn render_rust_type_without_applied_binding( if node_is_set_collection(n.clone(), source_indices.clone()) { match n.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child); + let elem_node = child_type_node(elem_child.clone()); let elem_is_type_var = if (elem_node.inferred.clone() != None) { is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { @@ -267,7 +267,7 @@ pub fn render_rust_type_without_applied_binding( ) { { let elem_name = - authored_name_at(source_indices.clone(), elem_node); + authored_name_at(source_indices.clone(), elem_node.clone()); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("Set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -385,14 +385,14 @@ pub fn map_literal_key_is_string( source_indices: Rc>>, ) -> bool { match map_type_node.children.clone().first().cloned() { - Some(key_child) => is_rust_string_like(key_child, source_indices.clone()), + Some(key_child) => is_rust_string_like(key_child.clone(), source_indices.clone()), None => match find_property( map_type_node.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), ) { Some(applied) => match applied.children.clone().first().cloned() { - Some(akey) => is_rust_string_like(akey, source_indices.clone()), + Some(akey) => is_rust_string_like(akey.clone(), source_indices.clone()), None => false, }, None => false, @@ -488,14 +488,14 @@ pub fn rust_host_text_carrier_elem_name( source_indices: Rc>>, ) -> String { match n.children.clone().first().cloned() { - Some(ch) => authored_name_at(source_indices.clone(), ch), + Some(ch) => authored_name_at(source_indices.clone(), ch.clone()), None => match find_property( n.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), ) { Some(applied) => match applied.children.clone().first().cloned() { - Some(ach) => authored_name_at(source_indices.clone(), ach), + Some(ach) => authored_name_at(source_indices.clone(), ach.clone()), None => "".to_string(), }, None => "".to_string(), @@ -516,7 +516,8 @@ pub fn is_host_text_carrier_type( if (nm.clone() == "String".to_string()) { true } else { - if ((nm.clone() == "FreeMonoid".to_string()) || (nm == "List".to_string())) { + if ((nm.clone() == "FreeMonoid".to_string()) || (nm.clone() == "List".to_string())) + { (rust_host_text_carrier_elem_name(n.clone(), source_indices.clone()) == "Char".to_string()) } else { @@ -583,7 +584,7 @@ pub fn rust_normalize_partial_function_field_type_text(rendered: String) -> Stri pub fn is_parametric_opaque_type_by_name(env: Rc, type_name: String) -> bool { match lookup_type_by_name(env.clone(), type_name) { - Some(item) => is_parametric_opaque_type_decl_item(item, env.source_indices.clone()), + Some(item) => is_parametric_opaque_type_decl_item(item.clone(), env.source_indices.clone()), None => false, } } @@ -602,7 +603,7 @@ pub fn is_parametric_opaque_type_base( source_indices.clone(), module_index, ) { - Some(item) => is_parametric_opaque_type_decl_item(item, source_indices.clone()), + Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), None => false, } } @@ -637,7 +638,7 @@ pub fn type_leaf_name_for_collapse( if (a.clone() == "".to_string()) { n.name.clone() } else { - a + a.clone() } } } @@ -802,7 +803,7 @@ pub fn render_rust_applied_type_arg( "()".to_string() } else { match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv), + Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => render_rust_decl_type( n.clone(), generic_param_names.clone(), @@ -832,17 +833,17 @@ pub fn render_rust_applied_type( let base_name = authored_name_at(source_indices.clone(), n.clone()); if ((n.children.clone().len() as i64) == 0) { match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { - Some(host) => host, - None => rust_named_type_base(base_name, corpus_repr.clone()), + Some(host) => host.clone(), + None => rust_named_type_base(base_name.clone(), corpus_repr.clone()), } } else { { let base = match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { - Some(host) => host, + Some(host) => host.clone(), None => rust_applied_type_base(base_name.clone(), corpus_repr.clone()), }; - let peel = is_parametric_opaque_type_by_name(env.clone(), base_name); + let peel = is_parametric_opaque_type_by_name(env.clone(), base_name.clone()); let args = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { @@ -947,12 +948,12 @@ pub fn render_rust_decl_type( }; match applied_overlay { Some(applied) => render_rust_applied_type_shared( - applied, + applied.clone(), generic_param_names.clone(), shared_types.clone(), corpus_repr.clone(), source_indices.clone(), - variant_to_enum, + variant_to_enum.clone(), env.clone(), ), None => { @@ -970,7 +971,7 @@ pub fn render_rust_decl_type( __found }) { - to_pascal(name) + to_pascal(name.clone()) } else { if (((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -985,14 +986,16 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop == None)) + && (applied_prop.clone() == None)) && v1_rt::set_contains(&shared_types, name.clone())) { { - let rendered = - rust_render_type_leaf_name(name.clone(), variant_to_enum); + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); render_rust_shared_type_if_needed( - name, + name.clone(), rendered, shared_types.clone(), ) @@ -1006,7 +1009,7 @@ pub fn render_rust_decl_type( { render_rust_shared_type_if_needed( name.clone(), - name, + name.clone(), shared_types.clone(), ) } else { @@ -1056,7 +1059,7 @@ pub fn render_rust_decl_type( __result }); let applied_ty = if (name.clone() == tuple_type_name()) { - render_tuple_parts(arg_list, RenderTarget::Rust) + render_tuple_parts(arg_list.clone(), RenderTarget::Rust) } else { if node_is_keyed_collection( n.clone(), @@ -1068,16 +1071,20 @@ pub fn render_rust_decl_type( .get(1 as usize) .cloned() { - Some(v) => { - emit_map_type(k, v, RenderTarget::Rust) - } + Some(v) => emit_map_type( + k.clone(), + v.clone(), + RenderTarget::Rust, + ), None => v1_rt::concat( v1_rt::concat( v1_rt::concat( base, "<".to_string(), ), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1085,7 +1092,9 @@ pub fn render_rust_decl_type( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1099,7 +1108,7 @@ pub fn render_rust_decl_type( match arg_list.clone().first().cloned() { Some(inner) => emit_container( to_snake(name.clone()), - inner, + inner.clone(), RenderTarget::Rust, ), None => v1_rt::concat( @@ -1108,7 +1117,9 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1117,7 +1128,9 @@ pub fn render_rust_decl_type( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ) @@ -1125,7 +1138,7 @@ pub fn render_rust_decl_type( } }; render_rust_shared_type_if_needed( - name, + name.clone(), applied_ty, shared_types.clone(), ) @@ -1154,11 +1167,11 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { return false; } let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, + Some(b) => b.clone(), None => { let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, + match lookup_type_by_name(env.clone(), name.clone()) { + Some(b) => b.clone(), None => return false, } } @@ -1223,7 +1236,7 @@ pub fn render_rust_fn_sig_type( && !is_container_type(name.clone())) && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) { - render_rust_shared_type_if_needed(name.clone(), name, shared_types.clone()) + render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) } else { if ((generic_param_names.clone().len() as i64) > 0) { render_rust_decl_type( @@ -1272,7 +1285,7 @@ pub fn render_rust_fn_sig_type_applied_binding( { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types, ) } else { @@ -1309,12 +1322,12 @@ pub fn alias_rhs_container_arg( match arg.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if node_is_collection(rt.clone(), source_indices) { - rt + rt.clone() } else { - arg + arg.clone() } } - _ => arg, + _ => arg.clone(), } } @@ -1351,13 +1364,13 @@ pub fn render_rust_alias_rhs_type( __found }) { - to_pascal(name) + to_pascal(name.clone()) } else { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { - Some(host) => host, + Some(host) => host.clone(), None => { if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr.clone())) @@ -1368,12 +1381,14 @@ pub fn render_rust_alias_rhs_type( ) } else { match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier, + Some(carrier) => carrier.clone(), None => { - let rendered = - rust_render_type_leaf_name(name.clone(), variant_to_enum); + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); render_rust_shared_type_if_needed( - name, + name.clone(), rendered, shared_types.clone(), ) @@ -1403,7 +1418,7 @@ pub fn render_rust_alias_rhs_type( name.clone(), corpus_repr.clone(), ) { - Some(host) => host, + Some(host) => host.clone(), None => { if (def_mod.clone() != local_mod) { v1_rt::concat( @@ -1420,7 +1435,7 @@ pub fn render_rust_alias_rhs_type( }; let peel = is_parametric_opaque_type_base( name.clone(), - def_mod, + def_mod.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -1472,12 +1487,12 @@ pub fn render_rust_alias_rhs_type( v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), ">".to_string(), ); - if (v1_rt::set_contains(&shared_types, name) + if (v1_rt::set_contains(&shared_types, name.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, applied_ty) + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty + applied_ty.clone() } } } else { @@ -1530,7 +1545,7 @@ pub fn is_rust_value_type( { let normed = normalize_access_type_node(n); match is_copy(RenderTarget::Rust, authored_name_at(source_indices, normed)) { - Some(v) => v, + Some(v) => v.clone(), None => false, } } @@ -1548,7 +1563,7 @@ pub fn is_rust_string_like( pub fn rust_source_root() -> String { match scaffold_for_target(RenderTarget::Rust).source_dir.clone() { - Some(dir) => dir, + Some(dir) => dir.clone(), None => "".to_string(), } } @@ -1561,7 +1576,7 @@ pub fn rust_source_ext() -> String { pub fn rust_visibility_prefix() -> String { match (*visibility_for_target(RenderTarget::Rust)).clone() { - VisibilitySpec::KeywordVisibility { prefix: p, .. } => p, + VisibilitySpec::KeywordVisibility { prefix: p, .. } => p.clone(), _ => "__VISIBILITY_SPEC_MISMATCH__".to_string(), } } @@ -1637,9 +1652,10 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( false } else { match children.clone().first().cloned() { - Some(child) => { - rust_nominal_identity_carrier_shape_eligible(child_type_node(child), source_indices) - } + Some(child) => rust_nominal_identity_carrier_shape_eligible( + child_type_node(child.clone()), + source_indices, + ), None => false, } } @@ -1666,7 +1682,8 @@ pub fn rust_nominal_ord_type_ref_eligible( (((((elem_node.children.clone().len() as i64) == 0) && ((elem_node.params.clone().len() as i64) == 0)) && (elem_node.connective.clone() == Connective::NoConnective)) - && ((type_name.clone() == "Symbol".to_string()) || (type_name == "DiffId".to_string()))) + && ((type_name.clone() == "Symbol".to_string()) + || (type_name.clone() == "DiffId".to_string()))) } } @@ -1688,7 +1705,7 @@ pub fn rust_serde_tag_attr() -> String { .tag_attribute .clone() { - Some(attr) => attr, + Some(attr) => attr.clone(), None => emit_error_expr( "missing serde tag_attribute for Rust".to_string(), RenderTarget::Rust, @@ -1776,15 +1793,15 @@ pub fn field_value_by_name( .first() .cloned() { - Some(fi) => Some(field_init_node_value(fi)), + Some(fi) => Some(field_init_node_value(fi.clone())), None => None, } } pub fn literal_string_value(n: Rc) -> Option { match (*n.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: lv, .. } => match (*lv).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s), + ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s.clone()), _ => None, }, _ => None, @@ -1797,7 +1814,7 @@ pub fn record_string_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(value_node) => literal_string_value(value_node), + Some(value_node) => literal_string_value(value_node.clone()), None => None, } } @@ -1815,7 +1832,7 @@ pub fn coproduct_decl_ref_decl_name( ) -> Option { match field_value_by_name(body, "coproduct".to_string(), source_indices.clone()) { Some(decl_ref_node) => record_string_field( - decl_ref_node, + decl_ref_node.clone(), "decl_name".to_string(), source_indices.clone(), ), @@ -1829,7 +1846,7 @@ pub fn optional_string_record_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(n) => literal_string_value(n), + Some(n) => literal_string_value(n.clone()), None => None, } } @@ -1840,7 +1857,7 @@ pub fn required_literal_string_policy_field( source_indices: Rc>>, ) -> Option { match field_value_by_name(record, field_name, source_indices) { - Some(n) => literal_string_value(n), + Some(n) => literal_string_value(n.clone()), None => None, } } @@ -1868,7 +1885,7 @@ pub fn rust_string_policy_for_naming( ) { Some(prefix) => rust_serde_policy( "".to_string(), - Some(prefix), + Some(prefix.clone()), None, Some("StripAffixAndSnakeCase".to_string()), ), @@ -1886,7 +1903,7 @@ pub fn rust_string_policy_for_naming( Some(suffix) => rust_serde_policy( "".to_string(), None, - Some(suffix), + Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -1898,7 +1915,7 @@ pub fn rust_string_policy_for_naming( { match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy("".to_string(), Some(prefix), Some(suffix), Some("StripAffixAndSnakeCase".to_string())), + Some(suffix) => rust_serde_policy("".to_string(), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), }, None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), @@ -1906,7 +1923,7 @@ pub fn rust_string_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name, + naming_name.clone(), )) } } @@ -1968,7 +1985,7 @@ pub fn rust_internal_policy_for_naming( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string(), ), - Some(prefix), + Some(prefix.clone()), None, Some("StripAffixAndSnakeCase".to_string()), ), @@ -1989,7 +2006,7 @@ pub fn rust_internal_policy_for_naming( "\")]".to_string(), ), None, - Some(suffix), + Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -2001,7 +2018,7 @@ pub fn rust_internal_policy_for_naming( { match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix), Some(suffix), Some("StripAffixAndSnakeCase".to_string())), + Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), }, None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), @@ -2009,7 +2026,7 @@ pub fn rust_internal_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name, + naming_name.clone(), )) } } @@ -2030,9 +2047,11 @@ pub fn rust_internal_policy_for_encoding( source_indices.clone(), ) { Some(tag_field) => match naming_policy_node(encoding.clone(), source_indices.clone()) { - Some(naming) => { - rust_internal_policy_for_naming(tag_field, naming, source_indices.clone()) - } + Some(naming) => rust_internal_policy_for_naming( + tag_field.clone(), + naming.clone(), + source_indices.clone(), + ), None => rust_serde_error_policy( "InternallyTaggedObject requires a naming policy".to_string(), ), @@ -2054,7 +2073,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { if (encoding_name.clone() == "StringVariant".to_string()) { match naming_policy_node(ve.clone(), source_indices.clone()) { - Some(nv) => rust_string_policy_for_naming(nv, source_indices.clone()), + Some(nv) => rust_string_policy_for_naming(nv.clone(), source_indices.clone()), None => rust_serde_error_policy( "StringVariant requires a naming policy".to_string(), ), @@ -2068,7 +2087,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantEncoding: ".to_string(), - encoding_name, + encoding_name.clone(), )) } } @@ -2082,7 +2101,7 @@ pub fn resolve_wire_serde_policy( source_indices: Rc>>, ) -> Rc { match wire_item.body.clone() { - Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve, source_indices), + Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), _ => rust_serde_error_policy("wire_contract: VariantEncoding could not be resolved (no initializer body and not a record literal)".to_string()), @@ -2121,7 +2140,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( "wire_contract: VariantEncoding alias chain exceeded recursion limit".to_string(), ); } else { - match wire_contract_item.clone() { + match wire_contract_item { None => { break rust_tagged_object_policy(); } @@ -2275,7 +2294,7 @@ pub fn coproduct_wire_contract_encoding( source_indices: Rc>>, ) -> Option> { match contract_item.body.clone() { - Some(body) => field_value_by_name(body, "encoding".to_string(), source_indices), + Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } } @@ -2293,8 +2312,8 @@ pub fn coproduct_wire_contract_targets( source_indices: Rc>>, ) -> bool { match contract_item.body.clone() { - Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { - Some(target_name) => (target_name == coproduct_name), + Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { + Some(target_name) => (target_name.clone() == coproduct_name), None => false, }, None => false, @@ -2353,7 +2372,7 @@ pub fn data_item_type_is_coproduct_wire_contract( ) -> bool { match item.type_annotation.clone() { Some(type_node) => { - ((authored_name_at(source_indices.clone(), type_node) + ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) && module_imports_std_serialization_coproduct_wire_contract( imports, @@ -2412,7 +2431,7 @@ pub fn is_coproduct_wire_contract_row( source_indices.clone(), ) != None) && (field_value_by_name( - body, + body.clone(), "encoding".to_string(), source_indices.clone(), ) != None)) @@ -2430,7 +2449,7 @@ pub fn emit_coproduct_wire_contract_target_validation( source_indices: Rc>>, ) -> String { match contract_item.body.clone() { - Some(body) => match coproduct_decl_ref_decl_name(body, source_indices) { + Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { let mut __found = false; @@ -2447,7 +2466,7 @@ pub fn emit_coproduct_wire_contract_target_validation( emit_rust_compile_error_item(v1_rt::concat( "CoproductWireContract target does not name a local coproduct: " .to_string(), - target_name, + target_name.clone(), )) } } @@ -2543,29 +2562,30 @@ pub fn resolve_local_coproduct_wire_policy( None } else { if ((contracts.clone().len() as i64) == 1) { - match contracts.first().cloned() { - Some(contract) => { - match coproduct_wire_contract_encoding(contract, source_indices.clone()) { - Some(encoding) => { - if (variant_encoding_is_string_variant( + match contracts.clone().first().cloned() { + Some(contract) => match coproduct_wire_contract_encoding( + contract.clone(), + source_indices.clone(), + ) { + Some(encoding) => { + if (variant_encoding_is_string_variant( + encoding.clone(), + source_indices.clone(), + ) && !all_unit_variants) + { + Some(rust_serde_error_policy(v1_rt::concat("CoproductWireContract StringVariant requires a nullary-only coproduct: ".to_string(), coproduct_name.clone()))) + } else { + Some(resolve_wire_serde_policy_from_encoding_node( encoding.clone(), source_indices.clone(), - ) && !all_unit_variants) - { - Some(rust_serde_error_policy(v1_rt::concat("CoproductWireContract StringVariant requires a nullary-only coproduct: ".to_string(), coproduct_name.clone()))) - } else { - Some(resolve_wire_serde_policy_from_encoding_node( - encoding, - source_indices.clone(), - )) - } + )) } - None => Some(rust_serde_error_policy(v1_rt::concat( - "CoproductWireContract missing encoding for ".to_string(), - coproduct_name.clone(), - ))), } - } + None => Some(rust_serde_error_policy(v1_rt::concat( + "CoproductWireContract missing encoding for ".to_string(), + coproduct_name.clone(), + ))), + }, None => None, } } else { @@ -2622,7 +2642,7 @@ pub fn insert_scoped_data_item( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&scoped, name.clone()) { - Some(entries) => entries, + Some(entries) => entries.clone(), None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -2670,7 +2690,7 @@ pub fn build_scoped_data_item_index( .iter() .cloned() .fold( - local, + local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), @@ -2716,7 +2736,7 @@ pub fn augment_scoped_data_item_index_with_imports( data_items: Rc>>, ) -> Rc>>>> { imports.iter().cloned().fold( - scoped, + scoped.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at(source_indices.clone(), imp.clone()); if import_is_all(imp.clone()) { @@ -2757,7 +2777,7 @@ pub fn rust_serde_rename_template_text() -> String { .rename_attribute_template .clone() { - Some(template) => template, + Some(template) => template.clone(), None => emit_error_expr( "missing serde rename_attribute_template for Rust".to_string(), RenderTarget::Rust, @@ -2769,7 +2789,7 @@ pub fn rust_test_file_path(module_name: String) -> String { { let conventions = test_conventions_for_target(RenderTarget::Rust); let file_dir = match conventions.file_dir.clone() { - Some(dir) => dir, + Some(dir) => dir.clone(), None => "".to_string(), }; let filename = module_to_filename(module_name); @@ -2795,7 +2815,7 @@ pub fn rust_async_test_decorator() -> String { .async_decorator .clone() { - Some(decorator) => decorator, + Some(decorator) => decorator.clone(), None => emit_error_expr( "missing async_decorator for Rust test conventions".to_string(), RenderTarget::Rust, @@ -2816,7 +2836,7 @@ pub fn emit_rust_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2839,8 +2859,8 @@ pub fn emit_rust_block_stmts( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2864,7 +2884,7 @@ pub fn emit_rust_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2880,7 +2900,7 @@ pub fn emit_rust_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2898,16 +2918,16 @@ pub fn emit_rust_init_block_stmts( ExprData::ExprLet => true, _ => false, }; - let line = if is_let.clone() { - raw_line.clone() + let line = if is_let { + raw_line } else { - v1_rt::concat(raw_line.clone(), ";".to_string()) + v1_rt::concat(raw_line, ";".to_string()) }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2927,7 +2947,10 @@ pub fn rust_qualify_type_leaf_name( match v1_rt::map_get(&variant_to_enum, name.clone()) { Some(parent) => { if (parent.clone() != "".to_string()) { - v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) } else { name.clone() } @@ -2944,7 +2967,7 @@ pub fn rust_render_type_leaf_name( "()".to_string() } else { match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier, + Some(carrier) => carrier.clone(), None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum.clone()), } } @@ -3097,7 +3120,7 @@ pub fn is_simple_disj(item: Rc) -> bool { pub fn is_dag_value_type_name(name: String) -> bool { match is_copy(RenderTarget::Rust, name) { - Some(v) => v, + Some(v) => v.clone(), None => false, } } @@ -3114,7 +3137,8 @@ pub fn is_type_constant( unit_only: unit_only, .. } => { - (((unit_only && !is_recursive) && !has_generics) && !summary.has_fn_fields.clone()) + (((unit_only.clone() && !is_recursive) && !has_generics) + && !summary.has_fn_fields.clone()) } TypeRepr::StructRepr => { if ((is_recursive || has_generics) || summary.has_fn_fields.clone()) { @@ -3164,7 +3188,7 @@ pub fn maybe_mark_shared_type( TypeRepr::EnumRepr { unit_only: unit_only, .. - } => (unit_only == false), + } => (unit_only.clone() == false), }); if (needs_sharing && !is_type_constant(summary.clone(), recursive_type_set)) { v1_rt::rc_set_insert(acc, summary.name.clone()) @@ -3210,7 +3234,7 @@ pub fn build_shared_types( __result }); collection_keys.iter().cloned().fold( - user_shared, + user_shared.clone(), |acc: Rc>, key: String| { let pascal = to_pascal(key.clone()); v1_rt::rc_set_insert(acc, pascal.clone()) @@ -3337,7 +3361,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>(), }), |acc: Rc, entry: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/05_emit_rust.dag:78228:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let read_only = if v1_rt::set_contains( &callable_set, @@ -3408,7 +3432,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if ((workflow_default_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: workflow_default_diags, + diagnostics: workflow_default_diags.clone(), }); } let svc_module_map = typed.modules.clone().iter().cloned().fold( @@ -3522,11 +3546,11 @@ pub fn emit_rust(typed: Rc) -> Rc { }; let cargo = emit_cargo_toml(crate_name.clone(), has_services.clone()); let main_file = emit_main_rs( - workflow_funcs, + workflow_funcs.clone(), typed.modules.clone(), has_services.clone(), - crate_name, - svc_module_map, + crate_name.clone(), + svc_module_map.clone(), ); let rt_file = emit_v2_rt_module(); let compiler_tests_file = if has_pipeline.clone() { @@ -3534,7 +3558,7 @@ pub fn emit_rust(typed: Rc) -> Rc { } else { Rc::new(vec![]) }; - let dry_run_file = if has_services { + let dry_run_file = if has_services.clone() { Rc::new(vec![emit_dry_run_module()]) } else { Rc::new(vec![]) @@ -3543,10 +3567,13 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::concat(module_files, Rc::new(vec![rt_file])), dry_run_file, ); - let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline); + let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline.clone()); let files = v1_rt::concat( v1_rt::concat( - v1_rt::concat(Rc::new(vec![cargo, lib_file, main_file]), all_mod_files), + v1_rt::concat( + Rc::new(vec![cargo, lib_file, main_file]), + all_mod_files.clone(), + ), compiler_tests_file, ), test_files, @@ -3667,7 +3694,7 @@ pub fn emit_module( emit_module_full( typed_module.clone(), registry, - emit_info, + emit_info.clone(), shared_types, v1_rt::rc_empty_map::(), build_data_item_index(Rc::new(vec![typed_module.clone()])), @@ -3720,7 +3747,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3783,10 +3810,10 @@ pub fn emit_module_full( let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str) + v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3842,7 +3869,10 @@ pub fn emit_module_full( let svc_imports_str = if ((extern_svc_imports.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat("\n".to_string(), extern_svc_imports.join(&"\n".to_string())) + v1_rt::concat( + "\n".to_string(), + extern_svc_imports.clone().join(&"\n".to_string()), + ) }; let local_enum_uses = Rc::new({ let mut __result = Vec::new(); @@ -3892,7 +3922,7 @@ pub fn emit_module_full( __result }); let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3905,7 +3935,7 @@ pub fn emit_module_full( let wire_context_imports = v1_rt::concat( module_import_items, contracts_imports_for_module( - this_module_name, + this_module_name.clone(), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3921,12 +3951,18 @@ pub fn emit_module_full( if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat(coproduct_wire_contract_validations, "\n\n".to_string()) + v1_rt::concat( + coproduct_wire_contract_validations.clone(), + "\n\n".to_string(), + ) }; let local_uses_str = if ((local_enum_uses.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat("\n".to_string(), local_enum_uses.join(&"\n".to_string())) + v1_rt::concat( + "\n".to_string(), + local_enum_uses.clone().join(&"\n".to_string()), + ) }; let wire_contract_item = Rc::new({ let mut __result = Vec::new(); @@ -3949,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3971,22 +4007,22 @@ pub fn emit_module_full( let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { - raw_filename + raw_filename.clone() }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))))))))((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4040,7 +4076,7 @@ pub fn is_import_graph_type_name( ) { Some(src) => type_name_is_rust_importable_in_module( name.clone(), - src, + src.clone(), typed_modules.clone(), registry.clone(), export_sets.clone(), @@ -4191,7 +4227,7 @@ pub fn module_name_from_filename( match v1_rt::map_get(&module_index.by_filename.clone(), mod_filename) { Some(mods) => Rc::new({ let mut __result = Vec::new(); - for tm in mods.iter().cloned() { + for tm in mods.clone().iter().cloned() { __result.push(authored_name_at( source_indices.clone(), tm.module.clone(), @@ -4215,7 +4251,7 @@ pub fn has_physical_type_def_in_module_filename( match v1_rt::map_get(&module_index.by_filename.clone(), mod_filename) { Some(mods) => { let mut __found = false; - for tm in mods.iter().cloned() { + for tm in mods.clone().iter().cloned() { if { let mut __found = false; for item in tm.items.clone().iter().cloned() { @@ -4365,11 +4401,11 @@ pub fn type_name_is_rust_importable_in_module( { None => false, Some(item) => type_item_has_rust_nominal_shell_authority( - item, + item.clone(), name.clone(), module_name.clone(), module_imports(tm.module.clone()), - module_emit_scope(tm), + module_emit_scope(tm.clone()), registry, export_sets, typed_modules.clone(), @@ -4398,7 +4434,7 @@ pub fn imported_name_is_non_emittable_type( source_indices.clone(), module_index.clone(), ) { - Some(src) => src, + Some(src) => src.clone(), None => import_module.clone(), }; (type_name_is_export_source_in_module( @@ -4409,7 +4445,7 @@ pub fn imported_name_is_non_emittable_type( module_index.clone(), ) && (type_name_is_rust_importable_in_module( name.clone(), - defining_module, + defining_module.clone(), typed_modules.clone(), registry, export_sets.clone(), @@ -5018,7 +5054,7 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - mod_name + mod_name.clone() } else { match reexport_source_module_name( name.clone(), @@ -5028,8 +5064,8 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - Some(src) => module_to_filename(src), - None => mod_name, + Some(src) => module_to_filename(src.clone()), + None => mod_name.clone(), } } } @@ -5071,11 +5107,11 @@ pub fn variant_defining_module_filename_for_import( continue; } } else { - break fallback.clone(); + break fallback; } } None => { - break fallback.clone(); + break fallback; } } } @@ -5102,7 +5138,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent == parent_enum.clone()) { + if (local_parent.clone() == parent_enum.clone()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -5176,7 +5212,7 @@ pub fn explicit_import_source_module_for_name( .first() .cloned() { - Some(src) => Some(src), + Some(src) => Some(src.clone()), None => match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ @@ -5217,7 +5253,7 @@ pub fn explicit_import_source_module_for_name( .first() .cloned() { - Some(src) => Some(src), + Some(src) => Some(src.clone()), None => None, }, }, @@ -5237,7 +5273,7 @@ pub fn reexport_variant_parent_in_import_module( loop { match reexport_source_module_name( variant_name.clone(), - import_module.clone(), + import_module, typed_modules.clone(), export_sets.clone(), source_indices.clone(), @@ -5318,7 +5354,7 @@ pub fn alias_rhs_rust_qualify_module_filename( source_indices.clone(), module_index.clone(), ) { - spell_mod + spell_mod.clone() } else { match module_name_from_filename( spell_mod.clone(), @@ -5328,16 +5364,16 @@ pub fn alias_rhs_rust_qualify_module_filename( ) { Some(mod_name) => match reexport_source_module_name( name.clone(), - mod_name, + mod_name.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone(), ) { - Some(src) => module_to_filename(src), - None => spell_mod, + Some(src) => module_to_filename(src.clone()), + None => spell_mod.clone(), }, - None => spell_mod, + None => spell_mod.clone(), } } } @@ -5433,7 +5469,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .first() .cloned() { - Some(import_module) => module_to_filename(import_module), + Some(import_module) => module_to_filename(import_module.clone()), None => match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ @@ -5477,7 +5513,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .first() .cloned() { - Some(import_module) => module_to_filename(import_module), + Some(import_module) => module_to_filename(import_module.clone()), None => item_defining_module_filename(name.clone(), registry, local_mod), }, } @@ -5510,7 +5546,7 @@ pub fn type_item_by_name_in_module_filename( module_index.clone(), ) { Some(mod_name) => match typed_module_by_name( - mod_name, + mod_name.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -5572,7 +5608,7 @@ pub fn type_item_has_rust_nominal_shell_authority( && ((rhs.children.clone().len() as i64) > 0)) { alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -5593,9 +5629,9 @@ pub fn type_item_has_rust_nominal_shell_authority( rhs.clone(), ); (((rhs_name.clone() != item_text.clone()) - && (rhs_name != "".to_string())) + && (rhs_name.clone() != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -5674,7 +5710,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( def_module_name.clone(), module_imports(tm.module.clone()), module_emit_scope(tm.clone()), - registry.clone(), + registry, export_sets.clone(), typed_modules.clone(), source_indices.clone(), @@ -5765,7 +5801,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); (rhs_base_has_rust_type_authority_in_module( - name, + name.clone(), def_mod, module_name.clone(), imports.clone(), @@ -5829,7 +5865,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); rhs_base_has_rust_type_authority_in_module( - name, + name.clone(), def_mod, module_name.clone(), imports.clone(), @@ -5860,7 +5896,7 @@ pub fn is_self_referential_opaque_type_resolved( let item_text = authored_name_at(source_indices.clone(), item.clone()); let rhs = resolved_type(item.clone()); (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), rhs) == item_text)) + && (authored_name_at(source_indices.clone(), rhs.clone()) == item_text)) } } @@ -5903,7 +5939,10 @@ pub fn emit_parametric_phantom_opaque_struct( let generic_names = item_generic_param_names(item.clone(), source_indices.clone()); let marker_ty = match generic_names.first().cloned() { Some(g) => v1_rt::concat( - v1_rt::concat("std::marker::PhantomData<".to_string(), to_pascal(g)), + v1_rt::concat( + "std::marker::PhantomData<".to_string(), + to_pascal(g.clone()), + ), ">".to_string(), ), None => "std::marker::PhantomData<()>".to_string(), @@ -5942,9 +5981,9 @@ pub fn is_emittable_parametric_type_alias_item( ((rhs_name.clone() != item_text) && (((rhs.children.clone().len() as i64) > 0) || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name != "".to_string())) + && (rhs_name.clone() != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -5995,7 +6034,7 @@ pub fn import_variant_parent_for_name( source_indices.clone(), module_index.clone(), ) { - Some(parent) => parent, + Some(parent) => parent.clone(), None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -6006,17 +6045,17 @@ pub fn import_variant_parent_for_name( source_indices.clone(), module_index.clone(), ) { - Some(parent) => parent, + Some(parent) => parent.clone(), None => { match find_variant_parent(type_summaries.clone(), n.clone(), imported_enums) { - Some(parent) => parent, + Some(parent) => parent.clone(), None => match find_variant_parent( type_summaries.clone(), n.clone(), import_module_enums, ) { - Some(parent) => parent, + Some(parent) => parent.clone(), None => "".to_string(), }, } @@ -6259,7 +6298,7 @@ pub fn emit_specific_import_block( __result }); let merged_direct_names = - unique_strings(v1_rt::concat(direct_names, local_parent_names)); + unique_strings(v1_rt::concat(direct_names.clone(), local_parent_names)); let type_direct_names = Rc::new({ let mut __result = Vec::new(); for n in merged_direct_names.clone().iter().cloned() { @@ -6280,7 +6319,7 @@ pub fn emit_specific_import_block( }); let other_direct_names = Rc::new({ let mut __result = Vec::new(); - for n in merged_direct_names.iter().cloned() { + for n in merged_direct_names.clone().iter().cloned() { if (is_import_graph_type_name( n.clone(), import_module.clone(), @@ -6375,7 +6414,7 @@ pub fn emit_specific_import_block( { let names_str = Rc::new({ let mut __result = Vec::new(); - for n in other_direct_names.iter().cloned() { + for n in other_direct_names.clone().iter().cloned() { __result.push(emit_import_name(n.clone(), registry.clone())); } __result @@ -6412,7 +6451,7 @@ pub fn emit_specific_import_block( __result }), if (other_direct_line.clone() != "".to_string()) { - Rc::new(vec![other_direct_line]) + Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) }, @@ -6506,7 +6545,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib }); let main_lines = if ((direct_lines.clone().len() as i64) > 0) { v1_rt::concat( - direct_lines, + direct_lines.clone(), Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { @@ -6566,7 +6605,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con }); let imported_enums = Rc::new({ let mut __result = Vec::new(); - for n in top_level.iter().cloned() { + for n in top_level.clone().iter().cloned() { if is_enum_in_summaries(type_summaries.clone(), n.clone()) { __result.push(n); } @@ -6577,7 +6616,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con let mut __result = Vec::new(); for en in Rc::new({ let mut __result = Vec::new(); - for en in imported_enums.iter().cloned() { + for en in imported_enums.clone().iter().cloned() { if (({ let mut __found = false; for p in parent_list.clone().iter().cloned() { @@ -6652,14 +6691,15 @@ pub fn rust_pub_use_module_name(line: String) -> String { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.split(&"::".to_string()) + rest.clone() + .split(&"::".to_string()) .map(|s| s.to_string()) .collect::>(), ) .first() .cloned() { - Some(mod_name) => mod_name, + Some(mod_name) => mod_name.clone(), None => "".to_string(), }, None => "".to_string(), @@ -6681,7 +6721,8 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.split(&"::".to_string()) + rest.clone() + .split(&"::".to_string()) .map(|s| s.to_string()) .collect::>(), ) @@ -6690,6 +6731,7 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { { Some(name_part) => match Rc::new( name_part + .clone() .split(&";".to_string()) .map(|s| s.to_string()) .collect::>(), @@ -6697,7 +6739,7 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { .first() .cloned() { - Some(name) => name, + Some(name) => name.clone(), None => "".to_string(), }, None => "".to_string(), @@ -6723,7 +6765,8 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { ); match prefix_parts.get(1 as usize).cloned() { Some(rest) => match Rc::new( - rest.split(&"}".to_string()) + rest.clone() + .split(&"}".to_string()) .map(|s| s.to_string()) .collect::>(), ) @@ -6732,6 +6775,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { { Some(names) => Rc::new( names + .clone() .split(&", ".to_string()) .map(|s| s.to_string()) .collect::>(), @@ -7143,10 +7187,10 @@ pub fn emit_prelude(imported_names: Rc>) -> String { let variant_line = if (has_holds.clone() && has_violates.clone()) { "".to_string() } else { - if has_holds { + if has_holds.clone() { "\nuse crate::v1_rt::Witness::Violates;".to_string() } else { - if has_violates { + if has_violates.clone() { "\nuse crate::v1_rt::Witness::Holds;".to_string() } else { "\nuse crate::v1_rt::Witness::{Holds, Violates};".to_string() @@ -7196,7 +7240,7 @@ pub fn emit_typed_item( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - Rc::new(env), + Rc::new(env.clone()), emit_info.clone(), wire_contract_item, data_items, @@ -7219,7 +7263,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text) + rust_nominal_identity_carrier_def(item_text.clone()) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -7245,11 +7289,11 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), " = ".to_string(), ), - host, + host.clone(), ), ";".to_string(), ), @@ -7264,7 +7308,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), " = ".to_string(), ), @@ -7295,7 +7339,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text) + rust_nominal_identity_carrier_def(item_text.clone()) } else { match rust_seed_host_container_base( item_text.clone(), @@ -7326,19 +7370,19 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), " = ".to_string(), ), - host, + host.clone(), ), "<".to_string(), ), Rc::new({ let mut __result = Vec::new(); - for n in generic_names.iter().cloned() { + for n in generic_names.clone().iter().cloned() { __result.push(to_pascal(n.clone())); } __result @@ -7381,14 +7425,16 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( "std::marker::PhantomData<".to_string(), - rust_phantom_marker_inner(unused_params), + rust_phantom_marker_inner( + unused_params.clone(), + ), ), ">".to_string(), ) } else { render_rust_alias_rhs_type( - alias_rhs, - generic_names, + alias_rhs.clone(), + generic_names.clone(), shared_types, emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -7416,7 +7462,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), @@ -7470,14 +7516,14 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco { + let fn_move_sites = if item_is_tco.clone() { v1_rt::rc_empty_map::() } else { match v1_rt::map_get( &emit_info.move_sites_index.clone(), - qualified_name, + qualified_name.clone(), ) { - Some(m) => m, + Some(m) => m.clone(), None => v1_rt::rc_empty_map::(), } }; @@ -7501,7 +7547,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(Rc::new(env), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7511,7 +7557,7 @@ pub fn emit_typed_item( }; if is_effectful { emit_func_def( - item_text, + item_text.clone(), item.params.clone(), resolved_type(item.clone()), item.uses.clone(), @@ -7523,7 +7569,7 @@ pub fn emit_typed_item( ) } else { emit_fn_def( - item_text, + item_text.clone(), item.params.clone(), resolved_type(item.clone()), item.body.clone().clone().unwrap(), @@ -7537,7 +7583,7 @@ pub fn emit_typed_item( } else { if is_data_def_item(item.clone()) { emit_data_def( - item_text, + item_text.clone(), item.type_annotation.clone().clone().unwrap(), item.body.clone().clone().unwrap(), registry.clone(), @@ -7553,7 +7599,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env), + Rc::new(env.clone()), ) } else { if is_resource_def_item(item.clone()) { @@ -7561,13 +7607,13 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env), + Rc::new(env.clone()), ) } else { v1_rt::concat( v1_rt::concat( "compile_error!(\"unhandled item: ".to_string(), - item_text, + item_text.clone(), ), "\");".to_string(), ) @@ -7612,7 +7658,7 @@ pub fn needs_box_wrapping( } } else { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional.clone() { + if is_optional { { let __tco_0 = with_required_cardinality(n); n = __tco_0; @@ -7689,7 +7735,7 @@ pub fn is_function_type_param(param: Rc) -> bool { { let type_expr = param_node_type_expr(param.clone()); let type_expr_is_var = match type_expr.inferred.clone() { - Some(inf) => is_type_variable(inf), + Some(inf) => is_type_variable(inf.clone()), None => false, }; let same_source_span = (((param.span.clone().file.clone() @@ -7734,7 +7780,7 @@ pub fn function_type_params_have_collision(type_params: Rc>>) -> bo } __result }); - ((names.clone().len() as i64) > (unique_strings(names).len() as i64)) + ((names.clone().len() as i64) > (unique_strings(names.clone()).len() as i64)) } } @@ -7763,7 +7809,7 @@ pub fn emit_type_def_from_connective( __result }); emit_struct_from_children( - item_text, + item_text.clone(), type_params, generic_param_names, item.children.clone(), @@ -7796,7 +7842,7 @@ pub fn emit_type_def_from_connective( rust_visibility_prefix(), "type ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), @@ -7826,9 +7872,9 @@ pub fn emit_type_def_from_connective( imports, env.source_indices.clone(), ) { - Some(local_policy) => local_policy, + Some(local_policy) => local_policy.clone(), None => { - if all_unit_variants { + if all_unit_variants.clone() { match wire_contract_item.clone() { Some(_) => resolve_wire_serde_policy_for_coproduct( wire_contract_item.clone(), @@ -7848,18 +7894,18 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), ); let policy_validation = match serde_policy.error_message.clone() { - Some(message) => emit_rust_compile_error_item(message), + Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; let validations = if (policy_validation.clone() == "".to_string()) { - rename_validations + rename_validations.clone() } else { if (rename_validations.clone() == "".to_string()) { - policy_validation + policy_validation.clone() } else { v1_rt::concat( - v1_rt::concat(policy_validation, "\n".to_string()), - rename_validations, + v1_rt::concat(policy_validation.clone(), "\n".to_string()), + rename_validations.clone(), ) } }; @@ -7872,20 +7918,23 @@ pub fn emit_type_def_from_connective( __result }); let enum_text = emit_enum_from_children( - item_text, + item_text.clone(), type_params, generic_param_names, item.children.clone(), recursive_types, shared_types, env.clone(), - serde_policy, + serde_policy.clone(), emit_info.clone(), ); if (validations.clone() == "".to_string()) { enum_text } else { - v1_rt::concat(v1_rt::concat(validations, "\n".to_string()), enum_text) + v1_rt::concat( + v1_rt::concat(validations.clone(), "\n".to_string()), + enum_text, + ) } } } @@ -7971,10 +8020,13 @@ pub fn rust_phantom_marker_inner(unused: Rc>) -> String { __result }); if ((pascal_unused.clone().len() as i64) == 1) { - pascal_unused.join(&", ".to_string()) + pascal_unused.clone().join(&", ".to_string()) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), pascal_unused.join(&", ".to_string())), + v1_rt::concat( + "(".to_string(), + pascal_unused.clone().join(&", ".to_string()), + ), ")".to_string(), ) } @@ -8076,7 +8128,7 @@ pub fn emit_struct_from_children( ), ": std::marker::PhantomData<".to_string(), ), - rust_phantom_marker_inner(unused_params), + rust_phantom_marker_inner(unused_params.clone()), ), ">,".to_string(), )]), @@ -8143,19 +8195,19 @@ pub fn render_rust_type_with_applied_binding( if (outer_name.clone() != applied_name) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types.clone(), ) } else { if v1_rt::set_contains(&shared_types, outer_name.clone()) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types.clone(), ) } else { render_rust_applied_type_shared( - applied, + applied.clone(), Rc::new(vec![]), shared_types.clone(), corpus_repr.clone(), @@ -8189,7 +8241,7 @@ pub fn render_rust_type_with_applied_binding( } } else { render_rust_applied_type_shared( - applied, + applied.clone(), Rc::new(vec![]), shared_types.clone(), corpus_repr.clone(), @@ -8276,7 +8328,7 @@ pub fn render_rust_field_type_with_applied_binding( ) != None) { render_rust_type_with_applied_binding( - authored_type, + authored_type.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -8286,7 +8338,7 @@ pub fn render_rust_field_type_with_applied_binding( && ((authored_type.children.clone().len() as i64) > 0)) { render_rust_type( - authored_type, + authored_type.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -8348,7 +8400,7 @@ pub fn emit_struct_field_from_child( ) != None) { render_rust_type_with_applied_binding( - authored_child_type, + authored_child_type.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -8403,7 +8455,7 @@ pub fn emit_struct_field_from_child( ">".to_string(), ); render_rust_shared_type_if_needed( - rt_child_name, + rt_child_name.clone(), with_params, shared_types.clone(), ) @@ -8449,20 +8501,20 @@ pub fn emit_struct_field_from_child( env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), generic_ty), + v1_rt::concat("Box<".to_string(), generic_ty.clone()), ">".to_string(), ) } else { if (((rt_child.return_cardinality.clone() != Cardinality::CardOptional) && v1_rt::set_contains( &shared_types, - authored_name_at(env.source_indices.clone(), rt_child), + authored_name_at(env.source_indices.clone(), rt_child.clone()), )) && !rust_type_is_rc_wrapped(generic_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, generic_ty) + wrap_shared_type(RenderTarget::Rust, generic_ty.clone()) } else { - generic_ty + generic_ty.clone() } }; let rename_attr = match Rc::new({ @@ -8479,12 +8531,12 @@ pub fn emit_struct_field_from_child( .first() .cloned() { - Some(prop) => match (*field_init_node_value(prop).expr_data.clone()).clone() { - ExprData::ExprLiteral { value: lv, .. } => match (*lv).clone() { + Some(prop) => match (*field_init_node_value(prop.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { LiteralValue::LitStr { value: key, .. } => v1_rt::concat( v1_rt::concat( " ".to_string(), - apply_type_template1(rust_serde_rename_template_text(), key), + apply_type_template1(rust_serde_rename_template_text(), key.clone()), ), "\n".to_string(), ), @@ -8519,7 +8571,7 @@ pub fn emit_rust_field_definition( v1_rt::concat( v1_rt::concat( v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake, + snake.clone(), ), "\")]\n".to_string(), ) @@ -8537,7 +8589,7 @@ pub fn emit_rust_field_definition( ), visibility, ), - emitted, + emitted.clone(), ), ": ".to_string(), ), @@ -8642,7 +8694,10 @@ pub fn emit_enum_from_children( if (accessor_impl.clone() == "".to_string()) { enum_def } else { - v1_rt::concat(v1_rt::concat(enum_def, "\n".to_string()), accessor_impl) + v1_rt::concat( + v1_rt::concat(enum_def, "\n".to_string()), + accessor_impl.clone(), + ) } } } @@ -8741,7 +8796,7 @@ pub fn emit_enum_shared_accessors( let first_fielded = fielded.clone().first().cloned().clone().unwrap(); let shared = Rc::new({ let mut __result = Vec::new(); - for fname in all_shared.iter().cloned() { + for fname in all_shared.clone().iter().cloned() { if { let types = Rc::new({ let mut __result = Vec::new(); @@ -8800,7 +8855,7 @@ pub fn emit_enum_shared_accessors( } let accessor_fns = Rc::new({ let mut __result = Vec::new(); - for fname in shared.iter().cloned() { + for fname in shared.clone().iter().cloned() { __result.push({ let ty = match Rc::new({ let mut __result = Vec::new(); @@ -9037,20 +9092,22 @@ pub fn wire_variant_tag_for_policy( } else { match policy.rename_style.clone() { Some(style) => { - if (style == "StripAffixAndSnakeCase".to_string()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { + Some(prefix) => match string_without_prefix(authored, prefix.clone()) { Some(stripped) => stripped.clone(), None => return None, }, None => authored, }; let without_suffix = match policy.rename_suffix.clone() { - Some(suffix) => match string_without_suffix(without_prefix, suffix) { - Some(stripped) => stripped, - None => return None, - }, + Some(suffix) => { + match string_without_suffix(without_prefix, suffix.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + } + } None => without_prefix, }; Some(to_snake(without_suffix)) @@ -9085,13 +9142,17 @@ pub fn policy_serde_tag_field(policy: Rc) -> Option { let needle = "tag = \"".to_string(); match string_index_of(policy.enum_attr.clone(), needle.clone()) { Some(start) => { - let after = (start + v1_rt::string_length(&needle)); + let after = (start.clone() + v1_rt::string_length(&needle)); match string_index_of_from( policy.enum_attr.clone(), "\"".to_string(), after.clone(), ) { - Some(end) => Some(v1_rt::substring(&policy.enum_attr.clone(), after, end)), + Some(end) => Some(v1_rt::substring( + &policy.enum_attr.clone(), + after.clone(), + end.clone(), + )), None => None, } } @@ -9118,9 +9179,9 @@ pub fn wire_variant_rename_attr_for_policy( match wire_variant_tag_for_policy(authored, policy.clone()) { Some(tag) => match policy.rename_style.clone() { Some(style) => { - if (style == "StripAffixAndSnakeCase".to_string()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag.clone()), "\")]\n".to_string(), ) } else { @@ -9139,12 +9200,12 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style == "StripAffixAndSnakeCase".to_string()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { match string_without_prefix(authored.clone(), prefix.clone()) { - Some(stripped) => stripped, + Some(stripped) => stripped.clone(), None => { return emit_rust_compile_error_item(v1_rt::concat( v1_rt::concat( @@ -9152,7 +9213,7 @@ pub fn variant_rename_validation_for_policy( " does not satisfy declared wire rename prefix: " .to_string(), ), - prefix, + prefix.clone(), )) } } @@ -9168,7 +9229,7 @@ pub fn variant_rename_validation_for_policy( v1_rt::concat("variant ".to_string(), authored.clone()), " does not satisfy declared wire rename suffix: ".to_string(), ), - suffix, + suffix.clone(), )), }, None => "".to_string(), @@ -9221,12 +9282,12 @@ pub fn enum_variant_field_type_node( ) -> Rc { match lookup_type_by_name(env, enum_name) { Some(enum_node) => { - match find_child_named(enum_node, variant_name, source_indices.clone()) { + match find_child_named(enum_node.clone(), variant_name, source_indices.clone()) { Some(variant) => { - match find_child_named(variant, field_name, source_indices.clone()) { + match find_child_named(variant.clone(), field_name, source_indices.clone()) { Some(field) => { if (field.inferred.clone() != None) { - resolved_type(field) + resolved_type(field.clone()) } else { fallback } @@ -9277,7 +9338,12 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type(n.clone(), shared_types, corpus_repr, source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } @@ -9289,7 +9355,7 @@ pub fn variant_is_synthetic_positional_payload( false } else { match fields.clone().first().cloned() { - Some(f) => (field_node_name_at(f, source_indices) == "0".to_string()), + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, } } @@ -9311,7 +9377,10 @@ pub fn emit_variant_from_child( wire_variant_rename_attr_for_policy(child_text.clone(), serde_policy.clone()); if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( - v1_rt::concat(v1_rt::concat(rename_attr, " ".to_string()), child_text), + v1_rt::concat( + v1_rt::concat(rename_attr, " ".to_string()), + child_text.clone(), + ), ",".to_string(), ) } else { @@ -9326,7 +9395,7 @@ pub fn emit_variant_from_child( if tuple_style { match child.children.clone().first().cloned() { Some(f) => { - let fallback = resolved_type(f); + let fallback = resolved_type(f.clone()); let type_node = if positional_payload.clone() { enum_variant_field_type_node( env.clone(), @@ -9339,7 +9408,7 @@ pub fn emit_variant_from_child( } else { fallback }; - let raw_ty = if positional_payload { + let raw_ty = if positional_payload.clone() { render_variant_payload_type( type_node.clone(), shared_types.clone(), @@ -9370,28 +9439,28 @@ pub fn emit_variant_from_child( raw_ty }; let final_ty = if needs_box_wrapping( - type_node, - recursive_types, + type_node.clone(), + recursive_types.clone(), shared_types.clone(), env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), ty), + v1_rt::concat("Box<".to_string(), ty.clone()), ">".to_string(), ) } else { - ty + ty.clone() }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), "(".to_string(), ), - final_ty, + final_ty.clone(), ), "),".to_string(), ) @@ -9399,7 +9468,7 @@ pub fn emit_variant_from_child( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), ",".to_string(), ), @@ -9450,7 +9519,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), " {\n".to_string(), ), @@ -9507,7 +9576,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), " {\n".to_string(), ), @@ -9539,15 +9608,15 @@ pub fn emit_fn_def( None }; if (host_text_op.clone() != None) { - return match host_text_op { - Some(op_fn) => op_fn, + return match host_text_op.clone() { + Some(op_fn) => op_fn.clone(), None => "".to_string(), }; } match rust_host_string_seam_fn_emit(name.clone()) { Some(seam_fn) => { if corpus_repr_is_faithful(emit_info.corpus_repr.clone()) { - seam_fn + seam_fn.clone() } else { "".to_string() } @@ -9597,9 +9666,13 @@ pub fn emit_fn_def( > 0); let needs_clone_bound = (return_is_bare_generic && !body_is_param_ref); let type_params_str = if needs_clone_bound { - emit_type_params_with_clone_bound(type_params, ret_name, si.clone()) + emit_type_params_with_clone_bound( + type_params.clone(), + ret_name.clone(), + si.clone(), + ) } else { - emit_type_params(type_params, si.clone()) + emit_type_params(type_params.clone(), si.clone()) }; let params_str = emit_params( value_params.clone(), @@ -9627,21 +9700,21 @@ pub fn emit_fn_def( let needs_stacker = (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) && (use_tco.clone() == false)); - if use_tco { + if use_tco.clone() { { let tco_params_str = emit_tco_params( value_params.clone(), - generic_param_names, + generic_param_names.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - si, + si.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), name.clone(), - value_params, + value_params.clone(), registry.clone(), body_scope, (depth.clone() + 1), @@ -9683,7 +9756,7 @@ pub fn emit_fn_def( ), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ), @@ -9699,7 +9772,7 @@ pub fn emit_fn_def( body.clone(), registry.clone(), body_scope, - depth, + depth.clone(), shared_types.clone(), emit_info.clone(), needs_stacker, @@ -9893,7 +9966,7 @@ pub fn emit_func_def( let body_str = emit_func_body( body, registry.clone(), - body_scope, + body_scope.clone(), (depth.clone() + 1), shared_types.clone(), emit_info.clone(), @@ -9930,7 +10003,7 @@ pub fn emit_func_def( ), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ), @@ -9966,15 +10039,15 @@ pub fn emit_func_body( let let_line = emit_let_binding(n.clone(), val_str, RenderTarget::Rust); let next_scope = extend_scope( scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { Some(bd) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_func_body( - bd, + bd.clone(), registry.clone(), next_scope, depth.clone(), @@ -10000,14 +10073,14 @@ pub fn emit_func_body( shared_types.clone(), emit_info.clone(), ); - let last_stmt = ss.last().cloned(); + let last_stmt = ss.clone().last().cloned(); let last_str = match last_stmt { Some(s) => match (*s.expr_data.clone()).clone() { ExprData::ExprReturn => v1_rt::concat( v1_rt::concat( "return Ok(".to_string(), emit_typed_expr( - return_value(s), + return_value(s.clone()), registry.clone(), init_state.scope.clone(), depth.clone(), @@ -10022,7 +10095,7 @@ pub fn emit_func_body( v1_rt::concat( "Ok(".to_string(), emit_typed_expr( - s, + s.clone(), registry.clone(), init_state.scope.clone(), depth.clone(), @@ -10126,7 +10199,7 @@ pub fn emit_tco_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored, + authored.clone(), generic_param_names, shared_types, corpus_repr, @@ -10323,7 +10396,7 @@ pub fn emit_rust_param_type( let param_str = param_types.join(&", ".to_string()); let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_rust_fn_sig_type( - rt, + rt.clone(), generic_param_names.clone(), shared_types.clone(), corpus_repr.clone(), @@ -10371,7 +10444,7 @@ pub fn emit_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored, + authored.clone(), generic_param_names, shared_types, corpus_repr, @@ -10443,7 +10516,7 @@ pub fn needs_reference_node( pub fn is_string_lit_pattern(p: Rc) -> bool { match (*p).clone() { - MatchPattern::LitPattern { value: v, .. } => match (*v).clone() { + MatchPattern::LitPattern { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitStr { value: _, .. } => true, _ => false, }, @@ -10479,7 +10552,7 @@ pub fn positional_payload_string_guard(fb_pat: Rc, bind_name: Stri }; v1_rt::concat( v1_rt::concat(bind_name, " == ".to_string()), - emit_string_literal(s, "".to_string()), + emit_string_literal(s.clone(), "".to_string()), ) } _ => "".to_string(), @@ -10548,7 +10621,7 @@ pub fn collect_pattern_string_guards( mut source_indices: Rc>>, ) -> String { loop { - match (*pattern.clone()).clone() { + match (*pattern).clone() { MatchPattern::VariantPattern { name: n, parent_enum: parent, @@ -10602,18 +10675,18 @@ pub fn collect_pattern_string_guards( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), "0".to_string(), ); if is_string_lit_pattern(fb_pat.clone()) { break positional_payload_string_guard( fb_pat.clone(), - pattern_string_binding_name(pos_path.clone()), + pattern_string_binding_name(pos_path), ); } else { { let __tco_0 = fb_pat.clone(); - let __tco_1 = pos_path.clone(); + let __tco_1 = pos_path; pattern = __tco_0; path_prefix = __tco_1; continue; @@ -10622,7 +10695,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), source_indices.clone(), ); } @@ -10634,7 +10707,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), source_indices.clone(), ); } @@ -10711,17 +10784,17 @@ pub fn emit_pattern( emit_info: Rc, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n, RenderTarget::Rust), - MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v), + MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), + MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), MatchPattern::VariantPattern { name: n, parent_enum, field_bindings: fbs, .. } => emit_variant_pattern( - n, - parent_enum, - fbs, + n.clone(), + parent_enum.clone(), + fbs.clone(), path_prefix, shared_types, scrut_type, @@ -10742,7 +10815,7 @@ pub fn pattern_parent_enum( let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { - parent_enum + parent_enum.clone() } else { if scrut_is_known_enum { Some(scrut_type.clone()) @@ -10774,7 +10847,7 @@ pub fn unique_variant_parent( __result }); if ((parent_matches.clone().len() as i64) == 1) { - parent_matches.first().cloned() + parent_matches.clone().first().cloned() } else { None } @@ -10787,7 +10860,7 @@ pub fn is_optional_variant_name(name: String) -> bool { pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent == "Optional".to_string()), + Some(parent) => (parent.clone() == "Optional".to_string()), None => false, } } @@ -10801,23 +10874,23 @@ pub fn positional_payload_scrut_type( ) -> String { { let type_key = match parent_enum { - Some(parent) => variant_summary_key(parent, variant_name), + Some(parent) => variant_summary_key(parent.clone(), variant_name), None => variant_name, }; match lookup_emit_type_summary(emit_info, type_key) { Some(summary) => match v1_rt::map_get(&summary.field_type_map.clone(), "0".to_string()) { - Some(payload_type) => payload_type, + Some(payload_type) => payload_type.clone(), None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - authored_name_at(source_indices, normalize_access_type_node(rt)) + authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } _ => "".to_string(), }, }, None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - authored_name_at(source_indices, normalize_access_type_node(rt)) + authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } _ => "".to_string(), }, @@ -10870,20 +10943,20 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb); + let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { "Some(ref __some_val)".to_string() } else { { let inner_pat = emit_pattern( - fb_pat, - v1_rt::rc_list_push(path_prefix, rust_name), - shared_types, + fb_pat.clone(), + v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), + shared_types.clone(), scrut_type.clone(), source_indices.clone(), emit_info.clone(), @@ -10895,7 +10968,7 @@ pub fn emit_variant_pattern( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -10907,38 +10980,38 @@ pub fn emit_variant_pattern( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(ref ".to_string()), - bind_name, + v1_rt::concat(qualified.clone(), "(ref ".to_string()), + bind_name.clone(), ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent, + resolved_parent.clone(), name.clone(), - fb, + fb.clone(), emit_info.clone(), source_indices.clone(), ); let inner_pat = emit_pattern( - fb_pat, - pos_path, - shared_types, + fb_pat.clone(), + pos_path.clone(), + shared_types.clone(), payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(".to_string()), + v1_rt::concat(qualified.clone(), "(".to_string()), inner_pat, ), ")".to_string(), @@ -10950,18 +11023,24 @@ pub fn emit_variant_pattern( { let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let fb_pat = field_binding_pattern(fb); + let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), - fb_name, + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), )); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - bind_name, + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + bind_name.clone(), ), ", .. }".to_string(), ) @@ -10969,25 +11048,31 @@ pub fn emit_variant_pattern( } else { { let pat_str = emit_pattern( - fb_pat, + fb_pat.clone(), v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), fb_name.clone(), ), - shared_types, + shared_types.clone(), "".to_string(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident(fb_name, RenderTarget::Rust), + emit_ident( + fb_name.clone(), + RenderTarget::Rust, + ), ": ".to_string(), ), - pat_str, + pat_str.clone(), ), ), ", .. }".to_string(), @@ -10997,15 +11082,16 @@ pub fn emit_variant_pattern( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent { - Some(parent) => { - v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) - } + let shape_key = match resolved_parent.clone() { + Some(parent) => v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ), None => name.clone(), }; let is_positional = (v1_rt::set_contains( @@ -11015,19 +11101,20 @@ pub fn emit_variant_pattern( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = - (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) - || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = (v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + shape_key.clone(), + ) || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11047,9 +11134,9 @@ pub fn emit_variant_pattern( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent { + let shape_key2 = match resolved_parent.clone() { Some(parent) => v1_rt::concat( - v1_rt::concat(parent, "::".to_string()), + v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), ), None => name.clone(), @@ -11063,18 +11150,18 @@ pub fn emit_variant_pattern( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2, + shape_key2.clone(), ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11082,7 +11169,7 @@ pub fn emit_variant_pattern( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.iter().cloned() { + for fb in effective_bindings.clone().iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11181,7 +11268,7 @@ pub fn emit_variant_pattern( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11247,18 +11334,18 @@ pub fn analyze_rc_pattern( } => { if (is_optional_variant_name(n.clone()) && is_optional_parent(parent_enum.clone())) { if ((fbs.clone().len() as i64) == 1) { - match fbs.first().cloned() { + match fbs.clone().first().cloned() { Some(fb) => { let inner = analyze_rc_pattern( - field_binding_pattern(fb), + field_binding_pattern(fb.clone()), "".to_string(), shared_types.clone(), emit_info.clone(), - source_indices, + source_indices.clone(), ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n == "Present".to_string()) + matches_option_rc_variant: ((n.clone() == "Present".to_string()) && inner.matches_rc_variant.clone()), needs_rc_pattern: inner.needs_rc_pattern.clone(), ref_bound_fields: Rc::new(vec![]), @@ -11273,17 +11360,17 @@ pub fn analyze_rc_pattern( { let resolved_parent = pattern_parent_enum( n.clone(), - parent_enum, + parent_enum.clone(), scrut_type, emit_info.type_summaries.clone(), ); let matches_rc_variant = match resolved_parent.clone() { - Some(enum_name) => v1_rt::set_contains(&shared_types, enum_name), + Some(enum_name) => v1_rt::set_contains(&shared_types, enum_name.clone()), None => false, }; let ref_bound_fields = Rc::new({ let mut __result = Vec::new(); - for fb in fbs.iter().cloned() { + for fb in fbs.clone().iter().cloned() { __result.extend( (*{ let fb_name = @@ -11324,7 +11411,7 @@ pub fn analyze_rc_pattern( matches_rc_variant: matches_rc_variant, matches_option_rc_variant: false, needs_rc_pattern: ((ref_bound_fields.clone().len() as i64) > 0), - ref_bound_fields: ref_bound_fields, + ref_bound_fields: ref_bound_fields.clone(), }) } } @@ -11364,7 +11451,10 @@ pub fn analyze_rc_match( let scrutinee_is_rc_wrapped = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if (((rt.children.clone().len() as i64) == 0) && (rt.ident_span.clone() != None)) { - v1_rt::set_contains(&shared_types, authored_name_at(source_indices.clone(), rt)) + v1_rt::set_contains( + &shared_types, + authored_name_at(source_indices.clone(), rt.clone()), + ) } else { false } @@ -11383,7 +11473,7 @@ pub fn analyze_rc_match( }; let arms_want_deref = { let mut __found = false; - for a in arm_analyses.iter().cloned() { + for a in arm_analyses.clone().iter().cloned() { if a.matches_rc_variant.clone() { __found = true; break; @@ -11412,17 +11502,17 @@ pub fn emit_pattern_rc_aware( emit_info: Rc, ) -> String { match (*pattern).clone() { - MatchPattern::Bind { name: n, .. } => emit_ident(n, RenderTarget::Rust), - MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v), + MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), + MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), MatchPattern::VariantPattern { name: n, parent_enum, field_bindings: fbs, .. } => emit_variant_pattern_rc_aware( - n, - parent_enum, - fbs, + n.clone(), + parent_enum.clone(), + fbs.clone(), path_prefix, rc_analysis, shared_types, @@ -11480,12 +11570,12 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb); + let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { "Some(ref __some_val)".to_string() } else { @@ -11498,9 +11588,9 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat, - v1_rt::rc_list_push(path_prefix, rust_name), - inner_analysis, + fb_pat.clone(), + v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), + inner_analysis.clone(), shared_types.clone(), scrut_type.clone(), source_indices.clone(), @@ -11513,7 +11603,7 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -11525,24 +11615,24 @@ pub fn emit_variant_pattern_rc_aware( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(ref ".to_string()), - bind_name, + v1_rt::concat(qualified.clone(), "(ref ".to_string()), + bind_name.clone(), ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent, + resolved_parent.clone(), name.clone(), - fb, + fb.clone(), emit_info.clone(), source_indices.clone(), ); @@ -11554,17 +11644,17 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat, - pos_path, - inner_analysis, + fb_pat.clone(), + pos_path.clone(), + inner_analysis.clone(), shared_types.clone(), - payload_scrut, + payload_scrut.clone(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(".to_string()), + v1_rt::concat(qualified.clone(), "(".to_string()), inner_pat, ), ")".to_string(), @@ -11576,28 +11666,37 @@ pub fn emit_variant_pattern_rc_aware( { let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let fb_pat = field_binding_pattern(fb); + let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), - fb_name, + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), )); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - bind_name, + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + bind_name.clone(), ), ", .. }".to_string(), ) } } else { - if field_needs_rc_ref(fb_name.clone(), rc_analysis) { + if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - emit_ident(fb_name, RenderTarget::Rust), + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + emit_ident(fb_name.clone(), RenderTarget::Rust), ), ", .. }".to_string(), ) @@ -11611,12 +11710,15 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let pat_str = emit_pattern_rc_aware( - fb_pat, + fb_pat.clone(), v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), fb_name.clone(), ), - inner_analysis, + inner_analysis.clone(), shared_types.clone(), "".to_string(), source_indices.clone(), @@ -11624,13 +11726,19 @@ pub fn emit_variant_pattern_rc_aware( ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat( + qualified.clone(), + " { ".to_string(), + ), v1_rt::concat( v1_rt::concat( - emit_ident(fb_name, RenderTarget::Rust), + emit_ident( + fb_name.clone(), + RenderTarget::Rust, + ), ": ".to_string(), ), - pat_str, + pat_str.clone(), ), ), ", .. }".to_string(), @@ -11641,15 +11749,16 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent { - Some(parent) => { - v1_rt::concat(v1_rt::concat(parent, "::".to_string()), name.clone()) - } + let shape_key = match resolved_parent.clone() { + Some(parent) => v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ), None => name.clone(), }; let is_positional = (v1_rt::set_contains( @@ -11659,19 +11768,20 @@ pub fn emit_variant_pattern_rc_aware( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = - (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) - || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = (v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + shape_key.clone(), + ) || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11691,9 +11801,9 @@ pub fn emit_variant_pattern_rc_aware( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent { + let shape_key2 = match resolved_parent.clone() { Some(parent) => v1_rt::concat( - v1_rt::concat(parent, "::".to_string()), + v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), ), None => name.clone(), @@ -11707,18 +11817,18 @@ pub fn emit_variant_pattern_rc_aware( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2, + shape_key2.clone(), ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11726,7 +11836,7 @@ pub fn emit_variant_pattern_rc_aware( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.iter().cloned() { + for fb in effective_bindings.clone().iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11849,7 +11959,7 @@ pub fn emit_variant_pattern_rc_aware( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11879,9 +11989,9 @@ pub fn rc_pattern_preludes( } => { if (is_optional_variant_name(n.clone()) && is_optional_parent(parent_enum.clone())) { if ((fbs.clone().len() as i64) == 1) { - match fbs.first().cloned() { + match fbs.clone().first().cloned() { Some(fb) => { - let fb_pat = field_binding_pattern(fb); + let fb_pat = field_binding_pattern(fb.clone()); let inner_analysis = analyze_rc_pattern( fb_pat.clone(), "".to_string(), @@ -11890,8 +12000,8 @@ pub fn rc_pattern_preludes( source_indices.clone(), ); rc_pattern_preludes( - fb_pat, - inner_analysis, + fb_pat.clone(), + inner_analysis.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -11906,13 +12016,13 @@ pub fn rc_pattern_preludes( { let resolved_parent = pattern_parent_enum( n.clone(), - parent_enum, + parent_enum.clone(), "".to_string(), emit_info.type_summaries.clone(), ); let preludes = Rc::new({ let mut __result = Vec::new(); - for fb in fbs.iter().cloned() { + for fb in fbs.clone().iter().cloned() { __result.extend( (*{ let fb_name = @@ -12011,7 +12121,7 @@ pub fn explicit_record_struct_name( let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { - Some(base) => base, + Some(base) => base.clone(), None => inferred_node.clone(), } } else { @@ -12026,27 +12136,27 @@ pub fn explicit_record_struct_name( }; let nname = authored_name_at(source_indices, n.clone()); if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { - type_name + type_name.clone() } else { if n_is_error { - type_name + type_name.clone() } else { if is_product { if (n.ident_span.clone() == None) { - type_name + type_name.clone() } else { - Some(nname) + Some(nname.clone()) } } else { if is_coproduct { - type_name + type_name.clone() } else { if (((n.children.clone().len() as i64) == 0) && (n.ident_span.clone() != None)) { - Some(nname) + Some(nname.clone()) } else { - type_name + type_name.clone() } } } @@ -12069,7 +12179,7 @@ pub fn variant_parent_from_binding_kind( Some(VarBindingKind::VariantValueBinding { parent_enum: parent_enum, .. - }) => Some(parent_enum), + }) => Some(parent_enum.clone()), _ => None, } } @@ -12111,7 +12221,7 @@ pub fn effective_variant_parent( let cached = match v1_rt::map_get(&emit_info.variant_to_enum.clone(), name.clone()) { Some(p) => { if (p.clone() != "".to_string()) { - Some(p) + Some(p.clone()) } else { None } @@ -12119,7 +12229,7 @@ pub fn effective_variant_parent( None => None, }; match cached { - Some(parent) => Some(parent), + Some(parent) => Some(parent.clone()), None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); @@ -12130,7 +12240,7 @@ pub fn effective_variant_parent( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { variant_parent_from_binding_kind(binding_kind) } @@ -12161,7 +12271,8 @@ pub fn move_licensed_at_site(emit_info: Rc, name: String, use_spa move_site_key(name.clone(), use_span.clone()), ) { Some(v) => { - (v && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + (v.clone() + && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) } None => false, } @@ -12221,7 +12332,7 @@ pub fn emit_var_ref( }; if variant_ref_self_wraps( name.clone(), - enum_name, + enum_name.clone(), shared_types, emit_info.corpus_repr.clone(), ) { @@ -12307,15 +12418,15 @@ pub fn emit_typed_expr_base( emit_keyword("null".to_string(), RenderTarget::Rust) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n, RenderTarget::Rust) + emit_keyword(n.clone(), RenderTarget::Rust) } else { { let variant_parent = effective_variant_parent( n.clone(), - binding_kind, + binding_kind.clone(), texpr.inferred.clone(), emit_info.clone(), - si, + si.clone(), ); match variant_parent { Some(enum_name) => { @@ -12329,7 +12440,7 @@ pub fn emit_typed_expr_base( let qualified = if (is_optional_variant_name(n.clone()) && (enum_name.clone() == "Optional".to_string())) { - if (n == "Present".to_string()) { + if (n.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -12340,10 +12451,11 @@ pub fn emit_typed_expr_base( enum_name.clone(), "::".to_string(), ), - n, + n.clone(), ) }; - if v1_rt::set_contains(&shared_types, enum_name) { + if v1_rt::set_contains(&shared_types, enum_name.clone()) + { v1_rt::concat( v1_rt::concat( "Rc::new(".to_string(), @@ -12361,12 +12473,12 @@ pub fn emit_typed_expr_base( Some(info) => { let is_data = (info.kind.clone() == ItemKind::DataItem); if is_data { - v1_rt::concat(to_snake(n), "()".to_string()) + v1_rt::concat(to_snake(n.clone()), "()".to_string()) } else { - emit_ident(n, RenderTarget::Rust) + emit_ident(n.clone(), RenderTarget::Rust) } } - None => emit_ident(n, RenderTarget::Rust), + None => emit_ident(n.clone(), RenderTarget::Rust), }, } } @@ -12405,7 +12517,7 @@ pub fn field_access_field_is_boxed( (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { - let field_ty = resolved_type(field_child); + let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), @@ -12424,12 +12536,15 @@ pub fn field_access_field_is_boxed( || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); ((faithful_nat_field || needs_box_wrapping( - field_ty, + field_ty.clone(), emit_info.recursive_type_set.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), )) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name)) + || is_recursive_type_by_name( + scope.type_env.clone(), + field_ty_name.clone(), + )) } } } @@ -12637,13 +12752,13 @@ pub fn type_needs_rc_seen( mut source_indices: Rc>>, ) -> bool { loop { - let normed = normalize_access_type_node(type_node.clone()); + let normed = normalize_access_type_node(type_node); let is_product = is_product_type(normed.clone()); let is_coproduct = is_coproduct_type(normed.clone()); - if is_product.clone() { + if is_product { break true; } else { - if is_coproduct.clone() { + if is_coproduct { break { let mut __found = false; for child in normed.children.clone().iter().cloned() { @@ -12664,7 +12779,7 @@ pub fn type_needs_rc_seen( }; { let __tco_0 = resolved_type(normed.clone()); - let __tco_1 = next_seen.clone(); + let __tco_1 = next_seen; type_node = __tco_0; seen = __tco_1; continue; @@ -12681,13 +12796,12 @@ pub fn type_needs_rc_seen( v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; let has_structure = (normed.connective.clone() != Connective::NoConnective); - if (!has_structure.clone() && ((normed.children.clone().len() as i64) == 0)) - { + if (!has_structure && ((normed.children.clone().len() as i64) == 0)) { break false; } else { { let __tco_0 = normed.clone(); - let __tco_1 = next_seen.clone(); + let __tco_1 = next_seen; type_node = __tco_0; seen = __tco_1; continue; @@ -12706,8 +12820,8 @@ pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> bool pub fn rust_runtime_bridge_name(function_name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), function_name.clone()) { - Some(runtime_name) => runtime_name, - None => function_name, + Some(runtime_name) => runtime_name.clone(), + None => function_name.clone(), } } @@ -12720,7 +12834,7 @@ pub fn rust_empty_map_value_type_str( match map_type.children.clone().get(1 as usize).cloned() { Some(value_child) => { let rendered = render_rust_type( - child_type_node(value_child), + child_type_node(value_child.clone()), shared_types, corpus_repr, source_indices, @@ -12728,7 +12842,7 @@ pub fn rust_empty_map_value_type_str( if (rendered.clone() == "".to_string()) { "".to_string() } else { - rendered + rendered.clone() } } None => "".to_string(), @@ -12744,7 +12858,7 @@ pub fn rust_empty_map_kv_type_str( { let key_str = match map_type.children.clone().first().cloned() { Some(key_child) => render_rust_type( - child_type_node(key_child), + child_type_node(key_child.clone()), shared_types.clone(), corpus_repr.clone(), source_indices.clone(), @@ -12758,7 +12872,10 @@ pub fn rust_empty_map_kv_type_str( source_indices.clone(), ); if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { - v1_rt::concat(v1_rt::concat(key_str, ", ".to_string()), val_str) + v1_rt::concat( + v1_rt::concat(key_str.clone(), ", ".to_string()), + val_str.clone(), + ) } else { "".to_string() } @@ -12787,7 +12904,7 @@ pub fn rust_btree_set_element_ord_eligible( || (elem_name.clone() == "Bool".to_string())) || (elem_name.clone() == "Unit".to_string())) || (elem_name.clone() == "Secret".to_string())) - || (elem_name == "Bytes".to_string())) + || (elem_name.clone() == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12799,7 +12916,7 @@ pub fn rust_empty_set_element_type_str( ) -> String { match set_type.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child); + let elem_node = child_type_node(elem_child.clone()); let elem_is_type_var = if (elem_node.inferred.clone() != None) { is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { @@ -12817,7 +12934,7 @@ pub fn rust_empty_set_element_type_str( "".to_string() } else { render_node_type( - elem_node, + elem_node.clone(), RenderTarget::Rust, shared_types, source_indices.clone(), @@ -12836,7 +12953,7 @@ pub fn emit_rust_empty_set_expr( ) -> String { match set_type.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child); + let elem_node = child_type_node(elem_child.clone()); let elem_is_type_var = if (elem_node.inferred.clone() != None) { is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { @@ -12847,7 +12964,7 @@ pub fn emit_rust_empty_set_expr( } else { if !rust_btree_set_element_ord_eligible(elem_node.clone(), source_indices.clone()) { { - let elem_name = authored_name_at(source_indices.clone(), elem_node); + let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("empty_set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -12862,7 +12979,10 @@ pub fn emit_rust_empty_set_expr( ); if (elem_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat("v1_rt::rc_empty_set::<".to_string(), elem_str), + v1_rt::concat( + "v1_rt::rc_empty_set::<".to_string(), + elem_str.clone(), + ), ">()".to_string(), ) } else { @@ -12928,7 +13048,7 @@ pub fn emit_rust_expr_var( let n = expr_var_name_at(expr.clone(), source_indices.clone()); emit_var_ref( n, - binding_kind, + binding_kind.clone(), expr.inferred.clone(), expr.span.clone().start.clone(), shared_types, @@ -12968,11 +13088,11 @@ pub fn emit_rust_expr_field_access( expr.clone(), (*scope.type_env).clone().source_indices.clone(), ) { - Some(svc_name) => service_var_name(svc_name), + Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( b, f, - summary, + summary.clone(), registry, scope.clone(), depth, @@ -12984,7 +13104,7 @@ pub fn emit_rust_expr_field_access( emit_typed_field_access( b, f, - summary, + summary.clone(), registry, scope.clone(), depth, @@ -13058,7 +13178,7 @@ pub fn emit_rust_expr_method_call( m, a, expr.inferred.clone(), - method_semantics, + method_semantics.clone(), registry, scope.clone(), depth, @@ -13176,7 +13296,7 @@ pub fn emit_rust_expr_record_lit( scope.module_name.clone(), ); let variant_name = match tn.clone() { - Some(n) => n, + Some(n) => n.clone(), None => "".to_string(), }; let peeled_type_name = if (((parent_enum.clone() == None) @@ -13188,13 +13308,13 @@ pub fn emit_rust_expr_record_lit( if ((concrete.clone() != "".to_string()) && (concrete.clone() != variant_name.clone())) { - Some(concrete) + Some(concrete.clone()) } else { - tn + tn.clone() } } } else { - tn + tn.clone() }; let raw = emit_typed_record_lit( peeled_type_name, @@ -13208,30 +13328,31 @@ pub fn emit_rust_expr_record_lit( emit_info.clone(), ); let rc_name = match parent_enum.clone() { - Some(en) => en, + Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), - parent_enum, + parent_enum.clone(), expanded_rt.clone(), emit_info.clone(), si.clone(), ) { - Some(p) => p, + Some(p) => p.clone(), None => { - let expanded_name = authored_name_at(si, expanded_rt.clone()); + let expanded_name = authored_name_at(si.clone(), expanded_rt.clone()); if ((((expanded_rt.ident_span.clone() != None) && (expanded_name.clone() != "".to_string())) && (expanded_name.clone() != variant_name.clone())) && v1_rt::set_contains(&shared_types, expanded_name.clone())) { - expanded_name + expanded_name.clone() } else { - variant_name + variant_name.clone() } } }, }; - if ((rc_name.clone() != "".to_string()) && v1_rt::set_contains(&shared_types, rc_name)) + if ((rc_name.clone() != "".to_string()) + && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -13431,8 +13552,8 @@ pub fn emit_rust_expr_bin_op( algebra_field: algebra, .. } => emit_typed_bin_op( - op, - algebra, + op.clone(), + algebra.clone(), binop_left(expr.clone()), binop_right(expr.clone()), registry, @@ -13659,7 +13780,7 @@ pub fn contextual_variant_parent( variant_name.clone(), explicit_parent.clone(), ) { - Some(explicit_parent) + Some(explicit_parent.clone()) } else { None } @@ -13674,7 +13795,7 @@ pub fn contextual_variant_parent( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { None } @@ -13687,7 +13808,9 @@ pub fn is_map_typed_expr( source_indices: Rc>>, ) -> bool { match texpr.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: n, .. }) => node_is_keyed_collection(n, source_indices), + Some(InferredNode::Resolved { node: n, .. }) => { + node_is_keyed_collection(n.clone(), source_indices) + } _ => false, } } @@ -13711,7 +13834,10 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name(arg, (*scope.type_env).clone().source_indices.clone()); + let ty_name = resolved_type_name( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { @@ -13778,7 +13904,7 @@ pub fn emit_discriminant_call_lowering( } __result }); - let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name) { + let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name.clone()) { v1_rt::concat( v1_rt::concat("&*(".to_string(), scrutinee), ")".to_string(), @@ -13802,13 +13928,19 @@ pub fn emit_discriminant_call_lowering( } } else { emit_rust_host_to_dag_string_via_seam( - v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), + v1_rt::concat( + v1_rt::concat("\"".to_string(), ty_name.clone()), + "\"".to_string(), + ), emit_info.corpus_repr.clone(), ) } } None => emit_rust_host_to_dag_string_via_seam( - v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), + v1_rt::concat( + v1_rt::concat("\"".to_string(), ty_name.clone()), + "\"".to_string(), + ), emit_info.corpus_repr.clone(), ), } @@ -13830,14 +13962,17 @@ pub fn emit_typed_call_expr( match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( - ret_type, + ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat("v1_rt::rc_empty_map::<".to_string(), kv_type_str), + v1_rt::concat( + "v1_rt::rc_empty_map::<".to_string(), + kv_type_str.clone(), + ), ">()".to_string(), ) } else { @@ -13853,7 +13988,7 @@ pub fn emit_typed_call_expr( match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( - ret_type, + ret_type.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), ) @@ -13893,7 +14028,9 @@ pub fn rust_call_arg_fail_closed_unwrap( match callee { Some(info) => match info.params.clone().get(idx.clone() as usize).cloned() { Some(param) => { - let param_required = (param_node_type_expr(param).return_cardinality.clone() + let param_required = (param_node_type_expr(param.clone()) + .return_cardinality + .clone() != Cardinality::CardOptional); let arg_optional = (resolved_type(arg).return_cardinality.clone() == Cardinality::CardOptional); @@ -13923,12 +14060,12 @@ pub fn emit_typed_call( { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); - let get_idx = get_args.get(1 as usize).cloned(); + let get_idx = get_args.clone().get(1 as usize).cloned(); let get_result = match get_list { Some(list_arg) => match get_idx { Some(idx_arg) => { let list_str = emit_typed_expr( - arg_value(list_arg), + arg_value(list_arg.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -13937,7 +14074,7 @@ pub fn emit_typed_call( 1024, ); let index_str = emit_typed_expr( - arg_value(idx_arg), + arg_value(idx_arg.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -13973,7 +14110,8 @@ pub fn emit_typed_call( if ((with_args.clone().len() as i64) < 2) { return "compile_error!(\"with call missing update record\")".to_string(); } - let update_arg = arg_value(with_args.get(1 as usize).cloned().clone().unwrap()); + let update_arg = + arg_value(with_args.clone().get(1 as usize).cloned().clone().unwrap()); let base_str = emit_typed_expr( base_arg.clone(), registry.clone(), @@ -13986,7 +14124,7 @@ pub fn emit_typed_call( let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(base_arg), + resolved_type(base_arg.clone()), ) } else { "compile_error!(\"with call missing resolved record type\")".to_string() @@ -14020,7 +14158,7 @@ pub fn emit_typed_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg, + update_arg.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -14040,14 +14178,17 @@ pub fn emit_typed_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), + v1_rt::concat( + v1_rt::concat(type_name.clone(), " { ".to_string()), + fields_str, + ), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc { + if needs_rc.clone() { return v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string(), @@ -14100,7 +14241,7 @@ pub fn emit_typed_call( let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { Some(value_arg) => emit_discriminant_call_lowering( - value_arg, + value_arg.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -14279,7 +14420,7 @@ pub fn emit_typed_call( } else { { let mut __found = false; - for a in filled_args.iter().cloned() { + for a in filled_args.clone().iter().cloned() { if expr_references_var(arg_value(a.clone()), func.clone(), si.clone()) { __found = true; break; @@ -14301,21 +14442,21 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt && (func.clone() == "concat".to_string())) + let call_str = if ((is_rt.clone() && (func.clone() == "concat".to_string())) && ((all_args.clone().len() as i64) > 2)) { - emit_nested_rt_concat(all_args, "".to_string(), shared_types.clone()) + emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) } else { v1_rt::concat( v1_rt::concat(v1_rt::concat(func_name, "(".to_string()), args_str), ")".to_string(), ) }; - match callee { + match callee.clone() { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects { + if has_effects.clone() { v1_rt::concat(call_str, ".await?".to_string()) } else { call_str @@ -14498,7 +14639,7 @@ pub fn emit_nested_rt_concat( .skip(1 as usize) .collect::>(), ); - let __tco_1 = next_acc.clone(); + let __tco_1 = next_acc; remaining = __tco_0; acc = __tco_1; continue; @@ -14552,7 +14693,7 @@ pub fn emit_typed_for_each( let ind2 = make_indent((depth.clone() + 2)); let ind0 = make_indent(depth.clone()); let iter_str = apply_type_template1(sharing.iter_owned.clone(), coll_str); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1.clone()), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) } } @@ -14590,7 +14731,10 @@ pub fn emit_typed_index( base_node.clone(), (*scope.type_env).clone().source_indices.clone(), ); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like( + base_node.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { apply_type_template2( spec.indexing.clone().string_index.clone(), base_str, @@ -14652,7 +14796,7 @@ pub fn emit_typed_slice( let base_node = normalize_access_type_node(resolved_type(base.clone())); if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( "unsupported string slice for target".to_string(), RenderTarget::Rust, @@ -14660,7 +14804,7 @@ pub fn emit_typed_slice( } } else { match spec.indexing.clone().list_slice.clone() { - Some(tmpl) => apply_type_template3(tmpl, base_str, start_str, end_str), + Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( "unsupported list slice for target".to_string(), RenderTarget::Rust, @@ -14682,7 +14826,7 @@ pub fn collection_element_type( if __rt_is_container { match rt.children.clone().first().cloned() { Some(elem_child) => { - let elem_node = child_type_node(elem_child); + let elem_node = child_type_node(elem_child.clone()); let elem_is_error = if (elem_node.inferred.clone() != None) { is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { @@ -14697,7 +14841,7 @@ pub fn collection_element_type( "_".to_string() } else { render_rust_type( - elem_node, + elem_node.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -14729,7 +14873,7 @@ pub fn lambda_scope_from_children( ) .iter() .cloned() - .fold(scope, |acc: Rc, pair: (i64, String)| { + .fold(scope.clone(), |acc: Rc, pair: (i64, String)| { let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { @@ -14864,7 +15008,7 @@ pub fn emit_typed_collection_lambda( (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); - let lambda_scope = lambda_scope_from_children(scope.clone(), ps, pn); + let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); let body_str = emit_typed_expr( bd, registry, @@ -14965,8 +15109,8 @@ pub fn emit_typed_fold_lambda( emit_info.clone(), 1024, ); - let acc_name = match ps.first().cloned() { - Some(n) => n, + let acc_name = match ps.clone().first().cloned() { + Some(n) => n.clone(), None => "".to_string(), }; let needs_unwrap = ((acc_name.clone() != "".to_string()) @@ -14985,7 +15129,7 @@ pub fn emit_typed_fold_lambda( ), ":".to_string(), ), - acc_name, + acc_name.clone(), ); v1_rt::concat( v1_rt::concat( @@ -15003,7 +15147,7 @@ pub fn emit_typed_fold_lambda( ), " = v1_rt::take_owned_counted(".to_string(), ), - acc_ident, + acc_ident.clone(), ), ", \"".to_string(), ), @@ -15067,7 +15211,7 @@ pub fn emit_rust_fold_method_call( Some(InferredNode::Resolved { node: method_result_type, .. - }) => Some(method_result_type), + }) => Some(method_result_type.clone()), _ => None, }; let acc_type_node = match fold_accumulator_type { @@ -15119,7 +15263,7 @@ pub fn emit_rust_fold_method_call( (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) - || acc_children_have_unit)); + || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15134,15 +15278,15 @@ pub fn emit_rust_fold_method_call( || is_under_resolved_non_collection) { match contextual_acc_type { - Some(concrete_type) => concrete_type, - None => acc_type, + Some(concrete_type) => concrete_type.clone(), + None => acc_type.clone(), } } else { - acc_type + acc_type.clone() } } None => match contextual_acc_type { - Some(concrete_type) => concrete_type, + Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { if (arg_value(init_arg.clone()).inferred.clone() != None) { @@ -15171,7 +15315,7 @@ pub fn emit_rust_fold_method_call( .first() .cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "".to_string(), }, _ => "".to_string(), @@ -15191,7 +15335,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node, + fold_lambda_node.clone(), (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15208,7 +15352,7 @@ pub fn emit_rust_fold_method_call( variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_set_insert( emit_info.owned_bindings.clone(), - acc_name, + acc_name.clone(), ), move_sites_index: emit_info.move_sites_index.clone(), move_sites: emit_info.move_sites.clone(), @@ -15226,7 +15370,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node, + fold_lambda_node.clone(), (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15239,7 +15383,10 @@ pub fn emit_rust_fold_method_call( .clone(), shared_types: emit_info.shared_types.clone(), ownership_index: emit_info.ownership_index.clone(), - movable: v1_rt::rc_set_insert(emit_info.movable.clone(), acc_name), + movable: v1_rt::rc_set_insert( + emit_info.movable.clone(), + acc_name.clone(), + ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), move_sites_index: emit_info.move_sites_index.clone(), @@ -15279,7 +15426,7 @@ pub fn emit_rust_fold_method_call( __found }; let is_bare_container = (((acc_type_node.children.clone().len() as i64) == 0) - && is_container_type(acc_type_name)); + && is_container_type(acc_type_name.clone())); let lambda_acc_type_str = if ((is_bare_container || acc_type_is_type_var) || acc_child_is_type_var) { "_".to_string() @@ -15328,7 +15475,7 @@ pub fn emit_rust_fold_method_call( { { let kv_type_str = rust_empty_map_kv_type_str( - acc_type_node, + acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15337,7 +15484,7 @@ pub fn emit_rust_fold_method_call( v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), - kv_type_str, + kv_type_str.clone(), ), ">()".to_string(), ) @@ -15351,20 +15498,20 @@ pub fn emit_rust_fold_method_call( } else { if ((((init_func.clone() == "empty_set".to_string()) && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str != "".to_string())) - && !acc_has_unit_child) + && (acc_type_str.clone() != "".to_string())) + && !acc_has_unit_child.clone()) { emit_rust_empty_set_expr( - acc_type_node, + acc_type_node.clone(), shared_types.clone(), (*scope.type_env).clone().source_indices.clone(), ) } else { - if (init_func == "empty_set".to_string()) { + if (init_func.clone() == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( - arg_value(init_arg), + arg_value(init_arg.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -15378,7 +15525,7 @@ pub fn emit_rust_fold_method_call( } } _ => emit_typed_expr( - arg_value(init_arg), + arg_value(init_arg.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -15398,14 +15545,14 @@ pub fn emit_rust_fold_method_call( scope.clone(), depth.clone(), shared_types.clone(), - fold_emit_info, + fold_emit_info.clone(), ), None => "compile_error!(\"missing fold function argument\")".to_string(), }; let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( - arg_value(a), + arg_value(a.clone()), (*scope.type_env).clone().source_indices.clone(), ), None => false, @@ -15446,7 +15593,7 @@ pub fn fold_lambda_element_unused( ExprData::ExprLambda => { let ps = lambda_param_names_at(lambda_expr.clone(), source_indices); match ps.get(1 as usize).cloned() { - Some(elem_name) => (elem_name == "_".to_string()), + Some(elem_name) => (elem_name.clone() == "_".to_string()), None => false, } } @@ -15475,7 +15622,7 @@ pub fn emit_rust_sort_by_method_call( ); let elem_type_str = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let resolved = rt; + let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, (*scope.type_env).clone().source_indices.clone(), @@ -15487,7 +15634,7 @@ pub fn emit_rust_sort_by_method_call( }; if ((elem.ident_span.clone() != None) && !elem_is_type_var) { render_rust_type( - elem, + elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15500,7 +15647,7 @@ pub fn emit_rust_sort_by_method_call( }; let sort_key_fn = match args.first().cloned() { Some(a) => emit_typed_collection_lambda( - arg_value(a), + arg_value(a.clone()), elem_type_str.clone(), registry.clone(), scope.clone(), @@ -15517,7 +15664,7 @@ pub fn emit_rust_sort_by_method_call( if (elem_type_str.clone() == "_".to_string()) { v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a, b| { a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str.clone()), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn.clone()), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } } } @@ -15560,7 +15707,7 @@ pub fn emit_rust_map_method_call( Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15568,15 +15715,15 @@ pub fn emit_rust_map_method_call( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( - arg_value(a) + arg_value(a.clone()) .children .clone() .iter() @@ -15625,7 +15772,7 @@ pub fn emit_rust_map_method_call( ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15633,15 +15780,15 @@ pub fn emit_rust_map_method_call( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( - arg_value(a) + arg_value(a.clone()) .children .clone() .iter() @@ -15723,7 +15870,7 @@ pub fn emit_rust_higher_order_method( Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { ExprData::ExprLambda => { let bd = match arg_value(a.clone()).children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => arg_value(a.clone()), }; let ps = lambda_param_names_at( @@ -15731,15 +15878,15 @@ pub fn emit_rust_higher_order_method( (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "__x".to_string(), }; let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( - arg_value(a) + arg_value(a.clone()) .children .clone() .iter() @@ -15769,7 +15916,7 @@ pub fn emit_rust_higher_order_method( v1_rt::rc_map_insert( seed_bindings("param".to_string(), p), "body".to_string(), - body_str, + body_str.clone(), ), "iter".to_string(), iter_str, @@ -15836,7 +15983,7 @@ pub fn emit_rust_get_method_call( ); let index_str = match args.first().cloned() { Some(a) => emit_typed_expr( - arg_value(a), + arg_value(a.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -15909,7 +16056,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15947,7 +16094,7 @@ pub fn emit_rust_with_method_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg, + update_arg.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -15967,14 +16114,17 @@ pub fn emit_rust_with_method_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), + v1_rt::concat( + v1_rt::concat(type_name.clone(), " { ".to_string()), + fields_str, + ), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc { + if needs_rc.clone() { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16104,7 +16254,7 @@ pub fn emit_rust_generic_method_call( v1_rt::concat("(".to_string(), recv_str), ".".to_string(), ), - emit_ident(function_name, RenderTarget::Rust), + emit_ident(function_name.clone(), RenderTarget::Rust), ), ")(".to_string(), ), @@ -16167,7 +16317,7 @@ pub fn emit_rust_generic_method_call( ), ")".to_string(), ); - if rust_runtime_bridge_wraps_collection_result_in_rc(function_name) { + if rust_runtime_bridge_wraps_collection_result_in_rc(function_name.clone()) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), lowered), ")".to_string(), @@ -16200,7 +16350,7 @@ pub fn emit_typed_method_call( op_params, .. } => { - let var_name = service_var_name(svc_name); + let var_name = service_var_name(svc_name.clone()); let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), @@ -16232,7 +16382,7 @@ pub fn emit_typed_method_call( ); let json_param_set = Rc::new({ let mut __result = Vec::new(); - for p in op_params.iter().cloned() { + for p in op_params.clone().iter().cloned() { if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), @@ -16329,8 +16479,10 @@ pub fn emit_typed_method_call( fold_accumulator_type, .. } => { - let method_name_raw = - authored_name_at((*scope.type_env).clone().source_indices.clone(), method_def); + let method_name_raw = authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + method_def.clone(), + ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), @@ -16341,12 +16493,12 @@ pub fn emit_typed_method_call( "count".to_string() } } else { - method_name_raw + method_name_raw.clone() }; if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( method_call_node, - fold_accumulator_type, + fold_accumulator_type.clone(), result_type, receiver.clone(), args.clone(), @@ -16392,7 +16544,7 @@ pub fn emit_typed_method_call( .cloned() { Some(ho_spec) => emit_rust_higher_order_method( - ho_spec, + ho_spec.clone(), receiver.clone(), args.clone(), registry.clone(), @@ -16531,9 +16683,10 @@ pub fn emit_typed_method_call( first_arg_str, ); let raw = apply_named_template( - tmpl, bindings, + tmpl.clone(), + bindings, ); - if rust_runtime_bridge_wraps_collection_result_in_rc(method_name) { + if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16541,7 +16694,7 @@ pub fn emit_typed_method_call( } None => { emit_rust_generic_method_call( - method_name, + method_name.clone(), receiver.clone(), args.clone(), result_type, @@ -16621,7 +16774,7 @@ pub fn emit_typed_first_arg( ) -> String { match args.first().cloned() { Some(a) => emit_typed_expr( - arg_value(a), + arg_value(a.clone()), registry, scope, depth, @@ -16661,7 +16814,7 @@ pub fn freemonoid_cons_binding( .. } => match Rc::new({ let mut __result = Vec::new(); - for fb in fbs.iter().cloned() { + for fb in fbs.clone().iter().cloned() { if (field_binding_name_at(fb.clone(), source_indices.clone()) == field.clone()) { __result.push(fb); } @@ -16671,8 +16824,8 @@ pub fn freemonoid_cons_binding( .first() .cloned() { - Some(fb) => match (*field_binding_pattern(fb)).clone() { - MatchPattern::Bind { name: nm, .. } => nm, + Some(fb) => match (*field_binding_pattern(fb.clone())).clone() { + MatchPattern::Bind { name: nm, .. } => nm.clone(), _ => "_".to_string(), }, None => "_".to_string(), @@ -16691,14 +16844,14 @@ pub fn arm_resolved_parent_enum( name: n, parent_enum: pe, .. - } => pattern_parent_enum(n, pe, scrut_type, type_summaries), + } => pattern_parent_enum(n.clone(), pe.clone(), scrut_type, type_summaries), _ => None, } } pub fn parent_enum_is_freemonoid(p: Option) -> bool { match p { - Some(nm) => (nm == "FreeMonoid".to_string()), + Some(nm) => (nm.clone() == "FreeMonoid".to_string()), None => false, } } @@ -16723,7 +16876,7 @@ pub fn freemonoid_catchall_arm(arms: Rc>>) -> Option> { pub fn freemonoid_catchall_bind_name(arm: Rc) -> String { match (*arm_pattern(arm)).clone() { - MatchPattern::Bind { name: nm, .. } => nm, + MatchPattern::Bind { name: nm, .. } => nm.clone(), _ => "".to_string(), } } @@ -16744,7 +16897,7 @@ pub fn arms_are_freemonoid_coproduct( }; let empty_is_fm = match freemonoid_match_arm_for(arms.clone(), "Empty".to_string()) { Some(ea) => parent_enum_is_freemonoid(arm_resolved_parent_enum( - ea, + ea.clone(), scrut_type.clone(), type_summaries.clone(), )), @@ -16752,7 +16905,7 @@ pub fn arms_are_freemonoid_coproduct( }; let cons_is_fm = match freemonoid_match_arm_for(arms.clone(), "Cons".to_string()) { Some(ca) => parent_enum_is_freemonoid(arm_resolved_parent_enum( - ca, + ca.clone(), scrut_type.clone(), type_summaries.clone(), )), @@ -16764,7 +16917,7 @@ pub fn arms_are_freemonoid_coproduct( }; let is_fm = (empty_is_fm || cons_is_fm); let empty_fillable = (has_empty || has_catchall.clone()); - let cons_fillable = (has_cons || has_catchall); + let cons_fillable = (has_cons || has_catchall.clone()); ((is_fm && empty_fillable) && cons_fillable) } } @@ -16780,7 +16933,7 @@ pub fn freemonoid_empty_branch_body( ) -> String { match empty_arm { Some(ea) => emit_typed_expr( - arm_body(ea), + arm_body(ea.clone()), registry, scope, depth, @@ -16795,14 +16948,14 @@ pub fn freemonoid_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_expr( - arm_body(wa), + arm_body(wa.clone()), registry, scope, depth, @@ -16835,7 +16988,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind), + v1_rt::concat("let ".to_string(), head_bind.clone()), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -16843,14 +16996,14 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind), + v1_rt::concat("let ".to_string(), tail_bind.clone()), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; v1_rt::concat( v1_rt::concat(head_let, tail_let), emit_typed_expr( - arm_body(ca), + arm_body(ca.clone()), registry, scope, depth, @@ -16867,14 +17020,14 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_expr( - arm_body(wa), + arm_body(wa.clone()), registry, scope, depth, @@ -16914,7 +17067,7 @@ pub fn emit_native_freemonoid_match( ); let nonempty_body = freemonoid_nonempty_branch_body( cons_arm, - catchall, + catchall.clone(), si, registry.clone(), scope.clone(), @@ -16933,11 +17086,11 @@ pub fn emit_native_freemonoid_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body, + empty_body.clone(), ), " } else { ".to_string(), ), - nonempty_body, + nonempty_body.clone(), ), " } }".to_string(), ) @@ -16970,10 +17123,10 @@ pub fn emit_typed_match( if is_optional { authored_name_at( (*scope.type_env).clone().source_indices.clone(), - with_required_cardinality(rt), + with_required_cardinality(rt.clone()), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -16997,7 +17150,7 @@ pub fn emit_typed_match( "".to_string() }; if (native_fm.clone() != "".to_string()) { - return native_fm; + return native_fm.clone(); } let rc_match = analyze_rc_match( scrutinee.clone(), @@ -17008,7 +17161,7 @@ pub fn emit_typed_match( (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { - Some(first_arm) => resolved_type(arm_body(first_arm)), + Some(first_arm) => resolved_type(arm_body(first_arm.clone())), None => type_variable_node("match_result".to_string()), }; let arm_strs = Rc::new({ @@ -17038,7 +17191,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -17058,7 +17211,10 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( "match ".to_string(), - apply_type_template1(sharing.deref_clone.clone(), scrut_str), + apply_type_template1( + sharing.deref_clone.clone(), + scrut_str.clone(), + ), ), " {\n".to_string(), ), @@ -17072,7 +17228,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_str() {\n".to_string(), ), arms_str, @@ -17103,7 +17259,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), sf_arms_str, @@ -17115,7 +17271,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), arms_str, @@ -17158,11 +17314,11 @@ pub fn emit_typed_match_arm( LiteralValue::LitStr { value: s, .. } => v1_rt::concat( v1_rt::concat( "ref __s if __s == \"".to_string(), - escape_string_literal_body(s), + escape_string_literal_body(s.clone()), ), "\"".to_string(), ), - _ => rust_literal_for_pattern(v), + _ => rust_literal_for_pattern(v.clone()), }, _ => emit_pattern( arm_pat.clone(), @@ -17199,7 +17355,7 @@ pub fn emit_typed_match_arm( collect_pattern_string_guards(arm_pat.clone(), Rc::new(vec![]), si.clone()); let arm_guard_str = match arm_g { Some(g) => emit_typed_expr( - g, + g.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -17214,17 +17370,17 @@ pub fn emit_typed_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards), + v1_rt::concat(" if ".to_string(), field_guards.clone()), " && ".to_string(), ), - arm_guard_str, + arm_guard_str.clone(), ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards) + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str) + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() } @@ -17239,7 +17395,7 @@ pub fn emit_typed_match_arm( if (variant_parent_from_binding_kind(body_binding_kind.clone()) != None) { emit_var_ref( body_name, - body_binding_kind, + body_binding_kind.clone(), Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), @@ -17251,7 +17407,7 @@ pub fn emit_typed_match_arm( ) } else { emit_typed_expr( - arm_b, + arm_b.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -17262,7 +17418,7 @@ pub fn emit_typed_match_arm( } } _ => emit_typed_expr( - arm_b, + arm_b.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -17274,10 +17430,10 @@ pub fn emit_typed_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat, - rc_analysis, + arm_pat.clone(), + rc_analysis.clone(), shared_types.clone(), - si, + si.clone(), emit_info.clone(), ); v1_rt::concat( @@ -17424,11 +17580,11 @@ pub fn rust_struct_field_type_node( ) -> Option> { match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( - struct_node, + struct_node.clone(), field_name, (*scope.type_env).clone().source_indices.clone(), ) { - Some(field_node) => Some(resolved_type(field_node)), + Some(field_node) => Some(resolved_type(field_node.clone())), None => None, }, None => None, @@ -17470,7 +17626,7 @@ pub fn rust_record_field_needs_box( ) -> bool { match rust_struct_field_type_node(scope.clone(), struct_name, field_name) { Some(field_type) => needs_box_wrapping( - field_type, + field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), @@ -17523,9 +17679,9 @@ pub fn is_already_optional( let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); - let f = field_access_field_at(texpr.clone(), si); + let f = field_access_field_at(texpr.clone(), si.clone()); match (*texpr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, _ => false, }, @@ -17534,7 +17690,7 @@ pub fn is_already_optional( .. } => { if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) - && (variant_parent_from_binding_kind(binding_kind).as_deref() + && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true @@ -17546,7 +17702,7 @@ pub fn is_already_optional( Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } - _ => match v1_rt::map_get(&scope.locals.clone(), n) { + _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) @@ -17562,9 +17718,9 @@ pub fn is_already_optional( .. } => match tn { Some(name) => { - ((parent.as_deref() == Some("Optional".to_string()).as_deref()) + ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) && ((name.clone() == "Present".to_string()) - || (name == "Absent".to_string()))) + || (name.clone() == "Absent".to_string()))) } None => false, }, @@ -17573,7 +17729,7 @@ pub fn is_already_optional( .. } => { let b = field_access_base(texpr.clone()); - let summary_says_optional = match fa_summary { + let summary_says_optional = match fa_summary.clone() { Some(fs) => match fs.value_shape.clone() { FieldValueShape::OptionalValue => true, _ => false, @@ -17587,7 +17743,7 @@ pub fn is_already_optional( Some(InferredNode::Resolved { node: base_type, .. }) => { - let resolved_base = base_type; + let resolved_base = base_type.clone(); if is_optional_struct_field( emit_info, authored_name_at( @@ -17659,42 +17815,48 @@ pub fn lookup_struct_field_type_name( None => None, }; match direct.clone() { - Some(_) => direct, + Some(_) => direct.clone(), None => match variant_name { - Some(vn) => match find_child_named(struct_node.clone(), vn, source_indices.clone()) - { - Some(variant_child) => match find_child_named( - variant_child, - field_name.clone(), - source_indices.clone(), - ) { - Some(field_child) => { - if (field_child.inferred.clone() != None) { - { - let field_type = resolved_type(field_child); - let ft_is_type_var = if (field_type.inferred.clone() != None) - { - is_type_variable( - field_type.inferred.clone().clone().unwrap(), - ) - } else { - false - }; - if ((field_type.ident_span.clone() != None) && !ft_is_type_var) + Some(vn) => { + match find_child_named(struct_node.clone(), vn.clone(), source_indices.clone()) + { + Some(variant_child) => match find_child_named( + variant_child.clone(), + field_name.clone(), + source_indices.clone(), + ) { + Some(field_child) => { + if (field_child.inferred.clone() != None) { { - Some(authored_name_at(source_indices.clone(), field_type)) - } else { - None + let field_type = resolved_type(field_child.clone()); + let ft_is_type_var = + if (field_type.inferred.clone() != None) { + is_type_variable( + field_type.inferred.clone().clone().unwrap(), + ) + } else { + false + }; + if ((field_type.ident_span.clone() != None) + && !ft_is_type_var.clone()) + { + Some(authored_name_at( + source_indices.clone(), + field_type.clone(), + )) + } else { + None + } } + } else { + None } - } else { - None } - } + None => None, + }, None => None, - }, - None => None, - }, + } + } None => None, }, } @@ -17730,7 +17892,7 @@ pub fn emit_field_value_with_context( (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { - Some(_) => node_lookup, + Some(_) => node_lookup.clone(), None => { if (struct_node.ident_span.clone() != None) { match lookup_emit_type_summary( @@ -17758,15 +17920,15 @@ pub fn emit_field_value_with_context( variant_name.clone(), et.clone(), ) { - Some(et) + Some(et.clone()) } else { - pe + pe.clone() } } - None => pe, + None => pe.clone(), }; let raw = emit_typed_record_lit( - tn, + tn.clone(), inner_fields, corrected_parent.clone(), resolved_type(field_value.clone()), @@ -17776,12 +17938,12 @@ pub fn emit_field_value_with_context( shared_types.clone(), emit_info.clone(), ); - let rc_name = match corrected_parent { - Some(en) => en, - None => variant_name, + let rc_name = match corrected_parent.clone() { + Some(en) => en.clone(), + None => variant_name.clone(), }; if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name)) + && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -17862,7 +18024,7 @@ pub fn find_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) <= 1) { - match candidates.first().cloned() { + match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -17897,13 +18059,13 @@ pub fn find_struct_name_by_fields( __result }); if ((typed_candidates.clone().len() as i64) == 1) { - match typed_candidates.first().cloned() { + match typed_candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } } else { match Rc::new({ - let mut __sorted: Vec<_> = candidates.iter().cloned().collect(); + let mut __sorted: Vec<_> = candidates.clone().iter().cloned().collect(); __sorted.sort_by(|a: &Rc, b: &Rc| { let __ka = (|c: Rc| c.name.clone())(a.clone()); let __kb = (|c: Rc| c.name.clone())(b.clone()); @@ -17930,7 +18092,7 @@ pub fn find_unique_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) == 1) { - match candidates.first().cloned() { + match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -17959,7 +18121,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { - Some(sn) => Some(sn), + Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -17986,7 +18148,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( - field_init_node_value(f), + field_init_node_value(f.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -18032,7 +18194,7 @@ pub fn emit_typed_record_lit( " {\n ".to_string(), ), emit_ident( - fname0, + fname0.clone(), RenderTarget::Rust, ), ), @@ -18042,7 +18204,8 @@ pub fn emit_typed_record_lit( ), ",\n}".to_string(), ); - if v1_rt::set_contains(&shared_types, r_sn) { + if v1_rt::set_contains(&shared_types, r_sn.clone()) + { v1_rt::concat( v1_rt::concat( "Rc::new(".to_string(), @@ -18154,7 +18317,7 @@ pub fn emit_typed_record_lit( ), "\n}".to_string(), ); - if v1_rt::set_contains(&shared_types, resolved_sn) { + if v1_rt::set_contains(&shared_types, resolved_sn.clone()) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), struct_lit), ")".to_string(), @@ -18225,7 +18388,7 @@ pub fn emit_typed_record_lit( ) { Some(canonical) => { if (canonical.clone() != tn.clone()) { - canonical + canonical.clone() } else { tn.clone() } @@ -18247,7 +18410,7 @@ pub fn emit_typed_record_lit( si.clone(), ); let effective_parent = match context_lookup { - Some(context_parent) => Some(context_parent), + Some(context_parent) => Some(context_parent.clone()), None => { let rt_is_type_var = if (resolved_type.inferred.clone() != None) { is_type_variable(resolved_type.inferred.clone().clone().unwrap()) @@ -18265,7 +18428,7 @@ pub fn emit_typed_record_lit( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { parent_enum.clone() } @@ -18362,19 +18525,19 @@ pub fn emit_typed_record_lit( } else { match effective_parent.clone() { Some(resolved_parent_enum) => v1_rt::concat( - v1_rt::concat(resolved_parent_enum, "::".to_string()), + v1_rt::concat(resolved_parent_enum.clone(), "::".to_string()), rust_tn, ), None => ctor_name.clone(), } }; - if ((optional_variant && (tn.clone() == "Present".to_string())) + if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { Some(f) => { let inner = emit_typed_expr( - field_init_node_value(f), + field_init_node_value(f.clone()), registry.clone(), scope.clone(), depth.clone(), @@ -18393,19 +18556,19 @@ pub fn emit_typed_record_lit( if ((fields.clone().len() as i64) == 0) { { let host_freemonoid_carrier = - authored_name_at(si, resolved_type.clone()); + authored_name_at(si.clone(), resolved_type.clone()); match rust_seed_host_freemonoid_empty( host_freemonoid_carrier, emit_info.corpus_repr.clone(), ) { - Some(grounded) => grounded, + Some(grounded) => grounded.clone(), None => v1_rt::concat(display_tn, " {}".to_string()), } } } else { { - let variant_summary_name = match effective_parent { - Some(parent) => variant_summary_key(parent, tn), + let variant_summary_name = match effective_parent.clone() { + Some(parent) => variant_summary_key(parent.clone(), tn.clone()), None => ctor_name.clone(), }; let is_positional_ctor = (((fields.clone().len() as i64) == 1) @@ -18419,7 +18582,7 @@ pub fn emit_typed_record_lit( if is_positional_ctor { match fields.clone().first().cloned() { Some(f) => { - let f_value = field_init_node_value(f); + let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( f_value.clone(), resolved_type.clone(), @@ -18433,25 +18596,25 @@ pub fn emit_typed_record_lit( ); let needs_wrap = (is_optional_struct_field( emit_info.clone(), - variant_summary_name, + variant_summary_name.clone(), "0".to_string(), ) && (is_already_optional( - f_value, + f_value.clone(), emit_info.clone(), scope.clone(), ) == false)); - let field_val = if needs_wrap { + let field_val = if needs_wrap.clone() { v1_rt::concat( - v1_rt::concat("Some(".to_string(), val_str), + v1_rt::concat("Some(".to_string(), val_str.clone()), ")".to_string(), ) } else { - val_str + val_str.clone() }; v1_rt::concat( v1_rt::concat( v1_rt::concat(display_tn, "(".to_string()), - field_val, + field_val.clone(), ), ")".to_string(), ) @@ -18602,7 +18765,7 @@ pub fn emit_typed_record_lit( if all_defaultable { Rc::new({ let mut __result = Vec::new(); - for fname in missing.iter().cloned() { + for fname in missing.clone().iter().cloned() { __result.extend((*if is_optional_struct_field(emit_info.clone(), variant_summary_name.clone(), fname.clone()) { Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { @@ -18644,7 +18807,7 @@ pub fn emit_typed_record_lit( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - si, + si.clone(), ); let has_unused = ((unused.len() as i64) > 0); if (is_struct && has_unused) { @@ -18674,7 +18837,7 @@ pub fn emit_typed_record_lit( "\n}".to_string(), ); if (ctor_alias_resolved - && v1_rt::set_contains(&shared_types, ctor_name)) + && v1_rt::set_contains(&shared_types, ctor_name.clone())) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), @@ -18762,7 +18925,7 @@ pub fn emit_typed_bin_op( let r_optional = is_optional_typed_expr(right.clone()); if (l_optional.clone() || r_optional.clone()) { { - let l_cmp = if l_optional { + let l_cmp = if l_optional.clone() { v1_rt::concat(l_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18776,7 +18939,7 @@ pub fn emit_typed_bin_op( ").as_deref()".to_string(), ) }; - let r_cmp = if r_optional { + let r_cmp = if r_optional.clone() { v1_rt::concat(r_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18798,7 +18961,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_cmp), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -18822,7 +18985,7 @@ pub fn emit_typed_bin_op( ), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -18854,7 +19017,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str, + op_str.clone(), ), " &".to_string(), ), @@ -18871,7 +19034,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -18923,9 +19086,9 @@ pub fn is_string_typed_expr( Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); let inner = if is_optional { - with_required_cardinality(rt) + with_required_cardinality(rt.clone()) } else { - rt + rt.clone() }; is_rust_string_like(inner, source_indices) } @@ -18982,7 +19145,7 @@ pub fn emit_typed_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.iter().cloned() { + for p in fmt_parts.clone().iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -19003,7 +19166,7 @@ pub fn emit_typed_string_interp( ) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); emit_rust_host_to_dag_string_via_seam( v1_rt::concat( v1_rt::concat( @@ -19034,9 +19197,9 @@ pub fn typed_interp_format_part( match (*part).clone() { StringPart::Text { value: v, .. } => { let escaped = if has_interpolations { - escape_rust_interp_text(v) + escape_rust_interp_text(v.clone()) } else { - escape_string_literal_body(v) + escape_string_literal_body(v.clone()) }; Rc::new(InterpPart { format_segment: escaped, @@ -19045,7 +19208,15 @@ pub fn typed_interp_format_part( } StringPart::Interpolation { expr: e, .. } => Rc::new(InterpPart { format_segment: "{}".to_string(), - arg_expr: emit_typed_expr(e, registry, scope, depth, shared_types, emit_info, 1024), + arg_expr: emit_typed_expr( + e.clone(), + registry, + scope, + depth, + shared_types, + emit_info, + 1024, + ), }), } } @@ -19092,7 +19263,7 @@ pub fn emit_tco_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -19108,7 +19279,7 @@ pub fn emit_tco_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -19125,8 +19296,8 @@ pub fn emit_tco_init_block_stmts( let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -19181,13 +19352,13 @@ pub fn emit_tco_init_stmt( if is_param { v1_rt::concat( v1_rt::concat( - v1_rt::concat(emit_ident(n, RenderTarget::Rust), " = ".to_string()), + v1_rt::concat(emit_ident(n.clone(), RenderTarget::Rust), " = ".to_string()), val_str, ), ";".to_string(), ) } else { - emit_let_binding(n, val_str, RenderTarget::Rust) + emit_let_binding(n.clone(), val_str, RenderTarget::Rust) } } _ => emit_typed_expr( @@ -19304,7 +19475,7 @@ pub fn emit_rust_tco_if( match e { Some(eb) => { let else_str = emit_typed_tco_expr( - eb, + eb.clone(), fn_name.clone(), params.clone(), registry.clone(), @@ -19371,7 +19542,7 @@ pub fn freemonoid_tco_empty_branch_body( ) -> String { match empty_arm { Some(ea) => emit_typed_tco_expr( - arm_body(ea), + arm_body(ea.clone()), fn_name, params, registry, @@ -19387,14 +19558,14 @@ pub fn freemonoid_tco_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_tco_expr( - arm_body(wa), + arm_body(wa.clone()), fn_name, params, registry, @@ -19430,7 +19601,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind), + v1_rt::concat("let ".to_string(), head_bind.clone()), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -19438,14 +19609,14 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind), + v1_rt::concat("let ".to_string(), tail_bind.clone()), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; v1_rt::concat( v1_rt::concat(head_let, tail_let), emit_typed_tco_expr( - arm_body(ca), + arm_body(ca.clone()), fn_name, params, registry, @@ -19463,14 +19634,14 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; v1_rt::concat( bind_let, emit_typed_tco_expr( - arm_body(wa), + arm_body(wa.clone()), fn_name, params, registry, @@ -19515,7 +19686,7 @@ pub fn emit_native_freemonoid_tco_match( ); let nonempty_body = freemonoid_tco_nonempty_branch_body( cons_arm, - catchall, + catchall.clone(), si, fn_name.clone(), params.clone(), @@ -19536,11 +19707,11 @@ pub fn emit_native_freemonoid_tco_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body, + empty_body.clone(), ), " } else { ".to_string(), ), - nonempty_body, + nonempty_body.clone(), ), " } }".to_string(), ) @@ -19578,7 +19749,7 @@ pub fn emit_rust_tco_match( .clone() .source_indices .clone(), - with_required_cardinality(rt), + with_required_cardinality(rt.clone()), ) } else { authored_name_at( @@ -19586,7 +19757,7 @@ pub fn emit_rust_tco_match( .clone() .source_indices .clone(), - rt, + rt.clone(), ) } } @@ -19613,11 +19784,11 @@ pub fn emit_rust_tco_match( "".to_string() }; if (native_tco_fm.clone() != "".to_string()) { - native_tco_fm + native_tco_fm.clone() } else { { let rc_match = analyze_rc_match( - s, + s.clone(), arm_list.clone(), tco_scrut_type.clone(), shared_types.clone(), @@ -19646,14 +19817,14 @@ pub fn emit_rust_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let tco_needs_as_str = (all_arms_are_string_lit(arm_list.clone()) - && ((arm_list.len() as i64) > 0)); + && ((arm_list.clone().len() as i64) > 0)); if rc_match.needs_option_deref.clone() { v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -19675,7 +19846,7 @@ pub fn emit_rust_tco_match( "match ".to_string(), apply_type_template1( sharing.deref_clone.clone(), - scrut_str, + scrut_str.clone(), ), ), " {\n".to_string(), @@ -19690,7 +19861,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_str() {\n".to_string(), ), arms_str, @@ -19701,7 +19872,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), arms_str, @@ -19791,15 +19962,15 @@ pub fn emit_rust_tco_let( }; let next_scope = extend_scope( frame.scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { Some(b) => v1_rt::concat( v1_rt::concat(let_line, "\n".to_string()), emit_typed_tco_expr( - b, + b.clone(), fn_name, params.clone(), registry.clone(), @@ -19844,9 +20015,9 @@ pub fn emit_rust_tco_block( emit_info.clone(), params.clone(), ); - let last_str = match ss.last().cloned() { + let last_str = match ss.clone().last().cloned() { Some(last_expr) => emit_typed_tco_expr( - last_expr, + last_expr.clone(), fn_name, params.clone(), registry.clone(), @@ -20035,7 +20206,7 @@ pub fn emit_typed_tco_match_arm( collect_pattern_string_guards(arm_pat.clone(), Rc::new(vec![]), si.clone()); let arm_guard_str = match arm_g { Some(g) => emit_typed_expr( - g, + g.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -20050,17 +20221,17 @@ pub fn emit_typed_tco_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards), + v1_rt::concat(" if ".to_string(), field_guards.clone()), " && ".to_string(), ), - arm_guard_str, + arm_guard_str.clone(), ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards) + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str) + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() } @@ -20079,10 +20250,10 @@ pub fn emit_typed_tco_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat, - rc_analysis, + arm_pat.clone(), + rc_analysis.clone(), shared_types.clone(), - si, + si.clone(), emit_info.clone(), ); v1_rt::concat( @@ -20129,7 +20300,7 @@ pub fn expr_references_var( match (*node.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(node.clone(), source_indices) == var_name), + } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -20269,7 +20440,7 @@ pub fn emit_typed_tco_reassign( }); let ordered_args = Rc::new({ let mut __result = Vec::new(); - for av in filtered_arg_values.iter().cloned() { + for av in filtered_arg_values.clone().iter().cloned() { __result.push(emit_typed_expr( av.clone(), registry.clone(), @@ -20284,7 +20455,7 @@ pub fn emit_typed_tco_reassign( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for p in filtered_params.iter().cloned() { + for p in filtered_params.clone().iter().cloned() { __result.push(emit_ident( param_node_name_at(p.clone(), si.clone()), RenderTarget::Rust, @@ -20331,9 +20502,9 @@ pub fn emit_service_def( env.source_indices.clone(), ); let impl_block = emit_service_impl( - safe_name, - fallback_transport, - op_children, + safe_name.clone(), + fallback_transport.clone(), + op_children.clone(), registry, shared_types, corpus_repr, @@ -20398,12 +20569,14 @@ pub fn emit_service_config_fields( } else { fs.clone() }; - let decls = - service_field_decls(fs, language_spec(RenderTarget::Rust).service_fields.clone()); + let decls = service_field_decls( + fs.clone(), + language_spec(RenderTarget::Rust).service_fields.clone(), + ); if ((decls.clone().len() as i64) == 0) { " // No configuration needed for local binding.\n".to_string() } else { - decls.join(&"".to_string()) + decls.clone().join(&"".to_string()) } } } @@ -20453,7 +20626,7 @@ pub fn emit_service_impl( v1_rt::concat("impl ".to_string(), name.clone()), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), methods_str, ), @@ -20504,7 +20677,7 @@ pub fn emit_service_new_method( None => "".to_string(), }; let base_url_default = if (from_config.clone() != "".to_string()) { - from_config + from_config.clone() } else { if fs.has_rest.clone() { { @@ -20519,7 +20692,7 @@ pub fn emit_service_new_method( else { unreachable!() }; - s + s.clone() } _ => "".to_string(), }, @@ -20529,7 +20702,7 @@ pub fn emit_service_new_method( "".to_string() }; if (from_fallback.clone() != "".to_string()) { - from_fallback + from_fallback.clone() } else { "http://localhost".to_string() } @@ -20538,8 +20711,10 @@ pub fn emit_service_new_method( "".to_string() } }; - let ctors = - service_field_ctors(fs, language_spec(RenderTarget::Rust).service_fields.clone()); + let ctors = service_field_ctors( + fs.clone(), + language_spec(RenderTarget::Rust).service_fields.clone(), + ); let ctors = Rc::new({ let mut __result = Vec::new(); for c in ctors.clone().iter().cloned() { @@ -20561,7 +20736,7 @@ pub fn emit_service_new_method( }), None => ctors.clone(), }; - let inits = ctors.join(&"".to_string()); + let inits = ctors.clone().join(&"".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -20596,14 +20771,14 @@ pub fn emit_auth_source_ctor( ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { Some(variant) => if (variant.clone() == "EnvVar".to_string()) { match source_expr.children.clone().first().cloned() { - Some(fi) => match (*field_init_node_value(fi).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: env_name, .. } = value.as_ref() else { unreachable!() }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" auth_token: std::env::var(\"".to_string(), env_name.clone()), "\").expect(\"missing credential: ".to_string()), env_name), "\"),\n".to_string()) }, + Some(fi) => match (*field_init_node_value(fi.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: env_name, .. } = value.as_ref() else { unreachable!() }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" auth_token: std::env::var(\"".to_string(), env_name.clone()), "\").expect(\"missing credential: ".to_string()), env_name.clone()), "\"),\n".to_string()) }, _ => " auth_token: compile_error!(\"EnvVar.name must be a string literal\"),\n".to_string(), }, None => " auth_token: compile_error!(\"EnvVar requires a name field\"),\n".to_string(), } } else { - v1_rt::concat(v1_rt::concat(" auth_token: compile_error!(\"unsupported CredentialSource variant: ".to_string(), variant), "\"),\n".to_string()) + v1_rt::concat(v1_rt::concat(" auth_token: compile_error!(\"unsupported CredentialSource variant: ".to_string(), variant.clone()), "\"),\n".to_string()) }, None => " auth_token: compile_error!(\"auth_source record literal has no type name\"),\n".to_string(), }, @@ -20621,7 +20796,10 @@ pub fn emit_modifier_doc_from_props( "".to_string() } else { v1_rt::concat( - v1_rt::concat("/// Modifiers: ".to_string(), names.join(&", ".to_string())), + v1_rt::concat( + "/// Modifiers: ".to_string(), + names.clone().join(&", ".to_string()), + ), "\n".to_string(), ) } @@ -20669,7 +20847,7 @@ pub fn emit_operation_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str) + v1_rt::concat("&self, ".to_string(), params_str.clone()) }; let ret_type = render_rust_type( resolved_type(op_node.clone()), @@ -20765,7 +20943,7 @@ pub fn emit_operation_method( ), " ".to_string(), ), - emit_ident(op_text, RenderTarget::Rust), + emit_ident(op_text.clone(), RenderTarget::Rust), ), "(".to_string(), ), @@ -20807,7 +20985,7 @@ pub fn emit_dry_run_branch_from_props( let first_mock = mock_props.clone().first().cloned(); match first_mock { Some(mp) => { - let mock_json = emit_data_value_json(field_init_node_value(mp), source_indices.clone()); + let mock_json = emit_data_value_json(field_init_node_value(mp.clone()), source_indices.clone()); let is_multi_field_conj = ((inferred.connective.clone() == Connective::Conj) && ((inferred.children.clone().len() as i64) > 1)); if is_multi_field_conj { { @@ -20830,7 +21008,7 @@ let prelude = match wire_opt.clone() { } else { { let wire_ty = match tn.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let __rest_wire: ".to_string(), render_rust_type(wire_ty, shared_types, corpus_repr.clone(), source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) @@ -20861,7 +21039,7 @@ match ch.return_cardinality.clone() { _ => raw.clone(), } }); } __result }); -let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); +let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.clone().iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); let result_body = v1_rt::concat(v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(log_line, "\n".to_string()), prelude), extract_lines.join(&"\n".to_string())), "\nOk(".to_string()), result_body), ")".to_string()) } @@ -21030,7 +21208,7 @@ pub fn emit_rest_http_method( match transport_method(transport, source_indices.clone()) { Some(m) => match m.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - let method_name = expr_var_name_at(m, source_indices.clone()); + let method_name = expr_var_name_at(m.clone(), source_indices.clone()); Rc::new({ let mut __result = Vec::new(); for ch in Rc::new(method_name.chars().map(|c| c as i64).collect::>()) @@ -21066,7 +21244,7 @@ pub fn emit_rest_url_line( v1_rt::concat( v1_rt::concat( "let url = format!(\"{}".to_string(), - escape_string_literal_body(path_str), + escape_string_literal_body(path_str.clone()), ), "\", self.base_url);".to_string(), ) @@ -21105,7 +21283,7 @@ pub fn emit_rest_url_line( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.iter().cloned() { + for p in parts.clone().iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -21138,7 +21316,7 @@ pub fn emit_rest_url_line( ) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21187,7 +21365,7 @@ pub fn emit_rest_auth_line( "self.auth_token.clone()".to_string() } else { match auth_input { - Some(ai) => emit_simple_expr(ai, RenderTarget::Rust, source_indices.clone()), + Some(ai) => emit_simple_expr(ai.clone(), RenderTarget::Rust, source_indices.clone()), None => "compile_error!(\"service config has auth but no auth_input or auth_source\")".to_string(), } }; @@ -21196,8 +21374,8 @@ pub fn emit_rest_auth_line( ExprData::ExprCall { .. } => { let header_name = match auth.children.clone().first().cloned() { Some(arg_node) => match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; s }, - _ => emit_simple_expr(arg_value(arg_node), RenderTarget::Rust, source_indices.clone()), + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; s.clone() }, + _ => emit_simple_expr(arg_value(arg_node.clone()), RenderTarget::Rust, source_indices.clone()), }, None => "x-api-key".to_string(), }; @@ -21213,14 +21391,16 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con transport.clone(), source_indices.clone(), ) { - Some(h) => h, + Some(h) => h.clone(), None => "Authorization".to_string(), }; let token_node = match transport_auth_token(transport.clone(), source_indices.clone()) { - Some(tn) => { - emit_simple_expr(tn, RenderTarget::Rust, source_indices.clone()) - } + Some(tn) => emit_simple_expr( + tn.clone(), + RenderTarget::Rust, + source_indices.clone(), + ), None => "\"\"".to_string(), }; v1_rt::concat( @@ -21291,7 +21471,7 @@ pub fn emit_rest_query_line( v1_rt::concat( v1_rt::concat( "let request = request.query(&[".to_string(), - pairs.join(&", ".to_string()), + pairs.clone().join(&", ".to_string()), ), "]);".to_string(), ) @@ -21318,11 +21498,11 @@ if (((req_strs.clone().len() as i64) == 0) && ((optional_fields.clone().len() as } else { { let body_init = if ((req_strs.clone().len() as i64) > 0) { - v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.join(&", ".to_string())), " });".to_string()) + v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.clone().join(&", ".to_string())), " });".to_string()) } else { "let mut __body = serde_json::json!({});".to_string() }; -let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.iter().cloned() { __result.push({ +let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.clone().iter().cloned() { __result.push({ let fname = field_init_node_name_at(fi.clone(), source_indices.clone()); let fexpr = emit_simple_expr(field_init_node_value(fi.clone()), RenderTarget::Rust, source_indices.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("if let Some(ref __v) = ".to_string(), fexpr.clone()), " { __body[\"".to_string()), fname.clone()), "\"] = serde_json::json!(__v); }".to_string()) @@ -21364,12 +21544,12 @@ pub fn child_from_key( .first() .cloned() { - Some(prop) => match (*field_init_node_value(prop).expr_data.clone()).clone() { + Some(prop) => match (*field_init_node_value(prop.clone()).expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { unreachable!() }; - Some(s) + Some(s.clone()) } _ => None, }, @@ -21439,16 +21619,18 @@ pub fn operation_response_200_resolved_type( .cloned() { Some(p) => { - let v = field_init_node_value(p); + let v = field_init_node_value(p.clone()); match v.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: tn, .. }) => Some(tn), + Some(InferredNode::Resolved { node: tn, .. }) => Some(tn.clone()), _ => { - let type_name = - authored_name_at(source_indices.clone(), normalize_access_type_node(v)); + let type_name = authored_name_at( + source_indices.clone(), + normalize_access_type_node(v.clone()), + ); if (type_name.clone() == "".to_string()) { None } else { - lookup_type_by_name(env, type_name) + lookup_type_by_name(env, type_name.clone()) } } } @@ -21468,12 +21650,13 @@ pub fn is_json_wire_declaration_type( } else { { let parts = Rc::new( - n.split(&".".to_string()) + n.clone() + .split(&".".to_string()) .map(|s| s.to_string()) .collect::>(), ); match parts.last().cloned() { - Some(last) => (last == "Json".to_string()), + Some(last) => (last.clone() == "Json".to_string()), None => false, } } @@ -21534,7 +21717,7 @@ pub fn wire_child_for_segment( .first() .cloned() { - Some(ch) => Some(ch), + Some(ch) => Some(ch.clone()), None => None, } } @@ -21552,7 +21735,10 @@ pub fn advance_wire_path_projection( if path_segment_is_list_index(seg.clone()) { { let next_node = match state.node.clone() { - Some(n) => Some(for_each_element_type_node(n, source_indices.clone())), + Some(n) => Some(for_each_element_type_node( + n.clone(), + source_indices.clone(), + )), None => None, }; Rc::new(WirePathProjection { @@ -21585,27 +21771,29 @@ pub fn advance_wire_path_projection( } } else { match state.node.clone() { - Some(n) => match wire_child_for_segment(n, seg.clone(), source_indices.clone()) { - Some(ch) => Rc::new(WirePathProjection { - expr: v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), state.expr.clone()), - ").".to_string(), - ), - emit_ident( - authored_name_at(source_indices.clone(), ch.clone()), - RenderTarget::Rust, + Some(n) => { + match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { + Some(ch) => Rc::new(WirePathProjection { + expr: v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), state.expr.clone()), + ").".to_string(), + ), + emit_ident( + authored_name_at(source_indices.clone(), ch.clone()), + RenderTarget::Rust, + ), ), - ), - node: Some(resolved_type(ch)), - ok: true, - }), - None => Rc::new(WirePathProjection { - expr: state.expr.clone(), - node: None, - ok: false, - }), - }, + node: Some(resolved_type(ch.clone())), + ok: true, + }), + None => Rc::new(WirePathProjection { + expr: state.expr.clone(), + node: None, + ok: false, + }), + } + } None => Rc::new(WirePathProjection { expr: state.expr.clone(), node: None, @@ -21760,7 +21948,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type == "bool".to_string()) { + if (rust_type.clone() == "bool".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -21826,7 +22014,7 @@ pub fn emit_from_key_extraction( } else { { let wire_ty = match tn.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; v1_rt::concat( @@ -21875,7 +22063,7 @@ match ch.inferred.clone().as_deref().cloned() { }); let field_names = Rc::new({ let mut __result = Vec::new(); - for ch in children.iter().cloned() { + for ch in children.clone().iter().cloned() { __result.push(emit_ident( authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust, @@ -21887,13 +22075,13 @@ match ch.inferred.clone().as_deref().cloned() { v1_rt::concat( v1_rt::concat( "(".to_string(), - field_names.first().cloned().clone().unwrap(), + field_names.clone().first().cloned().clone().unwrap(), ), ",)".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), + v1_rt::concat("(".to_string(), field_names.clone().join(&", ".to_string())), ")".to_string(), ) }; @@ -21919,7 +22107,9 @@ pub fn emit_plain_response_body( ) -> String { { let is_text = match transport_response_format(transport, source_indices.clone()) { - Some(fmt) => (authored_name_at(source_indices.clone(), fmt) == "Text".to_string()), + Some(fmt) => { + (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) + } None => false, }; if is_text { @@ -21950,22 +22140,22 @@ pub fn emit_response_code_handling( __result }); if ((response_props.clone().len() as i64) == 0) { - if use_from_key { + if use_from_key.clone() { emit_from_key_extraction( op_node.clone(), source_indices.clone(), - shared_types, - corpus_repr, - env, + shared_types.clone(), + corpus_repr.clone(), + env.clone(), ) } else { - emit_plain_response_body(op_node.clone(), transport, source_indices.clone()) + emit_plain_response_body(op_node.clone(), transport.clone(), source_indices.clone()) } } else { { let arms = Rc::new({ let mut __result = Vec::new(); - for p in response_props.iter().cloned() { + for p in response_props.clone().iter().cloned() { __result.push(emit_response_arm( p.clone(), op_node.clone(), @@ -22025,12 +22215,15 @@ pub fn emit_response_arm( { let prefix = v1_rt::substring(&code_str, 0, 1); v1_rt::concat( - v1_rt::concat(v1_rt::concat(prefix.clone(), "00..=".to_string()), prefix), + v1_rt::concat( + v1_rt::concat(prefix.clone(), "00..=".to_string()), + prefix.clone(), + ), "99".to_string(), ) } } else { - code_str + code_str.clone() } }; if is_success { @@ -22094,7 +22287,7 @@ pub fn emit_exit_code_handling( __result }); if ((exit_props.clone().len() as i64) == 0) { - emit_shell_return(inferred, source_indices) + emit_shell_return(inferred.clone(), source_indices.clone()) } else { { let has_nonzero = { @@ -22111,7 +22304,7 @@ pub fn emit_exit_code_handling( }; let exit_arms = Rc::new({ let mut __result = Vec::new(); - for p in exit_props.iter().cloned() { + for p in exit_props.clone().iter().cloned() { __result.push(emit_exit_arm( p.clone(), inferred.clone(), @@ -22158,7 +22351,7 @@ pub fn emit_exit_arm( } else { code_str.clone() }; - let is_success = (code_str == "0".to_string()); + let is_success = (code_str.clone() == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -22226,7 +22419,7 @@ pub fn emit_shell_call( v1_rt::concat( v1_rt::concat(let_kw, " = std::process::Command::new(".to_string()), emit_shell_argv_element( - first_arg, + first_arg.clone(), optional_params.clone(), corpus_repr.clone(), source_indices.clone(), @@ -22254,9 +22447,15 @@ pub fn emit_shell_call( let arg_lines = if ((argv.clone().len() as i64) > 1) { Rc::new({ let mut __result = Vec::new(); - for arg in Rc::new(argv.iter().cloned().skip(1 as usize).collect::>()) - .iter() - .cloned() + for arg in Rc::new( + argv.clone() + .iter() + .cloned() + .skip(1 as usize) + .collect::>(), + ) + .iter() + .cloned() { __result.push(v1_rt::concat( v1_rt::concat( @@ -22301,7 +22500,7 @@ pub fn emit_shell_call( __result }); let wd_line = " .current_dir(self.working_dir.as_deref().unwrap_or(\".\"))".to_string(); - if has_stdin { + if has_stdin.clone() { { let stdin_expr = transport_stdin(transport.clone(), source_indices.clone()) .clone() @@ -22310,10 +22509,14 @@ pub fn emit_shell_call( ExprData::ExprVar { binding_kind: _, .. } => emit_ident( - expr_var_name_at(stdin_expr, source_indices.clone()), + expr_var_name_at(stdin_expr.clone(), source_indices.clone()), + RenderTarget::Rust, + ), + _ => emit_simple_expr( + stdin_expr.clone(), RenderTarget::Rust, + source_indices.clone(), ), - _ => emit_simple_expr(stdin_expr, RenderTarget::Rust, source_indices.clone()), }; let spawn_line = " .stdin(std::process::Stdio::piped())\n .stdout(std::process::Stdio::piped())\n .stderr(std::process::Stdio::piped())".to_string(); let spawn_exec = " .spawn()?;".to_string(); @@ -22374,7 +22577,7 @@ pub fn emit_shell_argv_element( unreachable!() }; v1_rt::concat( - v1_rt::concat("\"".to_string(), escape_string_literal_body(s)), + v1_rt::concat("\"".to_string(), escape_string_literal_body(s.clone())), "\"".to_string(), ) } @@ -22411,7 +22614,7 @@ pub fn emit_shell_argv_element( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.iter().cloned() { + for p in parts.clone().iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -22454,23 +22657,23 @@ pub fn emit_shell_argv_element( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(arg.clone(), source_indices); + let name = expr_var_name_at(arg.clone(), source_indices.clone()); let var_name = emit_ident(name.clone(), RenderTarget::Rust); let is_opt = (is_optional_typed_expr(arg.clone()) - || match v1_rt::map_get(&optional_params, name) { + || match v1_rt::map_get(&optional_params, name.clone()) { Some(_) => true, None => false, }); - if is_opt { + if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( - v1_rt::concat(var_name, ".as_deref().unwrap_or(\"\")".to_string()), + v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name, corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) } } - _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices), + _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), } } @@ -22494,10 +22697,10 @@ pub fn emit_shell_return( Some(channel) => { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr(channel, is_optional) + emit_shell_channel_expr(channel.clone(), is_optional.clone()) } None => { - if (is_product && ((effective.children.clone().len() as i64) > 1)) { + if (is_product.clone() && ((effective.children.clone().len() as i64) > 1)) { { let needs_stderr = { let mut __found = false; @@ -22535,7 +22738,7 @@ pub fn emit_shell_return( __result }); let lines = if (stderr_line.clone() != "".to_string()) { - v1_rt::concat(stderr_line, "\n".to_string()) + v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() }; @@ -22551,7 +22754,7 @@ pub fn emit_shell_return( { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr("stdout".to_string(), is_optional) + emit_shell_channel_expr("stdout".to_string(), is_optional.clone()) } } } @@ -22589,11 +22792,11 @@ pub fn unwrap_single_field_product(n: Rc) -> Rc { && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { - Some(field_node) => resolved_type(field_node), - None => n, + Some(field_node) => resolved_type(field_node.clone()), + None => n.clone(), } } else { - n + n.clone() } } } @@ -22658,7 +22861,7 @@ pub fn emit_resource_def( let depth = 0; let cap_methods = Rc::new({ let mut __result = Vec::new(); - for c in cap_children.iter().cloned() { + for c in cap_children.clone().iter().cloned() { __result.push(emit_capability_method( c.clone(), shared_types.clone(), @@ -22725,7 +22928,7 @@ pub fn emit_capability_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str) + v1_rt::concat("&self, ".to_string(), params_str.clone()) }; let ret = render_rust_type( resolved_type(cap_node.clone()), @@ -22804,7 +23007,7 @@ pub fn data_def_annotation_is_named_refinement( let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) - && !is_container_type(ann_name)) + && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), source_indices.clone(), @@ -22829,7 +23032,7 @@ pub fn emit_data_def( annotation_type_node.clone() } else { match value.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => annotation_type_node.clone(), } }; @@ -22841,7 +23044,7 @@ pub fn emit_data_def( RenderTarget::Rust, authored_name_at( (*scope.type_env).clone().source_indices.clone(), - annotation_type_node, + annotation_type_node.clone(), ), ) } else { @@ -22863,28 +23066,31 @@ pub fn emit_data_def( Some(top_value) => { let top_type_name = authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(top_value), + resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { - raw_ty_str + raw_ty_str.clone() } else { - if (raw_ty_str == "Rc".to_string()) { + if (raw_ty_str.clone() == "Rc".to_string()) { v1_rt::concat( - v1_rt::concat("Rc>".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("BoundedLattice<".to_string(), top_type_name), + v1_rt::concat("BoundedLattice<".to_string(), top_type_name.clone()), ">".to_string(), ) } } } - None => raw_ty_str, + None => raw_ty_str.clone(), } } else { - raw_ty_str + raw_ty_str.clone() }; let fn_name = to_snake(name); let needs_rc = v1_rt::set_contains( @@ -22912,7 +23118,7 @@ pub fn emit_data_def( value.clone(), (*scope.type_env).clone().source_indices.clone(), ) { - Some(identity_expr) => identity_expr, + Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( value.clone(), registry, @@ -22938,7 +23144,7 @@ pub fn emit_data_def( ), "() -> ".to_string(), ), - ty_str, + ty_str.clone(), ), " { ".to_string(), ), @@ -22957,10 +23163,10 @@ pub fn emit_data_def( depth, shared_types.clone(), emit_info.clone(), - needs_rc, + needs_rc.clone(), ); let kw = rust_items().func_keyword.clone(); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str), "| c.clone())\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str.clone()), "| c.clone())\n".to_string()), "}".to_string()) } } } @@ -22985,7 +23191,7 @@ pub fn rust_nominal_identity_data_expr( let symbol_name = expr_var_name_at(value.clone(), source_indices.clone()); Some(v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_name, "(\"".to_string()), + v1_rt::concat(type_name.clone(), "(\"".to_string()), escape_string_literal_body(symbol_name), ), "\".to_string())".to_string(), @@ -23049,9 +23255,9 @@ pub fn emit_data_def_body( (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => match lattice_value { + None => match lattice_value.clone() { Some(lattice) => field_value_by_name( - lattice, + lattice.clone(), "join".to_string(), (*scope.type_env).clone().source_indices.clone(), ), @@ -23104,7 +23310,7 @@ pub fn emit_data_def_body( (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( - n, + n.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -23249,7 +23455,7 @@ pub fn emit_data_def_body( emit_info.clone(), 1024, ); - v1_rt::concat(" ".to_string(), val_str) + v1_rt::concat(" ".to_string(), val_str.clone()) } } } else { @@ -23275,14 +23481,14 @@ pub fn emit_data_def_body( ); match effective_variant_parent( vname.clone(), - bk, + bk.clone(), value.inferred.clone(), emit_info.clone(), (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( - vname, - enum_name, + vname.clone(), + enum_name.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), ), @@ -23296,7 +23502,7 @@ pub fn emit_data_def_body( } else { "".to_string() }; - let wrap_end = if (needs_rc.clone() && !is_already_wrapped) { + let wrap_end = if (needs_rc.clone() && !is_already_wrapped.clone()) { ")".to_string() } else { "".to_string() @@ -23304,7 +23510,7 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat(" ".to_string(), wrap_start), - val_str, + val_str.clone(), ), wrap_end, ) @@ -23342,7 +23548,7 @@ pub fn emit_test_file( } else { { let filename = module_to_filename(module_name.clone()); - let tests_str = test_fns.join(&"\n\n".to_string()); + let tests_str = test_fns.clone().join(&"\n\n".to_string()); let content = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -23364,7 +23570,7 @@ pub fn emit_test_file( ), " use super::*;\n\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), tests_str, ), @@ -23472,9 +23678,9 @@ pub fn emit_operation_test( let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { - args_str + args_str.clone() }; - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent), "assert!(result.is_ok(), \"".to_string()), struct_name), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent.clone()), "assert!(result.is_ok(), \"".to_string()), struct_name.clone()), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) } } @@ -23486,11 +23692,11 @@ pub fn emit_rust_default_value( let type_name = authored_name_at(source_indices, param_node_type_expr(param)); match lookup_checkpoint(RenderTarget::Rust, type_name.clone()) { Some(cp) => match cp.default_expr.clone() { - Some(expr) => expr, + Some(expr) => expr.clone(), None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name, + type_name.clone(), ), "\")".to_string(), ), @@ -23498,7 +23704,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name, + type_name.clone(), ), "\")".to_string(), ), @@ -23656,9 +23862,9 @@ pub struct WorkflowFunc { pub fn extract_literal_string(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s), - LiteralValue::LitBool { value: b, .. } => Some(if b { + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s.clone()), + LiteralValue::LitBool { value: b, .. } => Some(if b.clone() { "true".to_string() } else { "false".to_string() @@ -23677,7 +23883,7 @@ pub fn resolve_param_default( ) -> Option { match param_node_default_value(param) { Some(dv) => match (*dv.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: _, .. } => extract_literal_string(dv), + ExprData::ExprLiteral { value: _, .. } => extract_literal_string(dv.clone()), ExprData::ExprVar { binding_kind: _, .. } => match lookup_item( @@ -23700,7 +23906,7 @@ pub fn resolve_param_default( .cloned() { Some(data_item) => match data_item.body.clone() { - Some(body) => extract_literal_string(body), + Some(body) => extract_literal_string(body.clone()), None => None, }, None => None, @@ -23750,11 +23956,11 @@ pub fn to_workflow_func( item_name.clone(), ); let ro_params = match v1_rt::map_get(&read_only_params_index, qualified) { - Some(m) => m, + Some(m) => m.clone(), None => v1_rt::rc_empty_set::(), }; Rc::new(WorkflowFunc { - name: item_name, + name: item_name.clone(), module_name: module_name.clone(), params: item.params.clone(), inferred: resolved_type(item.clone()), @@ -23840,17 +24046,17 @@ pub fn collect_workflow_funcs( pub fn cli_default_literal_value(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { - LiteralValue::LitStr { value: s, .. } => Some(s), - LiteralValue::LitInt { value: i, .. } => Some((i).to_string()), - LiteralValue::LitFloat { value: f, .. } => Some(f), - LiteralValue::LitBool { value: b, .. } => Some(if b { + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + LiteralValue::LitStr { value: s, .. } => Some(s.clone()), + LiteralValue::LitInt { value: i, .. } => Some((i.clone()).to_string()), + LiteralValue::LitFloat { value: f, .. } => Some(f.clone()), + LiteralValue::LitBool { value: b, .. } => Some(if b.clone() { emit_keyword("true".to_string(), RenderTarget::Rust) } else { emit_keyword("false".to_string(), RenderTarget::Rust) }), LiteralValue::LitNull => None, - LiteralValue::LitSymbol { value: s, .. } => Some(s), + LiteralValue::LitSymbol { value: s, .. } => Some(s.clone()), }, _ => None, } @@ -24072,12 +24278,12 @@ pub fn emit_main_rs( "".to_string() }; let resource_use = if (resource_imports_str.clone() != "".to_string()) { - v1_rt::concat(resource_imports_str, "\n".to_string()) + v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) } else { "".to_string() }; let svc_use = if (svc_imports_str.clone() != "".to_string()) { - v1_rt::concat(svc_imports_str, "\n".to_string()) + v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) } else { "".to_string() }; @@ -24125,7 +24331,7 @@ pub fn emit_main_rs( has_pipeline.clone(), crate_name.clone(), ); - let diagnostic_fns = if has_pipeline { + let diagnostic_fns = if has_pipeline.clone() { emit_main_diagnostic_fns(crate_name.clone()) } else { "".to_string() @@ -24212,7 +24418,7 @@ pub fn emit_main_mod_uses( { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); let core_mod = module_to_filename("v1.std.core".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) } } else { base @@ -24345,7 +24551,7 @@ pub fn emit_subcommand_enum( "#[derive(Subcommand)]\n".to_string(), "enum Commands {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), variants_str, ), @@ -24421,13 +24627,19 @@ pub fn emit_subcommand_field( emit_cli_param_type_node(param_node_type_expr(param.clone()), source_indices.clone()); let default_attr = match v1_rt::map_get(&resolved_defaults, param_name) { Some(resolved) => v1_rt::concat( - v1_rt::concat("#[arg(long, default_value = \"".to_string(), resolved), + v1_rt::concat( + "#[arg(long, default_value = \"".to_string(), + resolved.clone(), + ), "\")]\n".to_string(), ), None => match param_node_default_value(param.clone()) { - Some(dv) => match cli_default_literal_value(dv) { + Some(dv) => match cli_default_literal_value(dv.clone()) { Some(default_value) => v1_rt::concat( - v1_rt::concat("#[arg(long, default_value = \"".to_string(), default_value), + v1_rt::concat( + "#[arg(long, default_value = \"".to_string(), + default_value.clone(), + ), "\")]\n".to_string(), ), None => "#[arg(long)]\n".to_string(), @@ -24473,8 +24685,8 @@ pub fn emit_cli_param_type_node( { let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname) { - mapped + if (mapped.clone() != nname.clone()) { + mapped.clone() } else { "String".to_string() } @@ -24554,7 +24766,10 @@ pub fn emit_main_fn( } else { v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), dry_run_line), + v1_rt::concat( + v1_rt::concat(parse_line, "\n".to_string()), + dry_run_line.clone(), + ), "\n".to_string(), ), result_handling, @@ -24564,7 +24779,7 @@ pub fn emit_main_fn( v1_rt::concat( v1_rt::concat( v1_rt::concat(async_attr, "{\n".to_string()), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_lines, ), @@ -24576,7 +24791,7 @@ pub fn emit_main_fn( pub fn emit_compile_match_arm(crate_name: String) -> String { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) } } @@ -24599,7 +24814,7 @@ pub fn emit_main_pipeline_fns(crate_name: String) -> String { ), emit_resolve_transitively_fn(crate_name.clone(), pipeline_mod.clone()), ), - emit_compile_target_helpers(crate_name.clone(), pipeline_mod, artifact_mod), + emit_compile_target_helpers(crate_name.clone(), pipeline_mod.clone(), artifact_mod), ) } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index a45b11d9a64..546f803d36f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -239,19 +239,15 @@ pub fn infer_block_stmts( None => { break Rc::new(BlockInferState { scope: scope.clone(), - diag_chunks: diag_chunks.clone(), - last_type: last_type.clone(), - typed_stmts: typed_stmts.clone(), + diag_chunks: diag_chunks, + last_type: last_type, + typed_stmts: typed_stmts, }); } Some(stmt) => { let is_last = (remaining_count.clone() == 1); - let stmt_expected = if is_last.clone() { - expected.clone() - } else { - None - }; - let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected.clone()); + let stmt_expected = if is_last { expected.clone() } else { None }; + let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); let stmt_rt = resolved_type(Rc::new(stmt_typed.clone())); @@ -266,9 +262,9 @@ pub fn infer_block_stmts( .collect::>(), ); let __tco_1 = (remaining_count - 1); - let __tco_2 = next_scope.clone(); + let __tco_2 = next_scope; let __tco_3 = v1_rt::rc_list_push(typed_stmts, Rc::new(stmt_typed.clone())); - let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags.clone()); + let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; remaining_count = __tco_1; @@ -373,16 +369,16 @@ pub fn merge_scope_from_imports( match remaining.clone().first().cloned() { None => { break Rc::new(InferScopeComponents { - svc_registry: svc_registry.clone(), - svc_locals: svc_locals.clone(), + svc_registry: svc_registry, + svc_locals: svc_locals, }); } Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => { let parent_result = typed_parent.items.clone().iter().cloned().fold( Rc::new(InferScopeComponents { - svc_registry: svc_registry.clone(), - svc_locals: svc_locals.clone(), + svc_registry: svc_registry, + svc_locals: svc_locals, }), |acc: Rc, titem: Rc| { if ((titem.transport.clone() != None) @@ -519,7 +515,7 @@ pub fn classify_field_recursion( ) -> Option> { { let type_expr = match field_node.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); @@ -538,7 +534,7 @@ pub fn classify_field_recursion( if is_container_type(field_type_name.clone()) { { let arity = match container_expected_arity(field_type_name.clone()) { - Some(a) => a, + Some(a) => a.clone(), None => 0, }; let value_index = if (arity == 2) { 1 } else { 0 }; @@ -548,7 +544,7 @@ pub fn classify_field_recursion( .get(value_index as usize) .cloned() { - Some(t) => authored_name_at(source_indices.clone(), t), + Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; let is_recursive_element = ((value_type.clone() == parent_name.clone()) @@ -558,9 +554,9 @@ pub fn classify_field_recursion( let elem = if (value_type.clone() == parent_name.clone()) { parent_name.clone() } else { - value_type + value_type.clone() }; - match field_type_name.as_str() { + match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, element_type: elem, @@ -585,11 +581,11 @@ pub fn classify_field_recursion( match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, - element_type: field_type_name, + element_type: field_type_name.clone(), })), _ => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::DirectRecursion, - element_type: field_type_name, + element_type: field_type_name.clone(), })), } } else { @@ -609,7 +605,7 @@ pub fn collect_fields_inductive( source_indices: Rc>>, ) -> Rc>>>> { fields.iter().cloned().fold( - acc, + acc.clone(), |field_acc: Rc>>>>, field_node: Rc| { match classify_field_recursion( field_node.clone(), @@ -655,9 +651,9 @@ pub fn collect_item_inductive_fields( ), Connective::Conj => collect_fields_inductive( item.children.clone(), - item_name, + item_name.clone(), "".to_string(), - recursive_type_set, + recursive_type_set.clone(), v1_rt::rc_empty_map::>>>(), source_indices.clone(), ), @@ -738,15 +734,17 @@ pub fn namespace_root_from_properties( .first() .cloned() { - Some(ns_prop) => match (*field_init_node_value(ns_prop).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitStr { value: root, .. } = value.as_ref() else { - unreachable!() - }; - root + Some(ns_prop) => { + match (*field_init_node_value(ns_prop.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitStr { value: root, .. } = value.as_ref() else { + unreachable!() + }; + root.clone() + } + _ => name, } - _ => name, - }, + } None => name, } } @@ -773,12 +771,12 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(parent) => { let is_coproduct = (parent.connective.clone() == Connective::Disj); if is_coproduct { if has_child_named( - parent, + parent.clone(), name.clone(), (*scope.type_env).clone().source_indices.clone(), ) { @@ -812,7 +810,7 @@ pub fn variant_owner_node_authority() -> String { pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(owner) => { let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); if owner_is_coproduct { @@ -821,7 +819,7 @@ pub fn variant_owner_node(scope: Rc, name: String) -> Option, name: String) -> Option, name: String) -> Rc { match lookup_variant_parent_enum(scope.clone(), name.clone()) { Some(parent_enum) => Rc::new(VarBindingKind::VariantValueBinding { - parent_enum: parent_enum, + parent_enum: parent_enum.clone(), }), None => match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(_) => { @@ -902,7 +900,7 @@ pub fn rejects_string_for_optional_coproduct_field( { let expected_resolved = match lookup_type_for(env, with_required_cardinality(expected.clone())) { - Some(resolved) => resolved, + Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; let expected_is_optional_coproduct = ((expected.return_cardinality.clone() @@ -918,7 +916,7 @@ pub fn rejects_string_for_optional_coproduct_field( pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { { let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { - Some(resolved) => resolved, + Some(resolved) => resolved.clone(), None => with_required_cardinality(ft.clone()), }; ((ft.return_cardinality.clone() == Cardinality::CardOptional) @@ -975,28 +973,28 @@ pub fn record_lit_expanded_from_expected( && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { - Some(exp) + Some(exp.clone()) } else { match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( (*scope.type_env).clone().source_indices.clone(), expanded.clone(), - ) == tn) + ) == tn.clone()) { - Some(expanded) + Some(expanded.clone()) } else { None } } _ => { - let rt = resolved_type(exp); + let rt = resolved_type(exp.clone()); if (authored_name_at( (*scope.type_env).clone().source_indices.clone(), rt.clone(), - ) == tn) + ) == tn.clone()) { - Some(rt) + Some(rt.clone()) } else { None } @@ -1040,7 +1038,7 @@ pub fn record_lit_instantiated_fields( if (authored_name_at( (*scope.type_env).clone().source_indices.clone(), exp.clone(), - ) != tn) + ) != tn.clone()) { None } else { @@ -1157,7 +1155,7 @@ pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc node: receiver_type, .. }) => node_is_set_collection( - receiver_type, + receiver_type.clone(), (*scope.type_env).clone().source_indices.clone(), ), _ => false, @@ -1171,7 +1169,10 @@ pub fn set_union_other_operand_is_resolved_non_set( match arg_value(other_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. - }) => !node_is_set_collection(other_type, (*scope.type_env).clone().source_indices.clone()), + }) => !node_is_set_collection( + other_type.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), _ => false, } } @@ -1181,14 +1182,14 @@ pub fn set_element_type_from_receiver( scope: Rc, ) -> Option> { match set_element_type_in_env(receiver_type, scope.type_env.clone()) { - Some(elem_slot) => Some(child_type_node(elem_slot)), + Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, } } pub fn set_element_type_is_concrete(elem: Rc) -> bool { match elem.inferred.clone() { - Some(inf) => !is_type_variable(inf), + Some(inf) => !is_type_variable(inf.clone()), None => true, } } @@ -1232,8 +1233,8 @@ pub fn nominal_call_arg_brand_mismatch( && (formal_name.clone() != actual_name.clone())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) == structural_carrier_template_name(actual.clone(), source_indices.clone()))) - && !is_declared_container_alias_spelling(formal_name)) - && !is_declared_container_alias_spelling(actual_name)) + && !is_declared_container_alias_spelling(formal_name.clone())) + && !is_declared_container_alias_spelling(actual_name.clone())) } } @@ -1253,12 +1254,12 @@ pub fn container_element_nominal_brand_mismatch( Some(formal_ch) => match actual.children.clone().first().cloned() { Some(actual_ch) => { let formal_el = peel_nominal_alias_identity( - child_type_node(formal_ch), + child_type_node(formal_ch.clone()), type_env.clone(), module_name.clone(), ); let actual_el = peel_nominal_alias_identity( - child_type_node(actual_ch), + child_type_node(actual_ch.clone()), type_env.clone(), module_name.clone(), ); @@ -1382,7 +1383,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1390,12 +1391,15 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env(receiver_type, scope.type_env.clone()) { + }) => match map_value_type_in_env( + receiver_type.clone(), + scope.type_env.clone(), + ) { Some(value_type) => { if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type) + witness_of_element(value_type.clone()) } else { - with_optional_cardinality(value_type) + with_optional_cardinality(value_type.clone()) } } None => resolve_builtin_call_type(func_name.clone()), @@ -1409,7 +1413,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1417,19 +1421,22 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_key_type_in_env(receiver_type, scope.type_env.clone()) { - Some(key_type) => { - let lk = list_kernel_ty_from_element(key_type); - Rc::new(Tier2bBt { - bt: lk.ty.clone(), - kernel_diags: lk.miss_diags.clone(), - }) + }) => { + match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) + { + Some(key_type) => { + let lk = list_kernel_ty_from_element(key_type.clone()); + Rc::new(Tier2bBt { + bt: lk.ty.clone(), + kernel_diags: lk.miss_diags.clone(), + }) + } + None => Rc::new(Tier2bBt { + bt: resolve_builtin_call_type(func_name.clone()), + kernel_diags: Rc::new(vec![]), + }), } - None => Rc::new(Tier2bBt { - bt: resolve_builtin_call_type(func_name.clone()), - kernel_diags: Rc::new(vec![]), - }), - }, + } _ => Rc::new(Tier2bBt { bt: resolve_builtin_call_type(func_name.clone()), kernel_diags: Rc::new(vec![]), @@ -1443,7 +1450,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1451,10 +1458,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env(receiver_type, scope.type_env.clone()) - { + }) => match map_value_type_in_env( + receiver_type.clone(), + scope.type_env.clone(), + ) { Some(value_type) => { - let lv = list_kernel_ty_from_element(value_type); + let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(Tier2bBt { bt: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), @@ -1485,12 +1494,14 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg).inferred + Some(insert_arg) => match arg_value(insert_arg.clone()).inferred .clone() .as_deref() .cloned() { - Some(InferredNode::Resolved { node: elem, .. }) => Some(elem), + Some(InferredNode::Resolved { node: elem, .. }) => { + Some(elem.clone()) + } _ => None, }, None => None, @@ -1505,10 +1516,10 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: other_type, .. }) => match set_element_type_in_env( - other_type, + other_type.clone(), scope.type_env.clone(), ) { - Some(elem_slot) => Some(child_type_node(elem_slot)), + Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, }, _ => None, @@ -1525,7 +1536,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let union_other_bad = if (func_name.clone() == "set_union".to_string()) { match typed_args.clone().get(1 as usize).cloned() { Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg, + other_arg.clone(), scope.clone(), ), None => false, @@ -1553,8 +1564,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let elem_mismatch = match recv_elem.clone() { Some(re) => match operand_elem.clone() { Some(oe) => set_element_types_mismatch( - re, - oe, + re.clone(), + oe.clone(), (*scope.type_env).clone().source_indices.clone(), ), None => false, @@ -1606,7 +1617,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg).inferred + match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1614,8 +1625,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match recv_elem { - Some(_) => receiver_type, + }) => match recv_elem.clone() { + Some(_) => receiver_type.clone(), None => match operand_elem.clone() { Some(element) => (*set_kernel_ty_from_element( element.clone(), @@ -1639,10 +1650,14 @@ pub fn infer_tier2b_builtin_with_kernel_diags( let build_diags = if (func_name.clone() == "set_contains".to_string()) { Rc::new(vec![]) } else { - match operand_elem { + match operand_elem.clone() { Some(element) => { - if ((recv_is_set && !elem_mismatch) && !union_other_bad) { - set_kernel_ty_from_element(element).miss_diags.clone() + if ((recv_is_set.clone() && !elem_mismatch.clone()) + && !union_other_bad.clone()) + { + set_kernel_ty_from_element(element.clone()) + .miss_diags + .clone() } else { Rc::new(vec![]) } @@ -1687,7 +1702,7 @@ pub fn method_pipe_map_keys_values_fallback( if (method_name.clone() == "map_keys".to_string()) { match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { - let lk = list_kernel_ty_from_element(key_type); + let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(MethodPipeFallback { result_ty: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), @@ -1702,7 +1717,7 @@ pub fn method_pipe_map_keys_values_fallback( if (method_name.clone() == "map_values".to_string()) { match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { - let lv = list_kernel_ty_from_element(value_type); + let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(MethodPipeFallback { result_ty: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), @@ -1746,7 +1761,7 @@ pub fn validate_cast( ) -> Option> { match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { - let source_name = authored_name_at(source_indices, src_node); + let source_name = authored_name_at(source_indices, src_node.clone()); if (source_name.clone() == target_name.clone()) { None } else { @@ -1762,7 +1777,10 @@ pub fn validate_cast( { let msg = v1_rt::concat( v1_rt::concat( - v1_rt::concat("invalid cast: ".to_string(), source_name), + v1_rt::concat( + "invalid cast: ".to_string(), + source_name.clone(), + ), " as ".to_string(), ), target_name.clone(), @@ -1818,7 +1836,7 @@ pub fn inferred_or_error( fallback_span: Rc, ) -> Rc { match result { - Some(inferred) => inferred, + Some(inferred) => inferred.clone(), None => Rc::new(InferredNode::CompilerError { message: fallback_message, span: fallback_span, @@ -1836,11 +1854,13 @@ pub fn resolve_pattern_subject( .. } => pattern_subject_from_node(resolve_scrutinee_type_node( scope.type_env.clone(), - scrutinee_type, + scrutinee_type.clone(), )), PatternSubject::PatternDynamic { span: dynamic_span, .. - } => Rc::new(PatternSubject::PatternDynamic { span: dynamic_span }), + } => Rc::new(PatternSubject::PatternDynamic { + span: dynamic_span.clone(), + }), PatternSubject::PatternLookupBlocked => Rc::new(PatternSubject::PatternLookupBlocked), } } @@ -1892,7 +1912,7 @@ pub fn annotate_pattern_parent_enums( let is_coproduct = (resolved_scrut_node.connective.clone() == Connective::Disj); if is_coproduct { - Some(scrutinee_name) + Some(scrutinee_name.clone()) } else { None } @@ -1905,7 +1925,7 @@ pub fn annotate_pattern_parent_enums( }; let annotated_variant_name = variant_name.clone(); let variant_lookup = lookup_variant_in_type( - resolved_scrut, + resolved_scrut.clone(), variant_name.clone(), scope.module_name.clone(), scope.type_env.clone(), @@ -1914,7 +1934,7 @@ pub fn annotate_pattern_parent_enums( let variant_subject = lookup_result_subject(variant_lookup); let annotated_bindings = Rc::new({ let mut __result = Vec::new(); - for binding in bindings.iter().cloned() { + for binding in bindings.clone().iter().cloned() { __result.push({ let field_lookup = lookup_field_in_variant( variant_subject.clone(), @@ -1946,17 +1966,17 @@ pub fn annotate_pattern_parent_enums( match inferred_parent { Some(parent_name) => Rc::new(MatchPattern::VariantPattern { name: annotated_variant_name, - parent_enum: Some(parent_name), + parent_enum: Some(parent_name.clone()), field_bindings: annotated_bindings, }), None => Rc::new(MatchPattern::VariantPattern { - name: variant_name, + name: variant_name.clone(), parent_enum: None, field_bindings: annotated_bindings, }), } } - _ => pattern, + _ => pattern.clone(), } }) } @@ -2088,7 +2108,7 @@ pub fn scope_after_stmt_node( if ((stmt.children.clone().len() as i64) <= 1) { { let val = match stmt.children.clone().first().cloned() { - Some(v) => v, + Some(v) => v.clone(), None => stmt.clone(), }; extend_scope( @@ -2122,7 +2142,7 @@ pub fn derive_field_provenance( let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(n), + resolved_type(n.clone()), ), _ => "".to_string(), }; @@ -2131,7 +2151,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for(scope.type_env.clone(), scrut_type_name); + inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2147,7 +2167,7 @@ pub fn derive_field_provenance( .cloned(); match matching { Some(ind_field) => { - compose_sub_value(scrutinee_provenance.clone(), ind_field) + compose_sub_value(scrutinee_provenance.clone(), ind_field.clone()) } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -2167,9 +2187,9 @@ pub fn extend_scope_with_pattern_node( MatchPattern::Bind { name: n, .. } => Rc::new(PatternScopeResult { scope: extend_scope_match_bound( scope.clone(), - n, + n.clone(), pattern_binding_type(scrutinee_subject.clone()), - scrutinee_provenance, + scrutinee_provenance.clone(), ), diagnostics: Rc::new(vec![]), }), @@ -2196,7 +2216,7 @@ pub fn extend_scope_with_pattern_node( ); let variant_subject = lookup_result_subject(variant_lookup.clone()); let variant_diags = variant_lookup.diagnostics.clone(); - bindings.iter().cloned().fold( + bindings.clone().iter().cloned().fold( Rc::new(PatternScopeResult { scope: scope.clone(), diagnostics: variant_diags, @@ -2310,7 +2330,7 @@ pub fn extract_fold_init_info( .first() .cloned() { - Some(a) => Some(a), + Some(a) => Some(a.clone()), None => method_args.clone().first().cloned(), }; match init_arg { @@ -2379,7 +2399,9 @@ pub fn derive_element_provenance( .first() .cloned(); match list_field { - Some(f) => Rc::new(SubValueRelation::IteratedSubValue { field: f }), + Some(f) => { + Rc::new(SubValueRelation::IteratedSubValue { field: f.clone() }) + } None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -2620,15 +2642,15 @@ pub fn infer_expr( Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: infer_literal_node(lit), + node: infer_literal_node(lit.clone()), })), - span, + span.clone(), )) } ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); Rc::new(InferResult { - typed: make_expr_error_node(kind, message, span), + typed: make_expr_error_node(kind.clone(), message.clone(), span.clone()), diagnostics: Rc::new(vec![]), }) } @@ -2645,11 +2667,11 @@ pub fn infer_expr( let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { Some(scope_enum) => ok_infer(make_named_expr_node( - name, + name.clone(), Rc::new(ExprData::ExprVar { binding_kind: Some(Rc::new( VarBindingKind::VariantValueBinding { - parent_enum: scope_enum, + parent_enum: scope_enum.clone(), }, )), }), @@ -2658,13 +2680,13 @@ pub fn infer_expr( node: binding.resolved.clone(), })), span.clone(), - span, + span.clone(), )), None => { let binding_kind = infer_var_binding_kind(scope.clone(), name.clone()); ok_infer(make_named_expr_node( - name, + name.clone(), Rc::new(ExprData::ExprVar { binding_kind: Some(binding_kind), }), @@ -2673,7 +2695,7 @@ pub fn infer_expr( node: binding.resolved.clone(), })), span.clone(), - span, + span.clone(), )) } } @@ -2682,7 +2704,7 @@ pub fn infer_expr( Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( - name, + name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, @@ -2692,11 +2714,11 @@ pub fn infer_expr( node: fsig.inferred.clone(), })), span.clone(), - span, + span.clone(), )) } else { ok_infer(make_named_expr_node( - name, + name.clone(), Rc::new(ExprData::ExprVar { binding_kind: Some(Rc::new( VarBindingKind::FunctionValueBinding, @@ -2710,7 +2732,7 @@ pub fn infer_expr( ), })), span.clone(), - span, + span.clone(), )) } } @@ -2727,10 +2749,13 @@ pub fn infer_expr( typed: err_texpr, diagnostics: Rc::new(vec![inference_error( v1_rt::concat( - v1_rt::concat("undefined variable '".to_string(), name), + v1_rt::concat( + "undefined variable '".to_string(), + name.clone(), + ), "'".to_string(), ), - span, + span.clone(), scope.module_name.clone(), )]), }) @@ -2769,7 +2794,7 @@ pub fn infer_expr( typed: make_expr_error_node( ExprErrorKind::SemanticExprError, "error type cascade".to_string(), - span, + span.clone(), ), diagnostics: base_diags, }) @@ -2783,25 +2808,27 @@ pub fn infer_expr( match field_type_lookup { Some(field_type) => { let field_summary = match field_summary_for_type( - base_rt, + base_rt.clone(), scope.type_env.clone(), field_name.clone(), ) { - Some(s) => Some(s), + Some(s) => Some(s.clone()), None => field_summary_for_type( - resolved_base, + resolved_base.clone(), scope.type_env.clone(), field_name.clone(), ), }; let fa_texpr = make_named_expr_node( - field_name, + field_name.clone(), Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![Rc::new(base_typed)]), - Some(Rc::new(InferredNode::Resolved { node: field_type })), - span, + Rc::new(vec![Rc::new(base_typed.clone())]), + Some(Rc::new(InferredNode::Resolved { + node: field_type.clone(), + })), + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2817,18 +2844,18 @@ pub fn infer_expr( if base_is_type_var { { let fa_texpr = make_named_expr_node( - field_name, + field_name.clone(), Rc::new(ExprData::ExprFieldAccess { summary: Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::StoredField, value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed)]), + Rc::new(vec![Rc::new(base_typed.clone())]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2838,25 +2865,25 @@ pub fn infer_expr( } } else { match check_service_field_access_node( - base_rt, + base_rt.clone(), field_name.clone(), scope.service_registry.clone(), (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( - field_name, + field_name.clone(), Rc::new(ExprData::ExprFieldAccess { summary: Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::StoredField, value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed)]), + Rc::new(vec![Rc::new(base_typed.clone())]), Some(Rc::new(InferredNode::Resolved { - node: svc_type, + node: svc_type.clone(), })), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -2870,7 +2897,7 @@ pub fn infer_expr( v1_rt::concat( v1_rt::concat( "no field '".to_string(), - field_name, + field_name.clone(), ), "' on type '".to_string(), ), @@ -2879,7 +2906,7 @@ pub fn infer_expr( .clone() .source_indices .clone(), - resolved_base, + resolved_base.clone(), ), ), "'".to_string(), @@ -2894,8 +2921,8 @@ pub fn infer_expr( diagnostics: v1_rt::concat( base_diags, Rc::new(vec![inference_error( - error_message, - span, + error_message.clone(), + span.clone(), scope.module_name.clone(), )]), ), @@ -2970,11 +2997,11 @@ pub fn infer_expr( scope.clone(), ); let remaining_results = infer_method_args_with_fold( - call_method_name, - call_method_args, + call_method_name.clone(), + call_method_args.clone(), call_fold_info.clone(), call_fold_acc_type.clone(), - elem_type, + elem_type.clone(), call_elem_provenance, scope.clone(), ); @@ -3143,7 +3170,7 @@ pub fn infer_expr( }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for air in arg_infer_results.iter().cloned() { + for air in arg_infer_results.clone().iter().cloned() { __result.extend((*air.diagnostics.clone()).iter().cloned()); } __result @@ -3151,7 +3178,7 @@ pub fn infer_expr( let typed_arg_nodes = typed_args.clone(); if (sig.clone() != None) { { - let resolved_type = match sig { + let resolved_type = match sig.clone() { Some(s) => substitute_generics( s.inferred.clone(), call_subst.clone(), @@ -3161,7 +3188,7 @@ pub fn infer_expr( }; let value_params_for_check = Rc::new({ let mut __result = Vec::new(); - for p in sig_params.iter().cloned() { + for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -3175,17 +3202,17 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))( value_params_for_check, - typed_args, - call_subst, + typed_args.clone(), + call_subst.clone(), (*scope.type_env).clone(), scope.module_name.clone(), ) }; Rc::new(InferResult { typed: make_named_expr_node( - func_name, + func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, @@ -3194,7 +3221,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_type, })), - span, + span.clone(), node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat(arg_diags, arg_compat_diags), @@ -3217,26 +3244,27 @@ pub fn infer_expr( call_fold_acc_type.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let refined_call_fold_acc_type = - if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) { - match Rc::new({ - let mut __result = Vec::new(); - for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(Rc::new(a.clone()))) { - __result.push(a); - } + let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) + && call_acc_is_under_resolved) + { + match Rc::new({ + let mut __result = Vec::new(); + for a in typed_args.clone().iter().cloned() { + if is_lambda_expr(arg_value(Rc::new(a.clone()))) { + __result.push(a); } - __result - }) - .first() - .cloned() - { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg))), - None => call_fold_acc_type, } - } else { - call_fold_acc_type - }; + __result + }) + .first() + .cloned() + { + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + None => call_fold_acc_type.clone(), + } + } else { + call_fold_acc_type.clone() + }; let method_resolution = resolve_known_method_node( method_receiver.clone(), resolve_method_receiver_type( @@ -3255,9 +3283,10 @@ pub fn infer_expr( let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { { - let receiver = method_receiver; + let receiver = method_receiver.clone(); let remaining = Rc::new( typed_args + .clone() .iter() .cloned() .skip(1 as usize) @@ -3265,13 +3294,13 @@ pub fn infer_expr( ); let base_result_type = match method_resolution.result_type.clone() { - Some(mt) => mt, + Some(mt) => mt.clone(), None => error_type(), }; let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { @@ -3305,10 +3334,11 @@ pub fn infer_expr( __result }); let fold_overrides = - if (call_fold_info != None) { + if (call_fold_info.clone() != None) { fold_override_map( "FoldAccumulator".to_string(), - refined_call_fold_acc_type, + refined_call_fold_acc_type + .clone(), ) } else { empty_override_map() @@ -3326,18 +3356,18 @@ pub fn infer_expr( } } else { Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: base_result_type, + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), } @@ -3356,8 +3386,8 @@ pub fn infer_expr( MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - } => match at { - Some(t) => template_return_is_receiver_self(t), + } => match at.clone() { + Some(t) => template_return_is_receiver_self(t.clone()), None => false, }, _ => false, @@ -3369,7 +3399,7 @@ pub fn infer_expr( (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( - first_arg_type, + first_arg_type.clone(), (*scope.type_env).clone().source_indices.clone(), )) { Rc::new(Node { @@ -3397,11 +3427,11 @@ pub fn infer_expr( ident: None, }) } else { - receiver + receiver.clone() }; let remaining_arg_nodes = Rc::new({ let mut __result = Vec::new(); - for ta in remaining.iter().cloned() { + for ta in remaining.clone().iter().cloned() { __result.push(make_arg_node( arg_name_at( Rc::new(ta.clone()), @@ -3416,7 +3446,7 @@ pub fn infer_expr( }); Rc::new(InferResult { typed: make_named_expr_node( - func_name, + func_name.clone(), Rc::new(ExprData::ExprMethodCall { method_semantics: method_resolution.semantics .clone(), @@ -3426,9 +3456,9 @@ pub fn infer_expr( remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bridge_result_type), + node: Rc::new(bridge_result_type.clone()), })), - span, + span.clone(), node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat( @@ -3447,12 +3477,12 @@ pub fn infer_expr( match expected.clone() { Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: exp, -})), span, node_name_span(texpr.clone())), + node: exp.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: arg_diags, }) } else { @@ -3460,46 +3490,46 @@ pub fn infer_expr( let empty_map_diags = v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): expected type is not a keyed collection".to_string(), span.clone(), scope.module_name.clone())])); match bare_m { Some(map_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: map_t, -})), span, node_name_span(texpr.clone())), + node: map_t.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: empty_map_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(empty_map_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span, scope.module_name.clone())])), + diagnostics: v1_rt::concat(empty_map_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), }), } } }, None => match bare_m { Some(map_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: map_t, -})), span, node_name_span(texpr.clone())), + node: map_t.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: arg_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span, scope.module_name.clone())])), + diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_map(): Map kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), }), }, } @@ -3511,12 +3541,12 @@ match bare_m { match expected.clone() { Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: exp, -})), span, node_name_span(texpr.clone())), + node: exp.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: arg_diags, }) } else { @@ -3524,46 +3554,46 @@ match bare_m { let empty_set_diags = v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): expected type is not Set<...>".to_string(), span.clone(), scope.module_name.clone())])); match bare_s { Some(set_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: set_t, -})), span, node_name_span(texpr.clone())), + node: set_t.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: empty_set_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(empty_set_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span, scope.module_name.clone())])), + diagnostics: v1_rt::concat(empty_set_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), }), } } }, None => match bare_s { Some(set_t) => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: set_t, -})), span, node_name_span(texpr.clone())), + node: set_t.clone(), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: arg_diags, }), None => Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), })), span.clone(), node_name_span(texpr.clone())), - diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span, scope.module_name.clone())])), + diagnostics: v1_rt::concat(arg_diags, Rc::new(vec![inference_error("empty_set(): Set kernel container profile missing".to_string(), span.clone(), scope.module_name.clone())])), }), }, } @@ -3573,7 +3603,7 @@ match bare_s { { let tier2b = infer_tier2b_builtin_with_kernel_diags( func_name.clone(), - typed_args, + typed_args.clone(), scope.clone(), span.clone(), ); @@ -3586,7 +3616,7 @@ match bare_s { }; Rc::new(InferResult { typed: make_named_expr_node( - func_name, + func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: call_semantics, descent_evidence: None, @@ -3595,7 +3625,7 @@ match bare_s { Some(Rc::new(InferredNode::Resolved { node: Rc::new(bt), })), - span, + span.clone(), node_name_span(texpr.clone()), ), diagnostics: v1_rt::concat( @@ -3628,31 +3658,32 @@ match bare_s { }; if (callable_local.clone() != None) { { - let callable_type = match callable_local { - Some(ct) => ct, + let callable_type = match callable_local.clone() + { + Some(ct) => ct.clone(), None => error_type(), }; let resolved_type = callable_inferred(callable_type); Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { node: resolved_type, -})), span, node_name_span(texpr.clone())), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: arg_diags, }) } } else { match infer_variant_constructor_call( func_name.clone(), - call_args, + call_args.clone(), span.clone(), node_name_span(texpr.clone()), scope.clone(), ) { - Some(ctor_result) => ctor_result, + Some(ctor_result) => ctor_result.clone(), None => { let type_match = lookup_type_by_name( scope.type_env.clone(), @@ -3660,10 +3691,10 @@ match bare_s { ); let resolved_type = match type_match.clone() { - Some(tn) => tn, + Some(tn) => tn.clone(), None => error_type(), }; - let call_diags = match type_match { + let call_diags = match type_match.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![inference_error( v1_rt::concat( @@ -3679,12 +3710,12 @@ match bare_s { )]), }; Rc::new(InferResult { - typed: make_named_expr_node(func_name, Rc::new(ExprData::ExprCall { + typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), descent_evidence: None, }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { node: resolved_type, -})), span, node_name_span(texpr.clone())), +})), span.clone(), node_name_span(texpr.clone())), diagnostics: v1_rt::concat(arg_diags, call_diags), }) } @@ -3738,11 +3769,11 @@ match bare_s { scope.clone(), ); let mc_arg_infer_results = infer_method_args_with_fold( - mc_method_name, - mc_args, + mc_method_name.clone(), + mc_args.clone(), fold_info.clone(), fold_acc_type.clone(), - recv_elem_type, + recv_elem_type.clone(), mc_elem_provenance, scope.clone(), ); @@ -3755,7 +3786,7 @@ match bare_s { }); let mc_arg_diags = Rc::new({ let mut __result = Vec::new(); - for air in mc_arg_infer_results.iter().cloned() { + for air in mc_arg_infer_results.clone().iter().cloned() { __result.extend((*air.diagnostics.clone()).iter().cloned()); } __result @@ -3778,11 +3809,11 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg))), - None => fold_acc_type, + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + None => fold_acc_type.clone(), } } else { - fold_acc_type + fold_acc_type.clone() }; let method_resolution = resolve_known_method_node( Rc::new(recv_typed.clone()), @@ -3798,7 +3829,7 @@ match bare_s { ); let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { - result_ty: rt, + result_ty: rt.clone(), kernel_diags: Rc::new(vec![]), }), None => method_pipe_map_keys_values_fallback( @@ -3811,7 +3842,7 @@ match bare_s { let base_result_type = (*pipe_fb.result_ty).clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }) } else { @@ -3819,7 +3850,7 @@ match bare_s { MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - } => match at { + } => match at.clone() { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( @@ -3835,36 +3866,36 @@ match bare_s { } __result }); - let mc_fold_overrides = if (fold_info != None) { + let mc_fold_overrides = if (fold_info.clone() != None) { fold_override_map( "FoldAccumulator".to_string(), - refined_fold_acc_type, + refined_fold_acc_type.clone(), ) } else { empty_override_map() }; resolve_type_variables_from_template( - t, + t.clone(), mc_arg_types, - recv_rt, + recv_rt.clone(), mc_fold_overrides, (*scope.type_env).clone().source_indices.clone(), ) } } else { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }), } @@ -3876,15 +3907,15 @@ match bare_s { } else { Some(Rc::new(MethodSemantics::PlainMethodSemantics)) }; - let typed_mc_arg_nodes = typed_mc_args; + let typed_mc_arg_nodes = typed_mc_args.clone(); let mc_texpr = make_named_expr_node( - method_name, + method_name.clone(), Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![Rc::new(recv_typed)]), typed_mc_arg_nodes), + v1_rt::concat(Rc::new(vec![Rc::new(recv_typed.clone())]), typed_mc_arg_nodes), Some(Rc::new(InferredNode::Resolved { node: Rc::new(result_type) })), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -3907,7 +3938,7 @@ match bare_s { let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(Rc::new(scrut_typed.clone())); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); - let scrut_provenance = classify_binding_provenance(scrut, scope.clone()); + let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ let mut __result = Vec::new(); for arm_node in arm_nodes.clone().iter().cloned() { @@ -3980,6 +4011,7 @@ match bare_s { let unified_arm_type = match arm_body_types.clone().first().cloned() { Some(first_type) => Rc::new( arm_body_types + .clone() .iter() .cloned() .skip(1 as usize) @@ -4004,6 +4036,7 @@ match bare_s { let mut __result = Vec::new(); for pair in Rc::new( arm_nodes + .clone() .iter() .cloned() .enumerate() @@ -4147,8 +4180,8 @@ match bare_s { } __result }); - let result_type = unified_arm_type; - let empty_arms_diags = if ((arm_infer_results.len() as i64) == 0) { + let result_type = unified_arm_type.clone(); + let empty_arms_diags = if ((arm_infer_results.clone().len() as i64) == 0) { Rc::new(vec![inference_error( "match expression has no arms".to_string(), span.clone(), @@ -4157,26 +4190,30 @@ match bare_s { } else { Rc::new(vec![]) }; - let exhaustiveness_diags = - match (*resolve_pattern_subject(scope.clone(), scrut_subject)).clone() { - PatternSubject::PatternResolved { - node: resolved_scrutinee, - .. - } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))))))))( - resolved_scrutinee, - typed_arms.clone(), - (*scope.type_env).clone(), - span.clone(), - scope.module_name.clone(), - ), - PatternSubject::PatternDynamic { span: _, .. } => Rc::new(vec![]), - PatternSubject::PatternLookupBlocked => Rc::new(vec![]), - }; + let exhaustiveness_diags = match (*resolve_pattern_subject( + scope.clone(), + scrut_subject.clone(), + )) + .clone() + { + PatternSubject::PatternResolved { + node: resolved_scrutinee, + .. + } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))( + resolved_scrutinee.clone(), + typed_arms.clone(), + (*scope.type_env).clone(), + span.clone(), + scope.module_name.clone(), + ), + PatternSubject::PatternDynamic { span: _, .. } => Rc::new(vec![]), + PatternSubject::PatternLookupBlocked => Rc::new(vec![]), + }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed)]), typed_arms), + v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed.clone())]), typed_arms.clone()), Some(Rc::new(InferredNode::Resolved { node: result_type })), - span, + span.clone(), ); Rc::new(InferResult { typed: match_texpr, @@ -4210,7 +4247,7 @@ match bare_s { else_rt.clone(), (*scope.type_env).clone().source_indices.clone(), )) { - infer_expr(then_expr, scope.clone(), Some(else_rt.clone())) + infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { then_result.clone() }; @@ -4221,7 +4258,7 @@ match bare_s { then_rt.clone(), (*scope.type_env).clone().source_indices.clone(), )) { - infer_expr(else_branch, scope.clone(), Some(then_rt.clone())) + infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; @@ -4250,14 +4287,14 @@ match bare_s { "if branches resolve to incompatible types: " .to_string(), node_type_shape( - then_rt, + then_rt.clone(), (*scope.type_env).clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( - else_rt, + else_rt.clone(), (*scope.type_env).clone().source_indices.clone(), ), ), @@ -4267,9 +4304,9 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed), Rc::new(else_typed)]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone()), Rc::new(else_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: unified })), - span, + span.clone(), ); Rc::new(InferResult { typed: if_texpr, @@ -4282,9 +4319,9 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed)]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), - span, + span.clone(), ); Rc::new(InferResult { typed: if_texpr2, @@ -4306,8 +4343,10 @@ match bare_s { ExprData::ExprVar { binding_kind: _, .. } => { - (authored_name_at((*scope.type_env).clone().source_indices.clone(), bd) - == let_name.clone()) + (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + bd.clone(), + ) == let_name.clone()) } _ => false, }, @@ -4325,11 +4364,11 @@ match bare_s { if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( - let_name, + let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed)]), + Rc::new(vec![Rc::new(val_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: val_type })), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { @@ -4350,16 +4389,16 @@ match bare_s { let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( - let_name, + let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed), Rc::new(body_typed.clone())]), + Rc::new(vec![Rc::new(val_typed.clone()), Rc::new(body_typed.clone())]), body_typed.inferred.clone(), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { typed: let_texpr2, - diagnostics: v1_rt::concat(val_diags, body_diags), + diagnostics: v1_rt::concat(val_diags, body_diags.clone()), }) } } @@ -4373,7 +4412,7 @@ match bare_s { (*scope.type_env).clone().source_indices.clone(), ), field_inits, - span, + span.clone(), node_name_span(texpr.clone()), scope.clone(), expected.clone(), @@ -4432,7 +4471,7 @@ match bare_s { (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { - Some(elem) => child_type_node(elem), + Some(elem) => child_type_node(elem.clone()), None => unit_type(), } } else { @@ -4442,7 +4481,7 @@ match bare_s { None => unit_type(), } }; - let empty_list_diags = if ((elem_results.len() as i64) == 0) { + let empty_list_diags = if ((elem_results.clone().len() as i64) == 0) { match expected.clone() { Some(exp) => { if node_is_element_collection( @@ -4472,14 +4511,14 @@ match bare_s { } else { Rc::new(vec![]) }; - let list_k = list_kernel_ty_from_element(elem_type_node); + let list_k = list_kernel_ty_from_element(elem_type_node.clone()); let ll_texpr = make_expr_node( Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { node: list_k.ty.clone(), })), - span, + span.clone(), ); Rc::new(InferResult { typed: ll_texpr, @@ -4506,14 +4545,14 @@ match bare_s { ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { - op: op, + op: op.clone(), algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![Rc::new(left_typed), Rc::new(right_typed)]), + Rc::new(vec![Rc::new(left_typed.clone()), Rc::new(right_typed)]), Some(Rc::new(InferredNode::Resolved { node: binop_info.result_type.clone(), })), - span, + span.clone(), ); Rc::new(InferResult { typed: bo_texpr, @@ -4531,10 +4570,10 @@ match bare_s { UnaryOpKind::Neg => resolved_type(Rc::new(operand_typed.clone())), }; let uo_texpr = make_expr_node( - Rc::new(ExprData::ExprUnaryOp { op: op }), - Rc::new(vec![Rc::new(operand_typed)]), + Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), + Rc::new(vec![Rc::new(operand_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: result_type })), - span, + span.clone(), ); Rc::new(InferResult { typed: uo_texpr, @@ -4608,9 +4647,12 @@ match bare_s { } else { if ((lam_params.clone().len() as i64) == 1) { match lam_params.clone().first().cloned() { - Some(p) => { - extend_scope(scope.clone(), p, exp.clone(), elem_prov) - } + Some(p) => extend_scope( + scope.clone(), + p.clone(), + exp.clone(), + elem_prov.clone(), + ), None => scope.clone(), } } else { @@ -4664,7 +4706,7 @@ match bare_s { { let exp = expected.clone().unwrap(); if ((exp.params.clone().len() as i64) > 0) { - Some(callable_inferred(exp)) + Some(callable_inferred(exp.clone())) } else { None } @@ -4741,11 +4783,11 @@ match bare_s { Rc::new(ExprData::ExprLambda), v1_rt::concat(Rc::new(vec![Rc::new(body_typed.clone())]), typed_param_nodes), body_typed.inferred.clone(), - span, + span.clone(), ); Rc::new(InferResult { typed: lam_texpr, - diagnostics: body_diags, + diagnostics: body_diags.clone(), }) } ExprData::ExprStringInterp => { @@ -4795,7 +4837,7 @@ match bare_s { Some(Rc::new(InferredNode::Resolved { node: string_type(), })), - span, + span.clone(), ); Rc::new(InferResult { typed: si_texpr, @@ -4809,7 +4851,7 @@ match bare_s { { let state = infer_block_stmts( stmts.clone(), - (stmts.len() as i64), + (stmts.clone().len() as i64), scope.clone(), Rc::new(vec![]), Rc::new(vec![]), @@ -4822,7 +4864,7 @@ match bare_s { Some(Rc::new(InferredNode::Resolved { node: state.last_type.clone(), })), - span, + span.clone(), ); Rc::new(InferResult { typed: blk_texpr, @@ -4840,7 +4882,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), - span, + span.clone(), )) } } @@ -4857,18 +4899,20 @@ match bare_s { inner_typed.inferred.clone(), target_name, span.clone(), - si, + si.clone(), scope.module_name.clone(), ); let cast_diags = match cast_diag { - Some(d) => Rc::new(vec![d]), + Some(d) => Rc::new(vec![d.clone()]), None => Rc::new(vec![]), }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![Rc::new(inner_typed), target_type.clone()]), - Some(Rc::new(InferredNode::Resolved { node: target_type })), - span, + Rc::new(vec![Rc::new(inner_typed.clone()), target_type.clone()]), + Some(Rc::new(InferredNode::Resolved { + node: target_type.clone(), + })), + span.clone(), ); Rc::new(InferResult { typed: cast_texpr, @@ -4898,23 +4942,23 @@ match bare_s { let body_scope = extend_scope( scope.clone(), variable.clone(), - elem_type_node, + elem_type_node.clone(), elem_provenance, ); - let body_result = infer_expr(body_expr, body_scope, None); + let body_result = infer_expr(body_expr.clone(), body_scope, None); let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( - variable, + variable.clone(), Rc::new(ExprData::ExprForEach), - Rc::new(vec![Rc::new(coll_typed), Rc::new(body_typed.clone())]), + Rc::new(vec![Rc::new(coll_typed.clone()), Rc::new(body_typed.clone())]), body_typed.inferred.clone(), - span, + span.clone(), node_name_span(texpr.clone()), ); Rc::new(InferResult { typed: fe_texpr, - diagnostics: v1_rt::concat(coll_diags, body_diags), + diagnostics: v1_rt::concat(coll_diags, body_diags.clone()), }) } ExprData::ExprIndex => { @@ -4934,8 +4978,8 @@ match bare_s { Some(InferredNode::Resolved { node: index_type, .. }) => Some(check_index_access_node( - base_type, - index_type, + base_type.clone(), + index_type.clone(), span.clone(), scope.module_name.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -4959,15 +5003,15 @@ match bare_s { span.clone(), )), }; - let index_access_diags = match index_check { + let index_access_diags = match index_check.clone() { Some(checked) => checked.diagnostics.clone(), None => Rc::new(vec![]), }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![Rc::new(base_typed), Rc::new(index_typed)]), + Rc::new(vec![Rc::new(base_typed.clone()), Rc::new(index_typed.clone())]), idx_inferred, - span, + span.clone(), ); Rc::new(InferResult { typed: idx_texpr, @@ -5000,9 +5044,9 @@ match bare_s { }) => match end_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: end_type, .. }) => { Some(check_slice_access_node( - base_type, - start_type, - end_type, + base_type.clone(), + start_type.clone(), + end_type.clone(), span.clone(), scope.module_name.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -5034,15 +5078,19 @@ match bare_s { span.clone(), )), }; - let slice_access_diags = match slice_check { + let slice_access_diags = match slice_check.clone() { Some(checked) => checked.diagnostics.clone(), None => Rc::new(vec![]), }; let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![Rc::new(base_typed), Rc::new(start_typed), Rc::new(end_typed)]), + Rc::new(vec![ + Rc::new(base_typed.clone()), + Rc::new(start_typed.clone()), + Rc::new(end_typed.clone()), + ]), slc_inferred, - span, + span.clone(), ); Rc::new(InferResult { typed: slc_texpr, @@ -5060,7 +5108,7 @@ match bare_s { Rc::new(ExprData::ExprReturn), Rc::new(vec![inner_result.typed.clone()]), (*inner_result.typed).clone().inferred.clone(), - span, + span.clone(), ); Rc::new(InferResult { typed: ret_texpr, @@ -5077,7 +5125,7 @@ match bare_s { ), diagnostics: Rc::new(vec![inference_error( "unhandled expression variant in infer_expr".to_string(), - span, + span.clone(), scope.module_name.clone(), )]), }) @@ -5097,30 +5145,33 @@ pub fn infer_variant_constructor_call( None => None, Some(parent_enum) => { let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), parent_enum) { + match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { Some(parent_node) => { - match find_child_named(parent_node, func_name.clone(), si.clone()) { + match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { Some(variant_node) => { - if variant_has_positional_payload_shape(variant_node, si.clone()) { + if variant_has_positional_payload_shape( + variant_node.clone(), + si.clone(), + ) { if ((call_args.clone().len() as i64) == 1) { match call_args.clone().first().cloned() { - Some(arg) => match arg_name_at(arg.clone(), si) { + Some(arg) => match arg_name_at(arg.clone(), si.clone()) { Some(arg_name) => { - let msg = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("positional variant constructor '".to_string(), func_name.clone()), "' does not accept named arguments (got '".to_string()), arg_name), ": ...')".to_string()); + let msg = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("positional variant constructor '".to_string(), func_name.clone()), "' does not accept named arguments (got '".to_string()), arg_name.clone()), ": ...')".to_string()); Some(Rc::new(InferResult { typed: semantic_expr_error_node( msg.clone(), arg.span.clone(), ), diagnostics: Rc::new(vec![inference_error( - msg, + msg.clone(), arg.span.clone(), scope.module_name.clone(), )]), })) } None => { - let payload_expr = arg_value(arg); + let payload_expr = arg_value(arg.clone()); let payload_init = make_field_init_node( "0".to_string(), payload_expr.clone(), @@ -5154,7 +5205,7 @@ pub fn infer_variant_constructor_call( span.clone(), ), diagnostics: Rc::new(vec![inference_error( - arity_msg, + arity_msg.clone(), span.clone(), scope.module_name.clone(), )]), @@ -5249,7 +5300,7 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = (*resolve_node(n.clone(), env.clone(), module_name.clone()).resolved).clone(); + let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { @@ -5273,15 +5324,15 @@ pub fn peel_alias_once_for_field_access( pub fn structural_from_expanded_type(normed: Rc) -> Rc { match normed.connective.clone() { - Connective::Conj => normed, - Connective::Disj => normed, + Connective::Conj => normed.clone(), + Connective::Disj => normed.clone(), _ => match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => match target.connective.clone() { - Connective::Conj => target, - Connective::Disj => target, - _ => normed, + Connective::Conj => target.clone(), + Connective::Disj => target.clone(), + _ => normed.clone(), }, - _ => normed, + _ => normed.clone(), }, } } @@ -5297,9 +5348,9 @@ pub fn record_field_type_is_unresolved_param( && ((ft.children.clone().len() as i64) == 0)) { match ft.inferred.clone() { - Some(inf) => is_type_variable(inf), + Some(inf) => is_type_variable(inf.clone()), None => { - let fname = authored_name_at(env.source_indices.clone(), ft); + let fname = authored_name_at(env.source_indices.clone(), ft.clone()); let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { @@ -5310,7 +5361,7 @@ pub fn record_field_type_is_unresolved_param( } __found }; - let conv = is_type_variable_name(fname); + let conv = is_type_variable_name(fname.clone()); (in_params || conv) } } @@ -5350,7 +5401,7 @@ pub fn record_has_unresolved_param_field(record: Rc, env: Rc) -> pub fn alias_chain_generic_decl(env: Rc, carrier: Rc, target: Rc) -> Rc { if ((target.params.clone().len() as i64) > 0) { - target + target.clone() } else { resolve_generic_use_decl(env, carrier) } @@ -5400,7 +5451,7 @@ pub fn alias_chain_target_after_args( { let type_args = carrier.children.clone(); if ((type_args.clone().len() as i64) == 0) { - target + target.clone() } else { { let decl = alias_chain_generic_decl(env.clone(), carrier.clone(), target.clone()); @@ -5408,7 +5459,7 @@ pub fn alias_chain_target_after_args( env.clone(), carrier.clone(), target.clone(), - type_args, + type_args.clone(), ); let is_parameterized_alias = (((decl.inferred.clone() != None) && ((decl.children.clone().len() as i64) == 0)) @@ -5417,11 +5468,15 @@ pub fn alias_chain_target_after_args( match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: alias_body, .. - }) => substitute_generics(alias_body, subst, env.source_indices.clone()), - _ => target, + }) => substitute_generics( + alias_body.clone(), + subst, + env.source_indices.clone(), + ), + _ => target.clone(), } } else { - substitute_generics(decl, subst, env.source_indices.clone()) + substitute_generics(decl.clone(), subst, env.source_indices.clone()) } } } @@ -5430,9 +5485,9 @@ pub fn alias_chain_target_after_args( pub fn alias_chain_carrier(n: Rc) -> Rc { if ((n.connective.clone() == Connective::NoConnective) && (n.name.clone() != "".to_string())) { - n + n.clone() } else { - structural_from_expanded_type(n) + structural_from_expanded_type(n.clone()) } } @@ -5455,7 +5510,7 @@ pub fn expand_alias_chain_for_field_access( structural_from_expanded_type(resolve_scrutinee_type_node(env.clone(), peeled.clone())); let is_record = ((structural.connective.clone() == Connective::Conj) || (structural.connective.clone() == Connective::Disj)); - if is_record.clone() { + if is_record { let resolved_record = if ((record_has_unresolved_param_field(structural.clone(), env.clone()) && ((carrier.children.clone().len() as i64) > 0)) @@ -5471,7 +5526,7 @@ pub fn expand_alias_chain_for_field_access( ); substitute_generics( structural.clone(), - subst.clone(), + subst, env.source_indices.clone(), ) } @@ -5480,19 +5535,19 @@ pub fn expand_alias_chain_for_field_access( } else { structural.clone() }; - let fail_closed = (lossy.clone() - && record_has_unresolved_param_field(resolved_record.clone(), env.clone())); - if fail_closed.clone() { - break nominal_type_ref(origin_name.clone()); + let fail_closed = + (lossy && record_has_unresolved_param_field(resolved_record.clone(), env.clone())); + if fail_closed { + break nominal_type_ref(origin_name); } else { break resolved_record.clone(); } } else { let next_name = carrier.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional.clone() || (next_name.clone() == "".to_string())) + let stop = ((is_optional || (next_name.clone() == "".to_string())) || emit_map_has(seen.clone(), next_name.clone())); - if stop.clone() { + if stop { break structural.clone(); } else { match lookup_type_by_name(env.clone(), next_name.clone()) { @@ -5505,7 +5560,7 @@ pub fn expand_alias_chain_for_field_access( let dropped_args = (((type_arg_count.clone() > 0) && (param_count.clone() > 0)) && (param_count.clone() != type_arg_count.clone())); - let next_lossy = (lossy.clone() || dropped_args.clone()); + let next_lossy = (lossy || dropped_args.clone()); let next_n = if ((type_arg_count.clone() > 0) && !dropped_args.clone()) { alias_chain_target_after_args( target.clone(), @@ -5516,9 +5571,9 @@ pub fn expand_alias_chain_for_field_access( target.clone() }; { - let __tco_0 = next_n.clone(); - let __tco_1 = next_seen.clone(); - let __tco_2 = next_lossy.clone(); + let __tco_0 = next_n; + let __tco_1 = next_seen; + let __tco_2 = next_lossy; n = __tco_0; seen = __tco_1; lossy = __tco_2; @@ -5590,11 +5645,11 @@ pub fn record_lit_alias_struct_fields( && (decl.inferred.clone() != None)) { match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => target, - _ => decl, + Some(InferredNode::Resolved { node: target, .. }) => target.clone(), + _ => decl.clone(), } } else { - decl + decl.clone() }; let expanded = expand_type_for_field_access( to_expand, @@ -5716,17 +5771,17 @@ pub fn infer_record_lit( expected.clone(), scope.clone(), ) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => match expected.clone() { Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, @@ -5737,13 +5792,13 @@ pub fn infer_record_lit( expected.clone(), scope.clone(), ) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, @@ -5907,7 +5962,7 @@ pub fn infer_record_lit( { let child_nodes = Rc::new({ let mut __result = Vec::new(); - for fir in fi_infer_results.iter().cloned() { + for fir in fi_infer_results.clone().iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( fir.typed_field.clone(), @@ -5973,20 +6028,20 @@ pub fn infer_record_lit( let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { - Some(_) => type_lookup, + Some(_) => type_lookup.clone(), None => { let local_lookup = lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for(scope.type_env.clone(), local_node) + lookup_type_for(scope.type_env.clone(), local_node.clone()) } None => None, } } }; let raw_resolved = match effective_lookup.clone() { - Some(tn) => tn, + Some(tn) => tn.clone(), None => error_type(), }; let expected_optional_parent = Some("Optional".to_string()); @@ -5997,7 +6052,7 @@ pub fn infer_record_lit( { let val_field = Rc::new({ let mut __result = Vec::new(); - for fir in fi_infer_results.iter().cloned() { + for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( fir.typed_field.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -6020,7 +6075,7 @@ pub fn infer_record_lit( } else { raw_resolved }; - let type_diags = match effective_lookup { + let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::UnresolvedType { @@ -6056,13 +6111,13 @@ pub fn infer_record_lit( }; let typed_field_nodes2 = typed_fields; let rl_name = match type_name.clone() { - Some(tn_val) => tn_val, + Some(tn_val) => tn_val.clone(), None => "".to_string(), }; let texpr = make_named_expr_node( rl_name, Rc::new(ExprData::ExprRecordLit { - parent_enum: local_variant_parent, + parent_enum: local_variant_parent.clone(), }), typed_field_nodes2, Some(Rc::new(InferredNode::Resolved { @@ -6127,11 +6182,13 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( - receiver, + receiver.clone(), (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { - Some(_) => Some(Rc::new(SizeExpr::ParamSize { param: rname })), + Some(_) => Some(Rc::new(SizeExpr::ParamSize { + param: rname.clone(), + })), None => None, } } @@ -6152,8 +6209,10 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { - let lname = - expr_var_name_at(left, (*ctx.type_env).clone().source_indices.clone()); + let lname = expr_var_name_at( + left.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() .cloned() @@ -6167,8 +6226,8 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option 0) { Some(Rc::new(SizeExpr::DividedSize { - param: p, - divisor: d, + param: p.clone(), + divisor: d.clone(), })) } else { None @@ -6212,14 +6271,14 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p == param_name.clone()) { + if (p.clone() == param_name.clone()) { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; - if (k > 0) { - match proportional_divisor_from_int_at_least_two(d) { + if (k.clone() > 0) { + match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6231,7 +6290,7 @@ pub fn proportional_skip_alias_plus_literal( Some(Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w, + divisor: div_w.clone(), }), })) } @@ -6276,7 +6335,7 @@ pub fn classify_collection_shrink( binding_kind: _, .. } => { let rname = expr_var_name_at( - receiver, + receiver.clone(), (*ctx.type_env).clone().source_indices.clone(), ); if (rname == param_name.clone()) { @@ -6284,7 +6343,7 @@ pub fn classify_collection_shrink( let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { Some(arg_node) => { - let arg_val = arg_value(arg_node); + let arg_val = arg_value(arg_node.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -6295,19 +6354,19 @@ pub fn classify_collection_shrink( if ((k.clone() > 0) && (mname.clone() == "skip".to_string())) { - match positive_descent_amount_from_positive_int(k) { + match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), variant_name: "".to_string(), - field_name: mname, + field_name: mname.clone(), shape: RecursionShape::ListRecursion, element_type: param_name.clone(), }); Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps, + steps: steps.clone(), }), }) }, @@ -6321,7 +6380,7 @@ Rc::new(SubValueRelation::StrictSubValue { binding_kind: _, .. } => { let aname = expr_var_name_at( - arg_val, + arg_val.clone(), (*ctx.type_env) .clone() .source_indices @@ -6339,20 +6398,20 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p == param_name.clone()) { - match proportional_divisor_from_int_at_least_two(d) { + if (p.clone() == param_name.clone()) { + match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), variant_name: "".to_string(), - field_name: mname, + field_name: mname.clone(), shape: RecursionShape::ListRecursion, element_type: param_name.clone(), }); Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w, + divisor: div_w.clone(), }), }) }, @@ -6367,32 +6426,37 @@ Rc::new(SubValueRelation::StrictSubValue { ), } } - ExprData::ExprBinOp { op, .. } => match op { - BinOp::Add => { - if (mname == "skip".to_string()) { + ExprData::ExprBinOp { op, .. } => { + match op.clone() { + BinOp::Add => { + if (mname.clone() == "skip".to_string()) { - let left = - binop_left(arg_val.clone()); - let right = binop_right(arg_val); - match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { - Some(rel) => rel, - None => match proportional_skip_alias_plus_literal(right, left, param_name.clone(), ctx.clone()) { - Some(rel) => rel, + { + let left = + binop_left(arg_val.clone()); + let right = binop_right( + arg_val.clone(), + ); + match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { + Some(rel) => rel.clone(), + None => match proportional_skip_alias_plus_literal(right.clone(), left.clone(), param_name.clone(), ctx.clone()) { + Some(rel) => rel.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), }, } + } + } else { + Rc::new(SubValueRelation::SubValueUnknown) } - } else { - Rc::new( - SubValueRelation::SubValueUnknown, - ) } + BinOp::Sub => Rc::new( + SubValueRelation::SubValueUnknown, + ), + _ => Rc::new( + SubValueRelation::SubValueUnknown, + ), } - BinOp::Sub => { - Rc::new(SubValueRelation::SubValueUnknown) - } - _ => Rc::new(SubValueRelation::SubValueUnknown), - }, + } _ => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -6425,7 +6489,7 @@ pub fn method_callback_element_position(semantics: Option>) Some(MethodSemantics::AlgebraMethodSemantics { algebra_template: at, .. - }) => match at { + }) => match at.clone() { Some(template) => template.callback_element_position.clone(), None => None, }, @@ -6441,7 +6505,7 @@ pub fn maybe_insert_composed_field_relation( match composed { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::SubValueUnknown => acc, - _ => v1_rt::rc_map_insert(acc, fname, rel), + _ => v1_rt::rc_map_insert(acc, fname, rel.clone()), }, None => acc, } @@ -6457,7 +6521,7 @@ pub fn maybe_insert_output_field_relation( ) -> Rc>> { { let composed = match sig.output_provenance.clone().get(idx as usize).cloned() { - Some(param_map) => classify_call_via_provenance(val, param_map, ctx), + Some(param_map) => classify_call_via_provenance(val, param_map.clone(), ctx), None => None, }; maybe_insert_composed_field_relation(acc, fname, composed) @@ -6478,7 +6542,7 @@ pub fn maybe_insert_match_field_relation( let lookup_type = match (*rel.clone()).clone() { SubValueRelation::PreservedValue => { match v1_rt::map_get(¶m_types, pname.clone()) { - Some(t) => t, + Some(t) => t.clone(), None => "".to_string(), } } @@ -6488,7 +6552,7 @@ pub fn maybe_insert_match_field_relation( }; if (lookup_type.clone() != "".to_string()) { { - let ind_fields = inductive_fields_for(type_env, lookup_type); + let ind_fields = inductive_fields_for(type_env, lookup_type.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -6507,7 +6571,7 @@ pub fn maybe_insert_match_field_relation( Some(ind_field) => v1_rt::rc_map_insert( fp_acc, pname.clone(), - compose_sub_value(rel, ind_field), + compose_sub_value(rel.clone(), ind_field.clone()), ), None => fp_acc, } @@ -6570,7 +6634,7 @@ pub fn build_per_field_for_let( v1_rt::rc_map_insert( ctx.per_field_vars.clone(), binding_name, - field_map, + field_map.clone(), ) } else { ctx.per_field_vars.clone() @@ -6630,7 +6694,7 @@ pub fn build_per_field_for_let( v1_rt::rc_map_insert( ctx.per_field_vars.clone(), binding_name, - field_map, + field_map.clone(), ) } else { ctx.per_field_vars.clone() @@ -6732,7 +6796,7 @@ pub fn resolve_collection_field( } => { let rname = expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); - match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname.clone()) { + match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { match f.shape.clone() { @@ -6777,7 +6841,7 @@ pub fn resolve_collection_field( || (inner_mname.clone() == "take".to_string())) || (inner_mname.clone() == "filter".to_string())) || (inner_mname.clone() == "reverse".to_string())); - if is_collection_preserving.clone() { + if is_collection_preserving { { let __tco_0 = method_receiver(expr); expr = __tco_0; @@ -6818,8 +6882,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let bname = - expr_var_name_at(base, (*scope.type_env).clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( @@ -6842,7 +6908,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - compose_sub_value(binding.provenance.clone(), ind_field) + compose_sub_value(binding.provenance.clone(), ind_field.clone()) } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -6880,15 +6946,17 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let bname = - expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), None => None, }; match from_per_field { - Some(rel) => Some(rel), + Some(rel) => Some(rel.clone()), None => { let type_name = match v1_rt::map_get(&ctx.scope_locals.clone(), bname.clone()) { @@ -6896,15 +6964,20 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match v1_rt::map_get(&ctx.param_names.clone(), bname) { - Some(t) => t, + None => match v1_rt::map_get( + &ctx.param_names.clone(), + bname.clone(), + ) { + Some(t) => t.clone(), None => "".to_string(), }, }; if (type_name.clone() != "".to_string()) { { - let fields = - inductive_fields_for(ctx.type_env.clone(), type_name); + let fields = inductive_fields_for( + ctx.type_env.clone(), + type_name.clone(), + ); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -6919,7 +6992,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field, + field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })) } @@ -6941,40 +7014,41 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match sig.output_provenance.clone().first().cloned() { Some(param_map) => { - classify_call_via_provenance(val.clone(), param_map, ctx.clone()) + classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) } None => None, }, None => None, }; match from_provenance.clone() { - Some(_) => from_provenance, + Some(_) => from_provenance.clone(), None => { - if (is_child_accessor_in_model(callee.clone()) || is_tree_size_reducing(callee)) + if (is_child_accessor_in_model(callee.clone()) + || is_tree_size_reducing(callee.clone())) { { let call_args = val.children.clone(); match call_args.first().cloned() { Some(first_arg) => { - let inner = arg_value(first_arg); + let inner = arg_value(first_arg.clone()); match (*inner.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let iname = expr_var_name_at( - inner, + inner.clone(), (*ctx.type_env).clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), iname.clone(), ) { - Some(t) => t, + Some(t) => t.clone(), None => match v1_rt::map_get( &ctx.sub_value_vars.clone(), - iname, + iname.clone(), ) { - Some(rel) => match (*rel).clone() { + Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. @@ -6992,7 +7066,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::StrictSubValue { - field: ind_field, + field: ind_field.clone(), factor: Rc::new( ShrinkFactor::UnitShrink, ), @@ -7046,7 +7120,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( (*ctx.type_env).clone().source_indices.clone(), - c, + c.clone(), ), None => "".to_string(), }; @@ -7055,7 +7129,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option None, }; match type_based.clone() { - Some(_) => type_based, + Some(_) => type_based.clone(), None => match (*val.expr_data.clone()).clone() { ExprData::ExprBinOp { op: op, .. } => { let left = binop_left(val.clone()); let right = binop_right(val.clone()); - match op { + match op.clone() { BinOp::Sub => match (*left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let lname = expr_var_name_at( - left, + left.clone(), (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) @@ -7119,13 +7193,15 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::ArithmeticDescent { - param: lname, + param: lname.clone(), factor: Rc::new( ShrinkFactor::ConstantShrink { - steps: steps, + steps: steps.clone(), }, ), }, @@ -7147,7 +7223,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( - left, + left.clone(), (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( @@ -7159,19 +7235,19 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let inner_left = binop_left(left); + let inner_left = binop_left(left.clone()); match (*inner_left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let lname = expr_var_name_at( - inner_left, + inner_left.clone(), (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( @@ -7183,7 +7259,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option Some(Rc::new( SubValueRelation::ArithmeticDescent { - param: left_name, + param: left_name.clone(), factor: Rc::new( ShrinkFactor::ProportionalShrink { - divisor: div_w, + divisor: div_w.clone(), }, ), }, @@ -7247,7 +7325,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field, + field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })) } @@ -7256,7 +7334,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match (*arg_value(a) + Some(a) => match (*arg_value(a.clone()) .expr_data .clone()) .clone() @@ -7272,7 +7350,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option 0) { - k + k.clone() } else { 0 } @@ -7288,7 +7366,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( - receiver, + receiver.clone(), (*ctx.type_env) .clone() .source_indices @@ -7303,19 +7381,19 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let synth_field = Rc::new(InductiveField { type_name: rname.clone(), variant_name: "".to_string(), - field_name: mname, + field_name: mname.clone(), shape: RecursionShape::ListRecursion, - element_type: rname, + element_type: rname.clone(), }); Some(Rc::new(SubValueRelation::StrictSubValue { field: synth_field, factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps, + steps: steps.clone(), }), })) }, @@ -7411,7 +7489,7 @@ pub fn classify_call_arg_provenance( if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) } else { - v1_rt::map_get(&ctx.sub_value_vars.clone(), name) + v1_rt::map_get(&ctx.sub_value_vars.clone(), name.clone()) } } _ => classify_let_value(arg_expr.clone(), ctx.clone()), @@ -7431,7 +7509,7 @@ pub fn merge_argument_relations(rels: Rc>>) -> Rc, rel: Rc| meet_sub_value(acc, rel.clone()), ), } @@ -7454,8 +7532,8 @@ pub fn classify_argument( if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) } else { - match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname) { - Some(rel) => rel, + match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { + Some(rel) => rel.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -7470,23 +7548,28 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { - Some(t) => t, - None => match v1_rt::map_get(&ctx.sub_value_vars.clone(), bname) { - Some(rel) => match (*rel).clone() { - SubValueRelation::StrictSubValue { field: f, .. } => { - f.element_type.clone() - } - SubValueRelation::IteratedSubValue { field: f, .. } => { - f.element_type.clone() - } - _ => "".to_string(), - }, - None => "".to_string(), - }, + Some(t) => t.clone(), + None => { + match v1_rt::map_get(&ctx.sub_value_vars.clone(), bname.clone()) + { + Some(rel) => match (*rel.clone()).clone() { + SubValueRelation::StrictSubValue { + field: f, .. + } => f.element_type.clone(), + SubValueRelation::IteratedSubValue { + field: f, .. + } => f.element_type.clone(), + _ => "".to_string(), + }, + None => "".to_string(), + } + } }; let fields = inductive_fields_for(ctx.type_env.clone(), type_name); let matching = Rc::new({ @@ -7502,7 +7585,7 @@ pub fn classify_argument( .cloned(); match matching { Some(ind_field) => Rc::new(SubValueRelation::StrictSubValue { - field: ind_field, + field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), }), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -7515,12 +7598,14 @@ pub fn classify_argument( let call_args = arg_expr.children.clone(); match call_args.first().cloned() { Some(first_arg) => { - let inner = arg_value(first_arg); + let inner = arg_value(first_arg.clone()); let inner_rel = classify_argument(inner, param_name.clone(), ctx.clone()); match (*inner_rel.clone()).clone() { - SubValueRelation::StrictSubValue { .. } => inner_rel, - SubValueRelation::IteratedSubValue { field: _, .. } => inner_rel, - SubValueRelation::ArithmeticDescent { .. } => inner_rel, + SubValueRelation::StrictSubValue { .. } => inner_rel.clone(), + SubValueRelation::IteratedSubValue { field: _, .. } => { + inner_rel.clone() + } + SubValueRelation::ArithmeticDescent { .. } => inner_rel.clone(), SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), @@ -7534,7 +7619,7 @@ pub fn classify_argument( match sig.output_provenance.clone().first().cloned() { Some(param_map) => classify_call_via_provenance( arg_expr.clone(), - param_map, + param_map.clone(), ctx.clone(), ), None => None, @@ -7543,7 +7628,7 @@ pub fn classify_argument( None => None, }; match from_provenance { - Some(prov_rel) => prov_rel, + Some(prov_rel) => prov_rel.clone(), None => { if (is_child_accessor_in_model(callee.clone()) || is_tree_size_reducing(callee.clone())) @@ -7553,7 +7638,7 @@ pub fn classify_argument( &ctx.param_names.clone(), param_name.clone(), ) { - Some(t) => t, + Some(t) => t.clone(), None => "".to_string(), }; let fields = inductive_fields_for( @@ -7577,7 +7662,7 @@ pub fn classify_argument( match cf { Some(ind_field) => { Rc::new(SubValueRelation::StrictSubValue { - field: ind_field, + field: ind_field.clone(), factor: Rc::new( ShrinkFactor::UnitShrink, ), @@ -7589,7 +7674,7 @@ pub fn classify_argument( } } } else { - if is_property_contraction(callee) { + if is_property_contraction(callee.clone()) { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ConstantShrink { @@ -7627,7 +7712,7 @@ pub fn classify_argument( ExprData::ExprBinOp { op: op, .. } => { let left = binop_left(arg_expr.clone()); let right = binop_right(arg_expr.clone()); - match op { + match op.clone() { BinOp::Sub => { let left_is_param = match (*left.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7640,7 +7725,7 @@ pub fn classify_argument( || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - left, + left.clone(), (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) @@ -7654,12 +7739,12 @@ pub fn classify_argument( else { unreachable!() }; - match positive_descent_amount_from_positive_int(k) { + match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps, + steps: steps.clone(), }), }) } @@ -7684,13 +7769,13 @@ pub fn classify_argument( || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - left, + left.clone(), (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } ExprData::ExprBinOp { op: BinOp::Sub, .. } => { - let inner_left = binop_left(left); + let inner_left = binop_left(left.clone()); match (*inner_left.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. @@ -7702,7 +7787,7 @@ pub fn classify_argument( || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( - inner_left, + inner_left.clone(), (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) @@ -7719,12 +7804,12 @@ pub fn classify_argument( else { unreachable!() }; - match proportional_divisor_from_int_at_least_two(k) { + match proportional_divisor_from_int_at_least_two(k.clone()) { Some(div_w) => { Rc::new(SubValueRelation::ArithmeticDescent { param: param_name.clone(), factor: Rc::new(ShrinkFactor::ProportionalShrink { - divisor: div_w, + divisor: div_w.clone(), }), }) } @@ -7762,17 +7847,19 @@ pub fn classify_argument( ctx.clone(), ); let else_rel = match if_else_branch(arg_expr.clone()) { - Some(e) => classify_argument(e, param_name.clone(), ctx.clone()), + Some(e) => classify_argument(e.clone(), param_name.clone(), ctx.clone()), None => Rc::new(SubValueRelation::SubValueUnknown), }; merge_argument_relations(Rc::new(vec![then_rel, else_rel])) } ExprData::ExprBlock => match arg_expr.children.clone().last().cloned() { - Some(last_expr) => classify_argument(last_expr, param_name.clone(), ctx.clone()), + Some(last_expr) => { + classify_argument(last_expr.clone(), param_name.clone(), ctx.clone()) + } None => Rc::new(SubValueRelation::SubValueUnknown), }, ExprData::ExprLet => match let_body(arg_expr.clone()) { - Some(body) => classify_argument(body, param_name.clone(), ctx.clone()), + Some(body) => classify_argument(body.clone(), param_name.clone(), ctx.clone()), None => Rc::new(SubValueRelation::SubValueUnknown), }, ExprData::ExprCast => { @@ -7820,8 +7907,10 @@ pub fn read_arg_provenance( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base, (*ctx.type_env).clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7847,9 +7936,10 @@ pub fn read_arg_provenance( .first() .cloned(); match matching { - Some(ind_field) => { - compose_sub_value(binding.provenance.clone(), ind_field) - } + Some(ind_field) => compose_sub_value( + binding.provenance.clone(), + ind_field.clone(), + ), None => Rc::new(SubValueRelation::SubValueUnknown), } } @@ -7978,10 +8068,10 @@ pub fn build_call_evidence( pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { if (found.clone() != "".to_string()) { - found + found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { - ExprData::ExprLambda => found, + ExprData::ExprLambda => found.clone(), _ => { let arg_val = arg_value(arg_node.clone()); match (*arg_val.expr_data.clone()).clone() { @@ -7989,11 +8079,11 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( - arg_val, + arg_val.clone(), (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { - Some(t) => t, + Some(t) => t.clone(), None => "".to_string(), } } @@ -8175,7 +8265,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { has_non_tail_self_call: body.has_non_tail_self_call.clone(), match_pattern: body.match_pattern.clone(), expr_data: Rc::new(ExprData::ExprCall { - call_semantics: cs, + call_semantics: cs.clone(), descent_evidence: Some(evidence), }), ident: None, @@ -8193,18 +8283,20 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), - None => match v1_rt::map_get(&ctx.sub_value_vars.clone(), sname) { - Some(rel) => match (*rel).clone() { - SubValueRelation::StrictSubValue { field: f, .. } => { - f.element_type.clone() - } - SubValueRelation::IteratedSubValue { field: f, .. } => { - f.element_type.clone() - } - _ => "".to_string(), - }, - None => "".to_string(), - }, + None => { + match v1_rt::map_get(&ctx.sub_value_vars.clone(), sname.clone()) { + Some(rel) => match (*rel.clone()).clone() { + SubValueRelation::StrictSubValue { field: f, .. } => { + f.element_type.clone() + } + SubValueRelation::IteratedSubValue { field: f, .. } => { + f.element_type.clone() + } + _ => "".to_string(), + }, + None => "".to_string(), + } + } } } _ => "".to_string(), @@ -8221,19 +8313,19 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { binding_kind: _, .. } => { let bname = expr_var_name_at( - base, + base.clone(), (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { - Some(t) => t, + Some(t) => t.clone(), None => "".to_string(), }; if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), - base_type, + base_type.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -8262,11 +8354,12 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), (*ctx.type_env).clone().source_indices.clone(), ); - if ((mname.clone() == "first".to_string()) || (mname == "last".to_string())) + if ((mname.clone() == "first".to_string()) + || (mname.clone() == "last".to_string())) { { let receiver = method_receiver(scrut.clone()); - resolve_collection_field(receiver, ctx.clone()) + resolve_collection_field(receiver.clone(), ctx.clone()) } } else { None @@ -8474,9 +8567,11 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { - Some(se) => { - v1_rt::rc_map_insert(ctx.size_aliases.clone(), binding_name.clone(), se) - } + Some(se) => v1_rt::rc_map_insert( + ctx.size_aliases.clone(), + binding_name.clone(), + se.clone(), + ), None => ctx.size_aliases.clone(), }; let inner_per_field = @@ -8498,7 +8593,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), - sub_type, + sub_type.clone(), ) } else { ctx.param_names.clone() @@ -8515,9 +8610,9 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.scope_locals.clone(), binding_name.clone(), Rc::new(TypeBinding { - name: binding_name, + name: binding_name.clone(), resolved: resolved_type(val.clone()), - provenance: rel, + provenance: rel.clone(), }), ), func_env: ctx.func_env.clone(), @@ -8535,7 +8630,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.scope_locals.clone(), binding_name.clone(), Rc::new(TypeBinding { - name: binding_name, + name: binding_name.clone(), resolved: resolved_type(val.clone()), provenance: Rc::new(SubValueRelation::SubValueUnknown), }), @@ -8544,11 +8639,11 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota per_field_vars: inner_per_field, }), }; - let annotated_value = annotate_descent(val, ctx.clone()); + let annotated_value = annotate_descent(val.clone(), ctx.clone()); let annotated_children = match let_body(body.clone()) { Some(body_child) => Rc::new(vec![ annotated_value, - annotate_descent(body_child, inner_ctx), + annotate_descent(body_child.clone(), inner_ctx.clone()), ]), None => Rc::new(vec![annotated_value]), }; @@ -8704,7 +8799,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota body.clone(), (*ctx.type_env).clone().source_indices.clone(), ); - let elem_position = method_callback_element_position(ms); + let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { let raw_receiver = method_receiver(body.clone()); @@ -8718,18 +8813,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota (*ctx.type_env).clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { - method_receiver(raw_receiver) + method_receiver(raw_receiver.clone()) } else { - raw_receiver + raw_receiver.clone() } } - _ => raw_receiver, + _ => raw_receiver.clone(), }; let receiver_field = match (*receiver.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: _, .. } => { let base = field_access_base(receiver.clone()); let fname = field_access_field_at( - receiver, + receiver.clone(), (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { @@ -8737,19 +8832,19 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota binding_kind: _, .. } => { let bname = expr_var_name_at( - base, + base.clone(), (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), bname.clone(), ) { - Some(t) => t, + Some(t) => t.clone(), None => match v1_rt::map_get( &ctx.sub_value_vars.clone(), - bname, + bname.clone(), ) { - Some(rel) => match (*rel).clone() { + Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. @@ -8768,7 +8863,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let mut __result = Vec::new(); for f in inductive_fields_for( ctx.type_env.clone(), - base_type, + base_type.clone(), ) .iter() .cloned() @@ -8792,20 +8887,20 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota binding_kind: _, .. } => { let rname = expr_var_name_at( - receiver, + receiver.clone(), (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { - Some(rel) => match (*rel).clone() { + Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { match f.shape.clone() { - RecursionShape::ListRecursion => Some(f), + RecursionShape::ListRecursion => Some(f.clone()), _ => None, } } SubValueRelation::IteratedSubValue { field: f, .. } => { match f.shape.clone() { - RecursionShape::ListRecursion => Some(f), + RecursionShape::ListRecursion => Some(f.clone()), _ => None, } } @@ -8833,12 +8928,13 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .cloned(); let lambda_elem_info = match lambda_arg { Some(la) => { - let lambda_node = arg_value(la); + let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, (*ctx.type_env).clone().source_indices.clone(), ); lparams + .clone() .get(elem_position.clone().unwrap() as usize) .cloned() } @@ -8859,17 +8955,17 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - elem_name, + elem_name.clone(), Rc::new(SubValueRelation::IteratedSubValue { - field: ind_field, + field: ind_field.clone(), }), ) } else { v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), - elem_name, + elem_name.clone(), Rc::new(SubValueRelation::IteratedSubValue { - field: ind_field, + field: ind_field.clone(), }), ) }, @@ -8988,8 +9084,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - fe_var, - Rc::new(SubValueRelation::IteratedSubValue { field: ind_field }), + fe_var.clone(), + Rc::new(SubValueRelation::IteratedSubValue { + field: ind_field.clone(), + }), ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), @@ -9008,13 +9106,13 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota per_field_vars: ctx.per_field_vars.clone(), }), }; - let annotated_coll = annotate_descent(coll, ctx.clone()); - let annotated_body = annotate_descent(fe_body, inner_ctx); + let annotated_coll = annotate_descent(coll.clone(), ctx.clone()); + let annotated_body = annotate_descent(fe_body, inner_ctx.clone()); Rc::new(Node { name: body.name.clone(), span: body.span.clone(), ident_span: body.ident_span.clone(), - children: Rc::new(vec![annotated_coll, annotated_body]), + children: Rc::new(vec![annotated_coll, annotated_body.clone()]), connective: body.connective.clone(), params: body.params.clone(), inferred: body.inferred.clone(), @@ -9043,9 +9141,11 @@ pub fn resolved_type_name( source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => authored_name_at(source_indices, rt), + Some(InferredNode::Resolved { node: rt, .. }) => { + authored_name_at(source_indices, rt.clone()) + } _ => match n.children.clone().first().cloned() { - Some(c) => authored_name_at(source_indices, c), + Some(c) => authored_name_at(source_indices, c.clone()), None => "".to_string(), }, } @@ -9090,13 +9190,13 @@ pub fn infer_output_provenance( v1_rt::rc_empty_map::>>>(), ); if ((Rc::new(v1_rt::map_keys(&scalar)).len() as i64) > 0) { - Rc::new(vec![scalar]) + Rc::new(vec![scalar.clone()]) } else { { let per_field = classify_body_per_field( body.clone(), - param_names, - param_types, + param_names.clone(), + param_types.clone(), type_env.clone(), func_env.clone(), v1_rt::rc_empty_map::>>>(), @@ -9111,7 +9211,7 @@ pub fn infer_output_provenance( } __found }) { - per_field + per_field.clone() } else { Rc::new(vec![]) } @@ -9135,7 +9235,7 @@ pub fn classify_body_provenance( } => { let vname = expr_var_name_at(expr.clone(), type_env.source_indices.clone()); match v1_rt::map_get(&let_prov, vname.clone()) { - Some(prov) => prov, + Some(prov) => prov.clone(), None => { if { let mut __found = false; @@ -9149,7 +9249,7 @@ pub fn classify_body_provenance( } { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - vname, + vname.clone(), Rc::new(SubValueRelation::PreservedValue), ) } else { @@ -9258,14 +9358,14 @@ pub fn classify_body_provenance( let_prov.clone(), ); if ((Rc::new(v1_rt::map_keys(&callee_result)).len() as i64) > 0) { - callee_result + callee_result.clone() } else { { - let is_shrink = match ms.as_deref().cloned() { + let is_shrink = match ms.clone().as_deref().cloned() { Some(MethodSemantics::AlgebraMethodSemantics { size_effect: se, .. - }) => match se { + }) => match se.clone() { Some(CollectionSizeEffect::ShrinkEffect) => true, _ => false, }, @@ -9273,18 +9373,19 @@ pub fn classify_body_provenance( }; if (is_shrink && match method_arg_nodes(expr.clone()).first().cloned() { - Some(arg_node) => match (*arg_value(arg_node).expr_data.clone()) - .clone() - { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: n, .. } = value.as_ref() - else { - unreachable!() - }; - (n > 0) + Some(arg_node) => { + match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: n, .. } = + value.as_ref() + else { + unreachable!() + }; + (n.clone() > 0) + } + _ => false, } - _ => false, - }, + } None => false, }) { @@ -9384,7 +9485,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types match if_else_branch(expr.clone()) { Some(else_expr) => { let else_prov = classify_body_provenance( - else_expr, + else_expr.clone(), param_names.clone(), param_types.clone(), type_env.clone(), @@ -9400,17 +9501,18 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types let value = let_value(expr.clone()); let bname = let_binding_name_at(expr.clone(), type_env.source_indices.clone()); let value_prov = classify_body_provenance( - value, + value.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_env.clone(), let_prov.clone(), ); - let updated = v1_rt::rc_map_insert(let_prov.clone(), bname, value_prov); + let updated = + v1_rt::rc_map_insert(let_prov.clone(), bname.clone(), value_prov.clone()); match let_body(expr.clone()) { Some(body) => classify_body_provenance( - body, + body.clone(), param_names.clone(), param_types.clone(), type_env.clone(), @@ -9489,7 +9591,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types ), ExprData::ExprReturn => match expr.children.clone().first().cloned() { Some(inner) => classify_body_provenance( - inner, + inner.clone(), param_names.clone(), param_types.clone(), type_env.clone(), @@ -9539,11 +9641,11 @@ pub fn method_call_args_by_name( let base = match lookup_func_sig(func_env, mname) { Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { - let first_pname = param_node_name_at(first_p, source_indices.clone()); + let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); if (first_pname.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), - first_pname, + first_pname.clone(), recv, ) } else { @@ -9764,7 +9866,7 @@ pub fn classify_terminal_per_field( match if_else_branch(expr.clone()) { Some(else_expr) => { let else_unwrapped = - unwrap_body_terminal(else_expr, let_prov, type_env.clone()); + unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); let else_result = match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ @@ -9812,7 +9914,7 @@ pub fn unwrap_body_terminal( match (*expr.expr_data.clone()).clone() { ExprData::ExprBlock => match expr.children.clone().last().cloned() { Some(last_stmt) => Rc::new(BodyTerminal { - expr: last_stmt, + expr: last_stmt.clone(), let_prov: let_prov, }), None => Rc::new(BodyTerminal { @@ -9854,6 +9956,7 @@ pub fn meet_per_field_results( let mut __result = Vec::new(); for pair in Rc::new( first_result + .clone() .iter() .cloned() .enumerate() @@ -9909,7 +10012,7 @@ pub fn meet_body_provenance_maps( .iter() .cloned() .fold( - first_prov, + first_prov.clone(), |acc: Rc>>, prov: Rc>>| { intersect_prov_maps(acc, prov.clone()) @@ -9952,11 +10055,11 @@ pub fn arm_ctx_from_variant_provenance( name: vname, field_bindings: bindings, .. - } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname) { + } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); - let extended = bindings.iter().cloned().fold( + let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( @@ -9974,7 +10077,7 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))))))))( + let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))( param_map.clone(), call_args.clone(), c.param_order.clone(), @@ -10137,7 +10240,7 @@ pub fn compute_variant_provenance( ); collect_variant_constructors( body, - rt_name, + rt_name.clone(), param_names, param_types, type_env.clone(), @@ -10176,9 +10279,9 @@ pub fn collect_variant_constructors( match (*body.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: pe, .. - } => match pe { + } => match pe.clone() { Some(enum_name) => { - if (enum_name == parent_enum) { + if (enum_name.clone() == parent_enum.clone()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10215,12 +10318,15 @@ pub fn collect_variant_constructors( ); match v1_rt::map_get(&acc, variant_name.clone()) { Some(existing) => { - let merged = merge_field_prov_maps(existing, field_prov_map); - v1_rt::rc_map_insert(acc.clone(), variant_name, merged) - } - None => { - v1_rt::rc_map_insert(acc.clone(), variant_name, field_prov_map) + let merged = + merge_field_prov_maps(existing.clone(), field_prov_map); + v1_rt::rc_map_insert(acc.clone(), variant_name.clone(), merged) } + None => v1_rt::rc_map_insert( + acc.clone(), + variant_name.clone(), + field_prov_map, + ), } } } else { @@ -10236,7 +10342,7 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) == parent_enum) + ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10309,13 +10415,13 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { ); match if_else_branch(body.clone()) { Some(eb) => collect_variant_constructors( - eb, - parent_enum, + eb.clone(), + parent_enum.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_env.clone(), - let_prov, + let_prov.clone(), then_acc, ), None => then_acc, @@ -10332,10 +10438,10 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { func_env.clone(), let_prov.clone(), ); - let new_lp = v1_rt::rc_map_insert(let_prov, bname, value_prov); + let new_lp = v1_rt::rc_map_insert(let_prov.clone(), bname.clone(), value_prov); collect_variant_constructors( - b, - parent_enum, + b.clone(), + parent_enum.clone(), param_names.clone(), param_types.clone(), type_env.clone(), @@ -10364,7 +10470,7 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { .iter() .cloned() .fold( - let_prov, + let_prov.clone(), |lp: Rc>>>>, stmt: Rc| match (*stmt .expr_data @@ -10389,10 +10495,14 @@ if ((Rc::new(v1_rt::map_keys(&composed_field_map)).len() as i64) > 0) { _ => lp.clone(), }, ); - match stmts.get((stmt_count - 1) as usize).cloned() { + match stmts + .clone() + .get((stmt_count.clone() - 1) as usize) + .cloned() + { Some(last) => collect_variant_constructors( - last, - parent_enum, + last.clone(), + parent_enum.clone(), param_names.clone(), param_types.clone(), type_env.clone(), @@ -10795,7 +10905,7 @@ pub fn infer_property_values( }), diagnostics: Rc::new({ let mut __result = Vec::new(); - for r in results.iter().cloned() { + for r in results.clone().iter().cloned() { __result.extend((*r.1.clone()).iter().cloned()); } __result @@ -10862,7 +10972,7 @@ pub fn infer_auth_source_properties( }), diagnostics: Rc::new({ let mut __result = Vec::new(); - for r in results.iter().cloned() { + for r in results.clone().iter().cloned() { __result.extend((*r.1.clone()).iter().cloned()); } __result @@ -10999,7 +11109,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))( body_typed.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -11035,9 +11145,9 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc transport: typed_transport, properties: typed_properties, type_annotation: typed_anno, - is_self_recursive: is_recursive, + is_self_recursive: is_recursive.clone(), has_non_tail_self_call: expr_has_non_tail_self_call( - Rc::new(body_typed), + Rc::new(body_typed.clone()), authored_name_at( (*scope.type_env).clone().source_indices.clone(), item.clone(), @@ -11063,7 +11173,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let fn_scope = scope.clone(); let body_result = infer_expr( item.body.clone().clone().unwrap(), - fn_scope, + fn_scope.clone(), Some(resolved_type(item.clone())), ); let body_typed = (*body_result.typed).clone(); @@ -11078,7 +11188,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(body_typed)), + body: Some(Rc::new(body_typed.clone())), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11128,7 +11238,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(val_typed)), + body: Some(Rc::new(val_typed.clone())), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11263,10 +11373,10 @@ pub fn type_node_label( { let authored = authored_name_at(source_indices, n.clone()); if (authored.clone() != "".to_string()) { - authored + authored.clone() } else { match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id, + Some(InferredNode::TypeVariable { id: tv_id, .. }) => tv_id.clone(), _ => n.name.clone(), } } @@ -11282,13 +11392,14 @@ pub fn param_is_generic_decl( let pname = param_node_name_at(p.clone(), source_indices.clone()); let tname = type_node_label(pt.clone(), source_indices.clone()); let type_expr_is_var = match pt.inferred.clone() { - Some(inf) => is_type_variable(inf), + Some(inf) => is_type_variable(inf.clone()), None => false, }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) && (pname.clone() != "".to_string())) - && ((pname.clone() == tname) || (type_expr_is_var && (pname == pt.name.clone())))) + && ((pname.clone() == tname) + || (type_expr_is_var && (pname.clone() == pt.name.clone())))) } } @@ -11303,7 +11414,7 @@ pub fn unify_generics( let bind_name = type_node_label(formal.clone(), source_indices.clone()); let f_bare = (((formal.children.clone().len() as i64) == 0) && (formal.connective.clone() == Connective::NoConnective)); - if ((f_bare.clone() + if ((f_bare || match formal.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: _, .. }) => true, _ => false, @@ -11372,7 +11483,7 @@ pub fn should_unify_record_lit_generics( let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); (((formal_name.clone() != "".to_string()) && (record_name.clone() != "".to_string())) - && (formal_name == record_name)) + && (formal_name.clone() == record_name.clone())) } } } @@ -11475,10 +11586,13 @@ pub fn unify_record_lit_generics( (*scope.type_env).clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) - && (formal_name == record_type_name.clone())) + && (formal_name.clone() == record_type_name.clone())) { unify_record_lit_field_walk( - record_lit_expected_fields(Some(record_type_name), scope.clone()), + record_lit_expected_fields( + Some(record_type_name.clone()), + scope.clone(), + ), record.clone(), generic_names.clone(), scope.clone(), @@ -11542,8 +11656,8 @@ pub fn substitute_generics_apply( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv_id, .. }) => { - match v1_rt::map_get(&subst, tv_id) { - Some(c) => c, + match v1_rt::map_get(&subst, tv_id.clone()) { + Some(c) => c.clone(), None => n.clone(), } } @@ -11554,7 +11668,7 @@ pub fn substitute_generics_apply( && ((n.params.clone().len() as i64) == 0)); if is_bare { match v1_rt::map_get(&subst, nm) { - Some(c) => c, + Some(c) => c.clone(), None => n.clone(), } } else { @@ -11588,10 +11702,12 @@ pub fn substitute_generics_apply( subst.clone(), source_indices.clone(), ); - if v1_rt::rc_ptr_eq(new_rt.clone(), rt) { + if v1_rt::rc_ptr_eq(new_rt.clone(), rt.clone()) { n.inferred.clone() } else { - Some(Rc::new(InferredNode::Resolved { node: new_rt })) + Some(Rc::new(InferredNode::Resolved { + node: new_rt.clone(), + })) } } _ => n.inferred.clone(), @@ -11606,10 +11722,10 @@ pub fn substitute_generics_apply( name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: new_children, + children: new_children.clone(), connective: n.connective.clone(), - params: new_params, - inferred: new_inferred, + params: new_params.clone(), + inferred: new_inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), body: n.body.clone(), @@ -11664,7 +11780,7 @@ pub fn deps_excluding_leaf_self( if is_bare_self { Rc::new(vec![]) } else { - deps0 + deps0.clone() } } } @@ -11998,7 +12114,7 @@ pub fn build_type_env( resolved: Rc::new(Node { name: "Unit".to_string(), span: unit_span.clone(), - ident_span: Some(unit_span), + ident_span: Some(unit_span.clone()), children: Rc::new(vec![]), connective: Connective::Conj, params: Rc::new(vec![]), @@ -12414,9 +12530,9 @@ pub fn build_type_env( v1_rt::rc_map_insert(acc, ident.clone(), true) }, ); - let all_local_bindings = v1_rt::rc_map_merge(local_bindings, param_bindings); + let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); let kernel_cache = type_env_cache_from_bindings( - kernel_bindings, + kernel_bindings.clone(), source_indices.clone(), compiler_recursive_name_set(), ); @@ -12518,9 +12634,9 @@ pub fn build_type_env( let visible_str_bindings = v1_rt::rc_map_merge(ancestry_str_bindings.clone(), local_str_bindings.clone()); let unresolved_env = Rc::new(TypeEnv { - bindings: all_local_bindings, - str_bindings: local_str_bindings, - ancestry_str_bindings: ancestry_str_bindings, + bindings: all_local_bindings.clone(), + str_bindings: local_str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), parents: scope_parents.clone(), recursive_types: cycle_set, recursive_type_set: cross_type_set, @@ -12530,7 +12646,7 @@ pub fn build_type_env( }); let resolved = resolve_env_bindings( unresolved_env, - module_name_str, + module_name_str.clone(), local_name_set, all_deps_map.clone(), ); @@ -12540,7 +12656,7 @@ pub fn build_type_env( bindings: resolved_env_out.bindings.clone(), str_bindings: resolved_env_out.str_bindings.clone(), ancestry_str_bindings: resolved_env_out.ancestry_str_bindings.clone(), - parents: scope_parents, + parents: scope_parents.clone(), recursive_types: resolved_env_out.recursive_types.clone(), recursive_type_set: resolved_env_out.recursive_type_set.clone(), inductive_fields: resolved_env_out.inductive_fields.clone(), @@ -12548,9 +12664,9 @@ pub fn build_type_env( intern_table: intern_table.clone(), }); let type_env_cache = Rc::new(TypeEnvCache { - deps_map: all_deps_map, + deps_map: all_deps_map.clone(), str_bindings: visible_str_bindings, - cycle_set_str: cycle_set_str, + cycle_set_str: cycle_set_str.clone(), variant_locals: v1_rt::rc_empty_map::>(), }); Rc::new(BuildTypeEnvResult { @@ -12865,7 +12981,7 @@ pub fn build_type_env_unresolved( }, ); let kernel_cache = type_env_cache_from_bindings( - kernel_bindings, + kernel_bindings.clone(), source_indices.clone(), compiler_recursive_name_set(), ); @@ -12967,10 +13083,10 @@ pub fn build_type_env_unresolved( let visible_str_bindings = v1_rt::rc_map_merge(ancestry_str_bindings.clone(), local_str_bindings.clone()); let unresolved_env = Rc::new(TypeEnv { - bindings: local_bindings, - str_bindings: local_str_bindings, - ancestry_str_bindings: ancestry_str_bindings, - parents: scope_parents, + bindings: local_bindings.clone(), + str_bindings: local_str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + parents: scope_parents.clone(), recursive_types: cycle_set, recursive_type_set: cross_type_set, inductive_fields: merged_inductive_fields, @@ -12978,9 +13094,9 @@ pub fn build_type_env_unresolved( intern_table: intern_table.clone(), }); let type_env_cache = Rc::new(TypeEnvCache { - deps_map: all_deps_map, + deps_map: all_deps_map.clone(), str_bindings: visible_str_bindings, - cycle_set_str: cycle_set_str, + cycle_set_str: cycle_set_str.clone(), variant_locals: v1_rt::rc_empty_map::>(), }); Rc::new(BuildTypeEnvResult { @@ -13008,9 +13124,9 @@ pub fn build_item_info( let item_name_str = authored_name_at(source_indices.clone(), item.clone()); match kind.clone() { ItemKind::FuncItem => Rc::new(ItemInfo { - name: item_name_str, + name: item_name_str.clone(), module_name: module_name, - kind: kind, + kind: kind.clone(), service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { @@ -13027,7 +13143,7 @@ pub fn build_item_info( ItemKind::FnItem => Rc::new(ItemInfo { name: item_name_str.clone(), module_name: module_name, - kind: kind, + kind: kind.clone(), service_names: if (item.body.clone() == None) { Rc::new(vec![]) } else { @@ -13052,16 +13168,16 @@ pub fn build_item_info( } else { expr_has_non_tail_self_call( item.body.clone().clone().unwrap(), - item_name_str, + item_name_str.clone(), true, source_indices.clone(), ) }, }), _ => Rc::new(ItemInfo { - name: item_name_str, + name: item_name_str.clone(), module_name: module_name, - kind: kind, + kind: kind.clone(), service_names: Rc::new(vec![]), resource_names: res_names, params: item.params.clone(), @@ -13135,7 +13251,11 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc func_sig: func_sig, svc_entries: svc_entries, svc_local: svc_local, - item_info: build_item_info(Rc::new(ritem), env.source_indices.clone(), module_name.clone()), + item_info: build_item_info( + Rc::new(ritem.clone()), + env.source_indices.clone(), + module_name.clone(), + ), }) } } @@ -13154,24 +13274,22 @@ pub fn fold_module_contributions( match remaining.clone().first().cloned() { None => { break Rc::new(LocalContributionState { - resolved_items: resolved_items.clone(), - func_sigs: func_sigs.clone(), - svc_registry: svc_registry.clone(), - svc_locals: svc_locals.clone(), - item_registry: item_registry.clone(), - diag_chunks: diag_chunks.clone(), + resolved_items: resolved_items, + func_sigs: func_sigs, + svc_registry: svc_registry, + svc_locals: svc_locals, + item_registry: item_registry, + diag_chunks: diag_chunks, }); } Some(contribution) => { let next_func_sigs = match contribution.func_sig.clone() { - Some(sig) => { - v1_rt::rc_map_insert(func_sigs.clone(), sig.name.clone(), sig.clone()) - } - None => func_sigs.clone(), + Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), + None => func_sigs, }; let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { v1_rt::rc_map_insert( - svc_registry.clone(), + svc_registry, authored_name_at( source_indices.clone(), contribution.resolved_item.clone(), @@ -13179,15 +13297,13 @@ pub fn fold_module_contributions( contribution.svc_entries.clone(), ) } else { - svc_registry.clone() + svc_registry }; let next_svc_locals = match contribution.svc_local.clone() { - Some(binding) => v1_rt::rc_map_insert( - svc_locals.clone(), - binding.name.clone(), - binding.clone(), - ), - None => svc_locals.clone(), + Some(binding) => { + v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) + } + None => svc_locals, }; { let __tco_0 = Rc::new( @@ -13199,9 +13315,9 @@ pub fn fold_module_contributions( ); let __tco_1 = v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); - let __tco_2 = next_func_sigs.clone(); - let __tco_3 = next_svc_registry.clone(); - let __tco_4 = next_svc_locals.clone(); + let __tco_2 = next_func_sigs; + let __tco_3 = next_svc_registry; + let __tco_4 = next_svc_locals; let __tco_5 = v1_rt::rc_map_insert( item_registry, contribution.item_info.clone().name.clone(), @@ -13258,8 +13374,8 @@ pub fn insert_variant_owner_checked( Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::VariantCollision { variant: arm_name.clone(), - enum1: prev_name, - enum2: owner_name, + enum1: prev_name.clone(), + enum2: owner_name.clone(), span: owner.span.clone(), }), module_name, @@ -13343,7 +13459,7 @@ pub fn owner_of_exported_arm( mut source_indices: Rc>>, ) -> Option> { loop { - match v1_rt::map_get(&parent_index, module_path.clone()) { + match v1_rt::map_get(&parent_index, module_path) { None => { break None; } @@ -13381,7 +13497,7 @@ pub fn owner_of_exported_arm( }) .first() .cloned(); - match own.clone() { + match own { Some(item) => { break Some(item.clone()); } @@ -13423,7 +13539,7 @@ pub fn owner_of_exported_arm( }) .first() .cloned(); - match reexport.clone() { + match reexport { Some(imp) => { let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); module_path = __tco_0; @@ -13447,7 +13563,7 @@ pub fn exported_coproduct_item( mut source_indices: Rc>>, ) -> Option> { loop { - match v1_rt::map_get(&parent_index, module_path.clone()) { + match v1_rt::map_get(&parent_index, module_path) { None => { break None; } @@ -13476,7 +13592,7 @@ pub fn exported_coproduct_item( }) .first() .cloned(); - match own.clone() { + match own { Some(item) => { break Some(item.clone()); } @@ -13518,7 +13634,7 @@ pub fn exported_coproduct_item( }) .first() .cloned(); - match reexport.clone() { + match reexport { Some(imp) => { let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); module_path = __tco_0; @@ -13689,7 +13805,7 @@ pub fn build_module_context( func_env: resolve_result.func_env.clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, - variant_locals: env_variant_locals, + variant_locals: env_variant_locals.clone(), item_registry: local.item_registry.clone(), diagnostics: v1_rt::concat( v1_rt::concat( @@ -13817,12 +13933,12 @@ pub fn typecheck_module( }); let infer_diags = Rc::new({ let mut __result = Vec::new(); - for tir in typed_item_results.iter().cloned() { + for tir in typed_item_results.clone().iter().cloned() { __result.extend((*tir.diagnostics.clone()).iter().cloned()); } __result }); - let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))))))))( + let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))( typed_items.clone(), (*ctx.func_env).clone(), env.clone(), @@ -13830,7 +13946,7 @@ pub fn typecheck_module( ); let reannotated_items = Rc::new({ let mut __result = Vec::new(); - for item in typed_items.iter().cloned() { + for item in typed_items.clone().iter().cloned() { __result.push( if (item.is_self_recursive.clone() && (item.body.clone() != None)) { Rc::new(Node { @@ -13868,7 +13984,7 @@ pub fn typecheck_module( __result }); let typed_base = module_node( - resolved_module_name, + resolved_module_name.clone(), module_imports(resolved.module.clone()), ctx.resolved_items.clone(), (*resolved.module).clone().span.clone(), @@ -13881,22 +13997,22 @@ pub fn typecheck_module( typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: Rc::new(env), + type_env: Rc::new(env.clone()), type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), cycle_set_str: env_cache.cycle_set_str.clone(), variant_locals: ctx.variant_locals.clone(), }), - func_env: updated_func_env, + func_env: updated_func_env.clone(), item_registry: ctx.item_registry.clone(), }), diagnostics: v1_rt::concat( v1_rt::concat( - v1_rt::concat(env_diags, ctx.diagnostics.clone()), + v1_rt::concat(env_diags.clone(), ctx.diagnostics.clone()), infer_diags, ), - seed_diags, + seed_diags.clone(), ), }) } @@ -13959,7 +14075,7 @@ pub fn resolve_env_bindings( Rc::new(vec![]), local_names.clone(), deps_map, - (remaining.len() as i64), + (remaining.clone().len() as i64), ) } } @@ -14028,7 +14144,7 @@ pub fn topo_resolve_types( let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14091,7 +14207,7 @@ pub fn topo_resolve_types( Some(binding) => { let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14139,7 +14255,7 @@ pub fn topo_resolve_types( __result }); { - let __tco_0 = next_remaining.clone(); + let __tco_0 = next_remaining; let __tco_1 = Rc::new(TypeEnv { bindings: ready_accum.bindings.clone(), str_bindings: ready_accum.str_bindings.clone(), @@ -14229,7 +14345,7 @@ pub fn variant_has_positional_payload_shape( ) -> bool { (((variant.children.clone().len() as i64) == 1) && match variant.children.clone().first().cloned() { - Some(f) => (field_node_name_at(f, source_indices) == "0".to_string()), + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, }) } @@ -14398,7 +14514,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>(), }); let built_raw = modules.clone().iter().cloned().fold( - init, + init.clone(), |state: Rc, typed_module: Rc| { typed_module.items.clone().iter().cloned().fold( state, @@ -14519,13 +14635,13 @@ pub fn typecheck_modules( match remaining.clone().first().cloned() { None => { let expanded_registry = - expand_transitive_services(modules.clone(), item_registry.clone(), 5); + expand_transitive_services(modules.clone(), item_registry, 5); break Rc::new(TypedGraph { modules: modules.clone(), - item_registry: expanded_registry.clone(), + item_registry: expanded_registry, diagnostics: Rc::new({ let mut __result = Vec::new(); - for c in diag_chunks.clone().iter().cloned() { + for c in diag_chunks.iter().cloned() { __result.extend((*c.clone()).iter().cloned()); } __result @@ -14563,7 +14679,7 @@ pub fn typecheck_modules( let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); let __tco_4 = v1_rt::rc_list_push( v1_rt::rc_list_push(diag_chunks, parent_result.diagnostics.clone()), - tc_diags.clone(), + tc_diags, ); remaining = __tco_0; modules = __tco_1; @@ -14608,7 +14724,7 @@ pub fn local_authority_binding(owner: Rc, name: String) -> Option Some(binding), + Some(binding) => Some(binding.clone()), None => None, } } @@ -14665,7 +14781,7 @@ pub fn local_authority_for_name( .last() .cloned() { - Some(owner) => Some(owner), + Some(owner) => Some(owner.clone()), None => None, } } @@ -14732,7 +14848,7 @@ pub fn rewire_inherited_str_binding( }) } else { match local_authority_for_name(modules.clone(), name.clone()) { - Some(owner) => match local_authority_binding(owner, name.clone()) { + Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { Some(canonical) => { let ancestry_str_bindings = v1_rt::rc_map_insert( ancestry_str_bindings.clone(), @@ -14740,9 +14856,11 @@ pub fn rewire_inherited_str_binding( canonical.clone(), ); let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { - Some(_) => { - v1_rt::rc_map_insert(str_bindings.clone(), name.clone(), canonical) - } + Some(_) => v1_rt::rc_map_insert( + str_bindings.clone(), + name.clone(), + canonical.clone(), + ), None => str_bindings.clone(), }; Rc::new(StrBindingsRewireAccum { @@ -14891,7 +15009,7 @@ pub fn compiler_kernel_type_env( resolved: Rc::new(Node { name: "Unit".to_string(), span: unit_span.clone(), - ident_span: Some(unit_span), + ident_span: Some(unit_span.clone()), children: Rc::new(vec![]), connective: Connective::Conj, params: Rc::new(vec![]), @@ -15030,7 +15148,7 @@ pub fn compiler_kernel_type_env( ); Rc::new(TypeEnv { bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: kernel_recursive_types, @@ -15067,7 +15185,7 @@ pub fn rewire_type_env_parent_links( }, }, ) { - Some(kernel) => kernel, + Some(kernel) => kernel.clone(), None => match modules.clone().first().cloned() { Some(m) => compiler_kernel_type_env( source_indices.clone(), @@ -15200,7 +15318,7 @@ pub fn reconcile( let modules = rewire_func_env_parent_links(modules.clone(), source_indices.clone()); let emit_info = build_emit_graph_info(modules.clone()); Rc::new(ResolvedGraph { - modules: modules, + modules: modules.clone(), item_registry: typed.item_registry.clone(), diagnostics: typed.diagnostics.clone(), emit_graph_info: emit_info, diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index 3e81ee3fec5..c3d02096a6e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -83,8 +83,8 @@ pub fn keyed_collection_parts( match n.children.clone().first().cloned() { Some(key_child) => match n.children.clone().get(1 as usize).cloned() { Some(value_child) => Some(Rc::new(KeyedCollectionParts { - key_type: resolved_type(key_child), - value_type: resolved_type(value_child), + key_type: resolved_type(key_child.clone()), + value_type: resolved_type(value_child.clone()), })), None => None, }, @@ -132,7 +132,7 @@ pub fn check_index_access_node( Some(parts) => { let key_diags = if node_type_equals( parts.key_type.clone(), - normed_index, + normed_index.clone(), source_indices.clone(), ) { Rc::new(vec![]) @@ -171,8 +171,10 @@ pub fn check_index_access_node( )) && index_is_int) { { - let elem = - for_each_element_type_node(normed, source_indices.clone()); + let elem = for_each_element_type_node( + normed.clone(), + source_indices.clone(), + ); access_result( with_optional_cardinality(elem), Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index bcd9d672ab4..80801b55852 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -110,7 +110,7 @@ pub fn kahn_remove_loop( }); let final_state = kahn_cycle_drain( initial_queue, - in_degree, + in_degree.clone(), reverse_adj, 0, (remaining.clone().len() as i64), @@ -160,7 +160,7 @@ pub fn kahn_cycle_drain( removed_count: removed_count.clone(), }), |state: Rc, node: String| { - let state = v1_rt::take_owned_counted(state, "src/v1/04_cycle.dag:2601:state"); + let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { Some(v) => v.clone(), @@ -210,7 +210,7 @@ pub fn kahn_cycle_drain( }) }); { - let __tco_0 = next_queue.clone(); + let __tco_0 = next_queue; let __tco_1 = result.in_degree.clone(); let __tco_2 = result.removed_count.clone(); let __tco_3 = (fuel - 1); @@ -279,7 +279,7 @@ pub fn detect_type_cycles_kahn( }); let result = Rc::new({ let mut __result = Vec::new(); - for n in all_names.iter().cloned() { + for n in all_names.clone().iter().cloned() { if v1_rt::set_contains(&cm_set, n.clone()) { __result.push(n); } diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 233e1970848..b8089770e47 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -321,8 +321,8 @@ pub fn find_first_enum_field_node( source_indices: Rc>>, ) -> Option> { match variants.first().cloned() { - Some(variant) => match find_child_named(variant, field_name, source_indices) { - Some(field_child) => Some(field_child), + Some(variant) => match find_child_named(variant.clone(), field_name, source_indices) { + Some(field_child) => Some(field_child.clone()), None => None, }, None => None, @@ -707,7 +707,8 @@ pub fn add_emit_item_summary( } _ => state.type_summaries.clone(), }; - let next_summaries = v1_rt::rc_map_insert(with_variants, summary.name.clone(), summary); + let next_summaries = + v1_rt::rc_map_insert(with_variants, summary.name.clone(), summary.clone()); Rc::new(EmitInfoBuildState { type_summaries: next_summaries, }) diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 66dbe7cd5db..77676a00023 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -151,8 +151,8 @@ pub fn merge_type_env_cache(base: Rc, overlay: Rc) - pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option> { match intern_find(env.intern_table.clone(), name) { - Some(ident) => match v1_rt::map_get(&env.bindings.clone(), ident) { - Some(binding) => Some(binding), + Some(ident) => match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { + Some(binding) => Some(binding.clone()), None => None, }, None => None, @@ -172,11 +172,11 @@ pub fn str_bindings_from_bindings( pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { - Some(binding) => Some(binding), + Some(binding) => Some(binding.clone()), None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { - Some(binding) => Some(binding), + Some(binding) => Some(binding.clone()), None => match intern_find(env.intern_table.clone(), name.clone()) { - Some(id) => v1_rt::map_get(&env.bindings.clone(), id), + Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), None => None, }, }, @@ -185,7 +185,7 @@ pub fn lookup_binding_by_name(env: Rc, name: String) -> Option, ident: i64) -> Option> { match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { - Some(binding) => Some(binding), + Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); lookup_binding_by_name(env.clone(), name) @@ -202,7 +202,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { match intern_find(env.intern_table.clone(), name) { - Some(id) => is_recursive_type(env.clone(), id), + Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } } @@ -227,14 +227,14 @@ pub fn authored_name(env: Rc, node: Rc) -> String { pub fn lookup_type_for(env: Rc, node: Rc) -> Option> { match node.ident.clone() { - Some(id) => lookup_type(env.clone(), id), + Some(id) => lookup_type(env.clone(), id.clone()), None => lookup_type_by_name(env.clone(), authored_name(env.clone(), node.clone())), } } pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { match node.ident.clone() { - Some(id) => is_recursive_type(env.clone(), id), + Some(id) => is_recursive_type(env.clone(), id.clone()), None => is_recursive_type_by_name(env.clone(), authored_name(env.clone(), node.clone())), } } @@ -242,11 +242,11 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) => fields, + Some(fields) => fields.clone(), None => Rc::new(vec![]), }; if ((local.clone().len() as i64) > 0) { - local + local.clone() } else { env.parents.clone().iter().cloned().fold( Rc::new(vec![]), @@ -291,7 +291,7 @@ pub fn put_inductive_field( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { - Some(fs) => fs, + Some(fs) => fs.clone(), None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -321,7 +321,7 @@ pub fn put_inductive_field_cross( ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { - Some(fs) => fs, + Some(fs) => fs.clone(), None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -346,7 +346,7 @@ pub fn merge_inductive_fields( right: Rc>>>>, ) -> Rc>>>> { Rc::new(v1_rt::map_keys(&right)).iter().cloned().fold( - left, + left.clone(), |acc: Rc>>>>, type_name: String| { match v1_rt::map_get(&right, type_name.clone()) { Some(incoming) => { @@ -469,14 +469,14 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings, + str_bindings: merged_bindings.clone(), ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, recursive_type_set: merged_recursive_set, inductive_fields: merged_inductive_fields, source_indices: merged_source_indices, - intern_table: merged_intern_table, + intern_table: merged_intern_table.clone(), }) } } diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 5271f9b41f5..95a6d52a3d7 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -119,22 +119,22 @@ pub fn inferred_to_outputs( } else { Rc::new(vec![make_field_node( "value".to_string(), - rt, + rt.clone(), Cardinality::Required, None, None, - span, + span.clone(), no_span(), )]) } } else { Rc::new(vec![make_field_node( "value".to_string(), - rt, + rt.clone(), Cardinality::Required, None, None, - span, + span.clone(), no_span(), )]) } @@ -147,11 +147,11 @@ pub fn inferred_to_outputs( } else { Rc::new(vec![make_field_node( "value".to_string(), - rt, + rt.clone(), Cardinality::Required, None, None, - span, + span.clone(), no_span(), )]) } diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index bfb4b339f09..58133bfe102 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -98,7 +98,7 @@ pub fn lookup_field_type_node( } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) { - Some(inner_result) => Some(with_optional_cardinality(inner_result)), + Some(inner_result) => Some(with_optional_cardinality(inner_result.clone())), None => None, } } @@ -122,7 +122,7 @@ pub fn lookup_field_type_node( { let value_child = match n.children.clone().get(1 as usize).cloned() { - Some(child) => child_type_node(child), + Some(child) => child_type_node(child.clone()), None => nominal_type_ref("V".to_string()), }; Some( @@ -135,7 +135,7 @@ pub fn lookup_field_type_node( ) } } else { - Some(child_type_node(field_child)) + Some(child_type_node(field_child.clone())) } } None => None, @@ -152,7 +152,7 @@ pub fn lookup_field_type_node( match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { lookup_field_type_node( - target, + target.clone(), field_name.clone(), source_indices.clone(), ) @@ -183,16 +183,18 @@ pub fn lookup_coproduct_common_field_node( }; let first_field = if found_in_all { match variants.clone().first().cloned() { - Some(first_variant) => { - find_child_named(first_variant, field_name.clone(), source_indices.clone()) - } + Some(first_variant) => find_child_named( + first_variant.clone(), + field_name.clone(), + source_indices.clone(), + ), None => None, } } else { None }; match first_field { - Some(field_child) => Some(child_type_node(field_child)), + Some(field_child) => Some(child_type_node(field_child.clone())), None => None, } } @@ -208,7 +210,7 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - if ((receiver_type.connective.clone() == Connective::Conj) || is_declared_container_alias_spelling(raw_name.clone())) { - receiver_type + receiver_type.clone() } else { { let resolved = reground_alias_carrier_identity( @@ -217,12 +219,12 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - ); let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); if ((resolved.connective.clone() == Connective::Conj) - || ((resolved_name.clone() != raw_name) - && is_declared_container_alias_spelling(resolved_name))) + || ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone()))) { - resolved + resolved.clone() } else { - receiver_type + receiver_type.clone() } } } @@ -243,16 +245,16 @@ pub fn resolve_scrutinee_type_node_seen( if n_is_type_var { return n.clone(); } - let normed = normalize_access_type_node(n); + let normed = normalize_access_type_node(n.clone()); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) && (normed.inferred.clone() != None)) { match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - resolve_scrutinee_type_node_seen(env.clone(), target, seen.clone()) + resolve_scrutinee_type_node_seen(env.clone(), target.clone(), seen.clone()) } - _ => normed, + _ => normed.clone(), } } else { if ((normed.connective.clone() == Connective::NoConnective) @@ -270,28 +272,28 @@ pub fn resolve_scrutinee_type_node_seen( match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { if ((((authored_name(env.clone(), target.clone()) - == canonical) + == canonical.clone()) && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { - normed + normed.clone() } else { resolve_scrutinee_type_node_seen( env.clone(), - target, + target.clone(), next_seen, ) } } - _ => normed, + _ => normed.clone(), } } } else { if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { - nominal_type_ref(canonical) + nominal_type_ref(canonical.clone()) } else { { let next_seen = if (canonical.clone() == "".to_string()) { @@ -302,18 +304,18 @@ pub fn resolve_scrutinee_type_node_seen( match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) - == canonical) + == canonical.clone()) && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) { - normed + normed.clone() } else { { let result = resolve_scrutinee_type_node_seen( env.clone(), - resolved, + resolved.clone(), next_seen, ); let is_optional = @@ -327,14 +329,14 @@ pub fn resolve_scrutinee_type_node_seen( } } } - None => normed, + None => normed.clone(), } } } } } } else { - normed + normed.clone() } } }) @@ -349,7 +351,7 @@ pub fn map_value_type_in_env(type_node: Rc, env: Rc) -> Option= 2)) { match map_type.children.clone().get(1 as usize).cloned() { - Some(value_type) => Some(value_type), + Some(value_type) => Some(value_type.clone()), None => None, } } else { @@ -367,7 +369,7 @@ pub fn map_key_type_in_env(type_node: Rc, env: Rc) -> Option= 1)) { match map_type.children.clone().first().cloned() { - Some(key_type) => Some(key_type), + Some(key_type) => Some(key_type.clone()), None => None, } } else { @@ -385,7 +387,7 @@ pub fn set_element_type_in_env(type_node: Rc, env: Rc) -> Option< && ((set_type.children.clone().len() as i64) >= 1)) { match set_type.children.clone().first().cloned() { - Some(elem_type) => Some(elem_type), + Some(elem_type) => Some(elem_type.clone()), None => None, } } else { @@ -409,9 +411,9 @@ pub fn field_summary_for_type( value_shape: FieldValueShape::PlainValue, })) } else { - if normed_opt { + if normed_opt.clone() { { - let inner = with_required_cardinality(normed); + let inner = with_required_cardinality(normed.clone()); match field_summary_for_type(inner, env.clone(), field.clone()) { Some(inner_summary) => Some(Rc::new(FieldSummary { access_style: inner_summary.access_style.clone(), @@ -431,7 +433,7 @@ pub fn field_summary_for_type( if is_product { v1_rt::map_get( &build_struct_field_summaries( - resolved, + resolved.clone(), env.source_indices.clone(), ), field.clone(), @@ -475,11 +477,11 @@ pub fn product_field_result_type(field: Rc) -> Option> { match rt.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: return_type, .. - }) => Some(return_type), - _ => Some(rt), + }) => Some(return_type.clone()), + _ => Some(rt.clone()), } } else { - Some(rt) + Some(rt.clone()) } } _ => None, @@ -495,9 +497,9 @@ pub fn map_lookup_result_type( match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { - Some(raw) + Some(raw.clone()) } else { - Some(make_container_type("Witness".to_string(), raw).ty.clone()) + Some(make_container_type("Witness".to_string(), raw.clone()).ty.clone()) } } None => None, @@ -529,16 +531,16 @@ pub fn lookup_field_in_product( None } { Some(lookup_rt) => Some(Rc::new(MethodFieldResult { - field_node: field, - result_type: lookup_rt, + field_node: field.clone(), + result_type: lookup_rt.clone(), size_effect: None, cost_shape: None, algebra_template: None, })), None => match product_field_result_type(field.clone()) { Some(rt) => Some(Rc::new(MethodFieldResult { - field_node: field, - result_type: rt, + field_node: field.clone(), + result_type: rt.clone(), size_effect: None, cost_shape: None, algebra_template: None, @@ -594,7 +596,7 @@ pub fn lookup_structural_method( ); let template_match = match profile { Some(p) => { - let templates = algebra_templates_for_profile(p); + let templates = algebra_templates_for_profile(p.clone()); Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { @@ -615,9 +617,9 @@ pub fn lookup_structural_method( result_type: mfr.result_type.clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), - algebra_template: Some(t), + algebra_template: Some(t.clone()), })), - None => base_result, + None => base_result.clone(), }; Rc::new(StructuralMethodLookup { resolution: resolution, diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index bae25f94a90..7e4b3673ab3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -131,7 +131,7 @@ pub fn builtin_function_registry() -> Rc>> { .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), Rc::new(set_ty.clone())); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), Rc::new(set_ty.clone())); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty)); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty.clone())); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); @@ -379,7 +379,7 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "is_xid_start".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "is_xid_continue".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "is_emoji_ident".to_string(), bool_type()); - m + m.clone() } } @@ -389,7 +389,7 @@ pub fn infer_builtin_call_type(name: String) -> Option> { pub fn resolve_builtin_call_type(name: String) -> Rc { match infer_builtin_call_type(name) { - Some(v) => v, + Some(v) => v.clone(), None => unit_type(), } } diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 7b2231d3838..4e0bf90d8ff 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -84,13 +84,18 @@ pub fn expand_scrut_from_decl( && (decl.connective.clone() == Connective::NoConnective)) && ((decl.children.clone().len() as i64) == 0)); if decl_is_disj { - decl + decl.clone() } else { if has_inferred_alias { match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let subst = generic_use_slot_bindings(scrut_node, env.clone()); - substitute_type_slots(target, subst, name, env.source_indices.clone()) + substitute_type_slots( + target.clone(), + subst, + name, + env.source_indices.clone(), + ) } _ => scrut_node, } @@ -110,14 +115,19 @@ pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc match lookup_type_by_name(env.clone(), name.clone()) { Some(decl) => { if is_generic_use { - expand_scrut_from_decl(decl, scrut_node.clone(), name, env.clone()) + expand_scrut_from_decl( + decl.clone(), + scrut_node.clone(), + name.clone(), + env.clone(), + ) } else { { let def_is_disj = (decl.connective.clone() == Connective::Disj); let has_inferred_body = ((decl.inferred.clone() != None) && (decl.connective.clone() == Connective::NoConnective)); if def_is_disj { - decl + decl.clone() } else { if has_inferred_body { match decl.inferred.clone().as_deref().cloned() { @@ -125,7 +135,7 @@ pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc let target_is_disj = (target.connective.clone() == Connective::Disj); if target_is_disj { - target + target.clone() } else { scrut_node.clone() } @@ -151,8 +161,8 @@ pub fn expand_scrut_type_for_variant_lookup( loop { let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); let is_disj = (scrut_node.connective.clone() == Connective::Disj); - let is_witness = is_witness_type_name(name.clone()); - if (is_disj.clone() || is_witness.clone()) { + let is_witness = is_witness_type_name(name); + if (is_disj || is_witness) { break scrut_node.clone(); } else { match scrut_node.inferred.clone().as_deref().cloned() { @@ -259,7 +269,7 @@ pub fn synthesize_optional_present_variant(scrut: Rc) -> Rc { pub fn synthesize_witness_holds_variant(scrut: Rc) -> Rc { { let inner = match scrut.children.clone().first().cloned() { - Some(child) => child_type_node(child), + Some(child) => child_type_node(child.clone()), None => error_type(), }; let value_field = Rc::new(Node { @@ -379,7 +389,7 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { } else { false }; - if is_error.clone() { + if is_error { break Rc::new(PatternSubject::PatternLookupBlocked); } else { if (((n.connective.clone() == Connective::NoConnective) @@ -405,7 +415,9 @@ pub fn pattern_subject_from_node(mut n: Rc) -> Rc { pub fn pattern_subject_from_inferred(n: Option>) -> Rc { match n.as_deref().cloned() { - Some(InferredNode::Resolved { node: resolved, .. }) => pattern_subject_from_node(resolved), + Some(InferredNode::Resolved { node: resolved, .. }) => { + pattern_subject_from_node(resolved.clone()) + } _ => Rc::new(PatternSubject::PatternLookupBlocked), } } @@ -427,7 +439,7 @@ pub fn node_lookup_failed(diagnostics: Rc>>) -> Rc) -> Rc { match (*result.status.clone()).clone() { NodeLookupStatus::LookupResolved { node: resolved, .. } => { - pattern_subject_from_node(resolved) + pattern_subject_from_node(resolved.clone()) } NodeLookupStatus::LookupFailed => Rc::new(PatternSubject::PatternLookupBlocked), } @@ -435,7 +447,7 @@ pub fn lookup_result_subject(result: Rc) -> Rc pub fn pattern_binding_type(subject: Rc) -> Rc { match (*subject).clone() { - PatternSubject::PatternResolved { node: resolved, .. } => resolved, + PatternSubject::PatternResolved { node: resolved, .. } => resolved.clone(), PatternSubject::PatternDynamic { span: _, .. } => error_type(), PatternSubject::PatternLookupBlocked => error_type(), } @@ -472,7 +484,7 @@ pub fn lookup_variant_in_type( Rc::new(CompilerDiagnostic::VariantNotFound { variant: variant_name.clone(), type_name: "unresolved".to_string(), - span: dynamic_span, + span: dynamic_span.clone(), }), module_name, )])), @@ -489,7 +501,7 @@ pub fn lookup_variant_in_type( node_lookup_failed(Rc::new(vec![])) } else { { - let optional_cardinality_subject = (scrut_opt + let optional_cardinality_subject = (scrut_opt.clone() && (authored_name_at(source_indices.clone(), scrut_node.clone()) != "Optional".to_string())); let witness_subject = (is_witness_type_name(authored_name_at( @@ -499,9 +511,11 @@ pub fn lookup_variant_in_type( if (optional_cardinality_subject.clone() && (variant_name.clone() == "Present".to_string())) { - node_lookup_resolved(synthesize_optional_present_variant(scrut_node)) + node_lookup_resolved(synthesize_optional_present_variant( + scrut_node.clone(), + )) } else { - if (optional_cardinality_subject + if (optional_cardinality_subject.clone() && (variant_name.clone() == "Absent".to_string())) { node_lookup_resolved(none_type()) @@ -509,13 +523,15 @@ pub fn lookup_variant_in_type( if (witness_subject.clone() && (variant_name.clone() == "Holds".to_string())) { - node_lookup_resolved(synthesize_witness_holds_variant(scrut_node)) + node_lookup_resolved(synthesize_witness_holds_variant( + scrut_node.clone(), + )) } else { - if (witness_subject + if (witness_subject.clone() && (variant_name.clone() == "Violates".to_string())) { node_lookup_resolved(synthesize_witness_violates_variant( - scrut_node, + scrut_node.clone(), )) } else { { @@ -535,34 +551,36 @@ pub fn lookup_variant_in_type( let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) - && (scrut_name == variant_name.clone())); + && (scrut_name.clone() == variant_name.clone())); let fallback = if record_destructure { - node_lookup_resolved(scrut_node) + node_lookup_resolved(scrut_node.clone()) } else { if (optional_coproduct_subject.clone() && (variant_name.clone() == "Present".to_string())) { node_lookup_resolved( - synthesize_optional_present_variant(scrut_node), + synthesize_optional_present_variant( + scrut_node.clone(), + ), ) } else { - if (optional_coproduct_subject + if (optional_coproduct_subject.clone() && (variant_name.clone() == "Absent".to_string())) { node_lookup_resolved(none_type()) } else { variant_not_found_result( - scrut_node, + scrut_node.clone(), variant_name.clone(), module_name, - source_indices, + source_indices.clone(), ) } } }; match direct_match { - Some(v) => node_lookup_resolved(v), + Some(v) => node_lookup_resolved(v.clone()), None => fallback, } } @@ -590,7 +608,7 @@ pub fn lookup_field_in_variant( Rc::new(CompilerDiagnostic::FieldNotFound { field: field_name.clone(), type_name: "unresolved".to_string(), - span: dynamic_span, + span: dynamic_span.clone(), }), module_name, )])), @@ -602,7 +620,7 @@ pub fn lookup_field_in_variant( source_indices.clone(), ) { Some(field_child) => { - let resolved = child_type_node(field_child); + let resolved = child_type_node(field_child.clone()); node_lookup_resolved(resolved) } None => node_lookup_failed(Rc::new(vec![make_error_node( @@ -635,7 +653,7 @@ pub fn check_match_exhaustiveness( env.clone(), authored_name_at(env.source_indices.clone(), scrutinee_type.clone()), ) { - Some(def) => def, + Some(def) => def.clone(), None => scrutinee_type.clone(), } }; @@ -653,10 +671,10 @@ pub fn check_match_exhaustiveness( )) && ((resolved.children.clone().len() as i64) == 1)); if ((is_coproduct || resolved_is_optional.clone()) || resolved_is_witness.clone()) { { - let variant_names = if resolved_is_optional { + let variant_names = if resolved_is_optional.clone() { Rc::new(vec!["Present".to_string(), "Absent".to_string()]) } else { - if resolved_is_witness { + if resolved_is_witness.clone() { Rc::new(vec!["Holds".to_string(), "Violates".to_string()]) } else { Rc::new({ @@ -732,7 +750,7 @@ pub fn check_match_exhaustiveness( if ((uncovered.clone().len() as i64) > 0) { Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::NonExhaustiveMatch { - missing: uncovered, + missing: uncovered.clone(), span: span, }), module_name, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 18ae25272a3..8fe704ae16a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -92,11 +92,11 @@ pub fn unit_variant_in_coproduct( pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc { if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { match ty.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => target, - _ => ty, + Some(InferredNode::Resolved { node: target, .. }) => target.clone(), + _ => ty.clone(), } } else { - ty + ty.clone() } } @@ -107,8 +107,8 @@ pub fn lookup_unit_variant_phantom_type( { let matches = collect_unit_variant_phantom_matches(env, variant_name); if ((matches.clone().len() as i64) == 1) { - match matches.first().cloned() { - Some(variant) => Some(variant), + match matches.clone().first().cloned() { + Some(variant) => Some(variant.clone()), None => None, } } else { @@ -269,10 +269,13 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S if ((((brand.clone() != "".to_string()) && (brand.clone() != authored_name_at(source_indices.clone(), Rc::new(structural.clone())))) - && !is_declared_container_alias_spelling(brand)) - && !is_transparent_primitive_alias_rhs(Rc::new(structural.clone()), source_indices)) + && !is_declared_container_alias_spelling(brand.clone())) + && !is_transparent_primitive_alias_rhs( + Rc::new(structural.clone()), + source_indices.clone(), + )) { - with_authored_identity(n.clone(), Rc::new(structural)) + with_authored_identity(n.clone(), Rc::new(structural.clone())) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) @@ -281,7 +284,7 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_resolved = (*resolve_node_bounded( - target, + target.clone(), env.clone(), module_name.clone(), 0, @@ -290,10 +293,10 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S .clone(); with_authored_identity(n.clone(), Rc::new(target_resolved)) } - _ => resolved, + _ => resolved.clone(), } } else { - resolved + resolved.clone() } } } @@ -413,11 +416,11 @@ pub fn resolve_paramless_generic_use_decl( ) -> Rc { match ((n.children.clone().len() as i64) > 0) { true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { - Some(user_decl) => user_decl, + Some(user_decl) => user_decl.clone(), None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) { true => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural, + Some(structural) => structural.clone(), None => decl, }, false => decl, @@ -433,14 +436,14 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { match lookup_type_for(env.clone(), n.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { - decl + decl.clone() } else { - resolve_paramless_generic_use_decl(env.clone(), n, decl, brand) + resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(decl) => decl, - None => n, + Some(decl) => decl.clone(), + None => n.clone(), }, } } @@ -488,7 +491,7 @@ pub fn substitute_type_slots( &slot_bindings, authored_name_at(source_indices.clone(), n.clone()), ) { - Some(concrete) => concrete, + Some(concrete) => concrete.clone(), None => n.clone(), } } else { @@ -552,7 +555,7 @@ pub fn substitute_type_slots( Some(InferredNode::Resolved { node: rt, .. }) => { Some(Rc::new(InferredNode::Resolved { node: substitute_type_slots( - rt, + rt.clone(), slot_bindings.clone(), decl_name.clone(), source_indices.clone(), @@ -602,7 +605,7 @@ pub fn classify_alias(target: Rc) -> AliasKind { if (((target.children.clone().len() as i64) > 0) && nc.clone()) { AliasKind::AliasParameterized } else { - if ((((target.children.clone().len() as i64) == 0) && nc) + if ((((target.children.clone().len() as i64) == 0) && nc.clone()) && (target.ident_span.clone() != None)) { AliasKind::AliasLeaf @@ -621,16 +624,17 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - resolve_node_bounded(target, env.clone(), module_name, (depth + 1)).resolved.clone() + Rc::new((*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) + .clone()) } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), authored_name_at(env.source_indices.clone(), target.clone()), ) { - Some(env_target) => env_target, - None => target, + Some(env_target) => env_target.clone(), + None => target.clone(), }, - AliasKind::AliasPassthrough => target, + AliasKind::AliasPassthrough => target.clone(), } } @@ -672,7 +676,7 @@ pub fn resolve_nominal_alias_rhs( }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for ar in arg_results.iter().cloned() { + for ar in arg_results.clone().iter().cloned() { __result.extend((*ar.diagnostics.clone()).iter().cloned()); } __result @@ -742,7 +746,7 @@ pub fn resolve_node_bounded( match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( - base, + base.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), @@ -846,7 +850,7 @@ pub fn resolve_node_bounded( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.iter().cloned() { + for cr in child_results.clone().iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result @@ -1040,7 +1044,7 @@ pub fn resolve_node_bounded( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for vr in variant_results.iter().cloned() { + for vr in variant_results.clone().iter().cloned() { __result.extend((*vr.diagnostics.clone()).iter().cloned()); } __result @@ -1086,8 +1090,8 @@ pub fn resolve_node_bounded( Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::ArityMismatch { name: type_name.clone(), - expected: expected_arity, - got: actual_arity, + expected: expected_arity.clone(), + got: actual_arity.clone(), span: n.span.clone(), }), module_name.clone(), @@ -1116,7 +1120,7 @@ pub fn resolve_node_bounded( }); let arg_diags = Rc::new({ let mut __result = Vec::new(); - for ar in arg_results.iter().cloned() { + for ar in arg_results.clone().iter().cloned() { __result.extend((*ar.diagnostics.clone()).iter().cloned()); } __result @@ -1187,8 +1191,8 @@ pub fn resolve_node_bounded( let alias_target = match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { substitute_type_slots( - target, - slot_bindings, + target.clone(), + slot_bindings.clone(), type_name.clone(), env.source_indices.clone(), ) @@ -1224,10 +1228,10 @@ pub fn resolve_node_bounded( ident: None, }); let resolved_node = Rc::new(Node { - name: type_name, + name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: resolved_args, + children: resolved_args.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { @@ -1239,7 +1243,7 @@ pub fn resolve_node_bounded( transport: n.transport.clone(), properties: (*target_result.resolved).clone().properties.clone(), type_annotation: n.type_annotation.clone(), - is_self_recursive: is_recursive, + is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), @@ -1291,10 +1295,10 @@ pub fn resolve_node_bounded( }); let result = Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name, + name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: resolved_args, + children: resolved_args.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { @@ -1306,7 +1310,7 @@ pub fn resolve_node_bounded( transport: n.transport.clone(), properties: decl.properties.clone(), type_annotation: n.type_annotation.clone(), - is_self_recursive: is_recursive, + is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), match_pattern: n.match_pattern.clone(), expr_data: n.expr_data.clone(), @@ -1325,11 +1329,11 @@ pub fn resolve_node_bounded( { let type_name = authored_name(env.clone(), n.clone()); let key_child_node = match n.children.clone().first().cloned() { - Some(k) => k, + Some(k) => k.clone(), None => unit_type(), }; let val_child_node = match n.children.clone().get(1 as usize).cloned() { - Some(v) => v, + Some(v) => v.clone(), None => unit_type(), }; let key_type = child_type_node(key_child_node.clone()); @@ -1362,7 +1366,7 @@ pub fn resolve_node_bounded( authored_name(env.clone(), val_child_node.clone()) } else { match container_param_name(type_name.clone(), 1) { - Some(pn) => pn, + Some(pn) => pn.clone(), None => authored_name(env.clone(), val_child_node.clone()), } }; @@ -1412,7 +1416,7 @@ pub fn resolve_node_bounded( }); Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name, + name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), children: Rc::new(vec![resolved_key_child, resolved_val_child]), @@ -1455,7 +1459,7 @@ pub fn resolve_node_bounded( authored_name(env.clone(), child_node.clone()) } else { match container_param_name(type_name.clone(), 0) { - Some(pn) => pn, + Some(pn) => pn.clone(), None => { authored_name(env.clone(), child_node.clone()) } @@ -1485,7 +1489,7 @@ pub fn resolve_node_bounded( }); Rc::new(NodeResolveResult { resolved: Rc::new(Node { - name: type_name, + name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), children: Rc::new(vec![resolved_child]), @@ -1583,7 +1587,7 @@ pub fn resolve_node_bounded( == Connective::Disj)); if target_is_coproduct_use { (*resolve_node_bounded( - target, + target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), @@ -1591,13 +1595,13 @@ pub fn resolve_node_bounded( .resolved) .clone() } else { - target + target.clone() } } - _ => resolved, + _ => resolved.clone(), } } else { - resolved + resolved.clone() }; let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); @@ -1646,7 +1650,7 @@ pub fn resolve_node_bounded( } else { match lookup_unit_variant_phantom_type(env.clone(), authored_name(env.clone(), n.clone())) { Some(phantom) => Rc::new(NodeResolveResult { - resolved: phantom, + resolved: phantom.clone(), diagnostics: Rc::new(vec![]), }), None => Rc::new(NodeResolveResult { @@ -1687,7 +1691,7 @@ pub fn missing_generic_args_diagnostics( { let type_name = authored_name(env.clone(), n.clone()); let decl = match lookup_type_for(env.clone(), n.clone()) { - Some(d) => d, + Some(d) => d.clone(), None => n.clone(), }; Rc::new(vec![make_error_node( @@ -1717,7 +1721,9 @@ pub fn resolve_optional_node( }) } else { match (*n.clone().unwrap()).clone() { - InferredNode::Resolved { node: inner, .. } => resolve_node(inner, env, module_name), + InferredNode::Resolved { node: inner, .. } => { + resolve_node(inner.clone(), env, module_name) + } InferredNode::CompilerError { message: msg, span: sp, @@ -1730,8 +1736,8 @@ pub fn resolve_optional_node( ), diagnostics: Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::InternalError { - message: msg, - span: sp, + message: msg.clone(), + span: sp.clone(), }), module_name, )]), @@ -1744,7 +1750,7 @@ pub fn resolve_optional_node( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { id: tv })), + inferred: Some(Rc::new(InferredNode::TypeVariable { id: tv.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -1770,11 +1776,15 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> let type_resolved = (*type_result.resolved).clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), - missing_generic_args_diagnostics(authored_type, env.clone(), module_name.clone()), + missing_generic_args_diagnostics( + authored_type.clone(), + env.clone(), + module_name.clone(), + ), ); let default_resolved = match field_node_default_value(field.clone()) { Some(default_value) => Some(resolve_expr_types( - default_value, + default_value.clone(), env.clone(), module_name.clone(), )), @@ -1789,7 +1799,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> field_node_name_at(field.clone(), env.source_indices.clone()), Rc::new(type_resolved), field_node_cardinality(field.clone()), - match default_resolved { + match default_resolved.clone() { Some(result) => Some(result.expr.clone()), None => None, }, @@ -1835,11 +1845,15 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), - missing_generic_args_diagnostics(authored_type, env.clone(), module_name.clone()), + missing_generic_args_diagnostics( + authored_type.clone(), + env.clone(), + module_name.clone(), + ), ); let default_resolved = match param_node_default_value(param.clone()) { Some(default_value) => Some(resolve_expr_types( - default_value, + default_value.clone(), env.clone(), module_name.clone(), )), @@ -1849,7 +1863,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> Some(result) => result.diagnostics.clone(), None => Rc::new(vec![]), }; - let default_expr = match default_resolved { + let default_expr = match default_resolved.clone() { Some(result) => Some((*result.expr).clone()), None => None, }; @@ -1942,7 +1956,11 @@ pub fn resolve_match_arm( { let arm_g = arm_guard(arm.clone()); let guard_result = match arm_g { - Some(guard) => Some(resolve_expr_types(guard, env.clone(), module_name.clone())), + Some(guard) => Some(resolve_expr_types( + guard.clone(), + env.clone(), + module_name.clone(), + )), None => None, }; let guard_diags = match guard_result.clone() { @@ -1956,7 +1974,7 @@ pub fn resolve_match_arm( Rc::new(MatchArmResolveResult { arm: make_arm_node( arm_pattern(arm.clone()), - match guard_result { + match guard_result.clone() { Some(result) => Some(result.expr.clone()), None => None, }, @@ -1975,11 +1993,13 @@ pub fn resolve_string_part( ) -> Rc { match (*part).clone() { StringPart::Text { value: value, .. } => Rc::new(StringPartResolveResult { - part: Rc::new(StringPart::Text { value: value }), + part: Rc::new(StringPart::Text { + value: value.clone(), + }), diagnostics: Rc::new(vec![]), }), StringPart::Interpolation { expr: expr, .. } => { - let expr_result = resolve_expr_types(expr, env, module_name); + let expr_result = resolve_expr_types(expr.clone(), env, module_name); let resolved_expr = (*expr_result.expr).clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { @@ -2035,7 +2055,7 @@ pub fn resolve_transport_binding( }); let prop_diags = Rc::new({ let mut __result = Vec::new(); - for pr in prop_results.iter().cloned() { + for pr in prop_results.clone().iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result @@ -2060,7 +2080,7 @@ pub fn resolve_transport_binding( }); let child_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.iter().cloned() { + for cr in child_results.clone().iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result @@ -2103,10 +2123,10 @@ pub fn resolve_expr_types( diagnostics: Rc::new(vec![]), }), ExprData::ExprError { kind, message, .. } => Rc::new(ExprResolveResult { - expr: make_expr_error_node(kind, message.clone(), texpr.span.clone()), + expr: make_expr_error_node(kind.clone(), message.clone(), texpr.span.clone()), diagnostics: Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::InternalError { - message: message, + message: message.clone(), span: texpr.span.clone(), }), module_name.clone(), @@ -2120,7 +2140,9 @@ pub fn resolve_expr_types( }), ExprData::ExprFieldAccess { summary: _, .. } => { let r = match texpr.children.clone().first().cloned() { - Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), + Some(base) => { + resolve_expr_types(base.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2172,7 +2194,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.iter().cloned() { + for r in arg_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2181,8 +2203,8 @@ pub fn resolve_expr_types( expr: make_named_expr_node( expr_call_func_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprCall { - call_semantics: cs, - descent_evidence: de, + call_semantics: cs.clone(), + descent_evidence: de.clone(), }), resolved_children, texpr.inferred.clone(), @@ -2268,7 +2290,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.iter().cloned() { + for r in mc_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2277,7 +2299,7 @@ pub fn resolve_expr_types( expr: make_named_expr_node( expr_method_name_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprMethodCall { - method_semantics: ms, + method_semantics: ms.clone(), }), resolved_children, texpr.inferred.clone(), @@ -2405,7 +2427,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.iter().cloned() { + for r in match_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2423,21 +2445,25 @@ pub fn resolve_expr_types( ExprData::ExprIf => { let ch = texpr.children.clone(); let cr = match ch.clone().first().cloned() { - Some(c) => resolve_expr_types(c, env.clone(), module_name.clone()), + Some(c) => resolve_expr_types(c.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; let tr = match ch.clone().get(1 as usize).cloned() { - Some(t) => resolve_expr_types(t, env.clone(), module_name.clone()), + Some(t) => resolve_expr_types(t.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let er = match ch.get(2 as usize).cloned() { - Some(e) => Some(resolve_expr_types(e, env.clone(), module_name.clone())), + let er = match ch.clone().get(2 as usize).cloned() { + Some(e) => Some(resolve_expr_types( + e.clone(), + env.clone(), + module_name.clone(), + )), None => None, }; let resolved_children = match er.clone() { @@ -2457,7 +2483,7 @@ pub fn resolve_expr_types( ), diagnostics: v1_rt::concat( v1_rt::concat(cr.diagnostics.clone(), tr.diagnostics.clone()), - match er { + match er.clone() { Some(r) => r.diagnostics.clone(), None => Rc::new(vec![]), }, @@ -2467,14 +2493,18 @@ pub fn resolve_expr_types( ExprData::ExprLet => { let ch = texpr.children.clone(); let vr = match ch.clone().first().cloned() { - Some(v) => resolve_expr_types(v, env.clone(), module_name.clone()), + Some(v) => resolve_expr_types(v.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let br = match ch.get(1 as usize).cloned() { - Some(bd) => Some(resolve_expr_types(bd, env.clone(), module_name.clone())), + let br = match ch.clone().get(1 as usize).cloned() { + Some(bd) => Some(resolve_expr_types( + bd.clone(), + env.clone(), + module_name.clone(), + )), None => None, }; let resolved_children = match br.clone() { @@ -2492,7 +2522,7 @@ pub fn resolve_expr_types( ), diagnostics: v1_rt::concat( vr.diagnostics.clone(), - match br { + match br.clone() { Some(r) => r.diagnostics.clone(), None => Rc::new(vec![]), }, @@ -2534,7 +2564,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.iter().cloned() { + for r in fi_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2542,7 +2572,9 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_named_expr_node( authored_name_at(env.source_indices.clone(), texpr.clone()), - Rc::new(ExprData::ExprRecordLit { parent_enum: pe }), + Rc::new(ExprData::ExprRecordLit { + parent_enum: pe.clone(), + }), resolved_children, texpr.inferred.clone(), texpr.span.clone(), @@ -2572,7 +2604,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in el_results.iter().cloned() { + for r in el_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2594,14 +2626,14 @@ pub fn resolve_expr_types( } => { let ch = texpr.children.clone(); let lr = match ch.clone().first().cloned() { - Some(l) => resolve_expr_types(l, env.clone(), module_name.clone()), + Some(l) => resolve_expr_types(l.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let rr = match ch.get(1 as usize).cloned() { - Some(r) => resolve_expr_types(r, env.clone(), module_name.clone()), + let rr = match ch.clone().get(1 as usize).cloned() { + Some(r) => resolve_expr_types(r.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2610,8 +2642,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprBinOp { - op: op, - algebra_field: af, + op: op.clone(), + algebra_field: af.clone(), }), Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), texpr.inferred.clone(), @@ -2622,7 +2654,7 @@ pub fn resolve_expr_types( } ExprData::ExprUnaryOp { op: op, .. } => { let r = match texpr.children.clone().first().cloned() { - Some(o) => resolve_expr_types(o, env.clone(), module_name.clone()), + Some(o) => resolve_expr_types(o.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2630,7 +2662,7 @@ pub fn resolve_expr_types( }; Rc::new(ExprResolveResult { expr: make_expr_node( - Rc::new(ExprData::ExprUnaryOp { op: op }), + Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), Rc::new(vec![r.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), @@ -2649,7 +2681,7 @@ pub fn resolve_expr_types( .collect::>(), ); let r = match texpr.children.clone().first().cloned() { - Some(b) => resolve_expr_types(b, env.clone(), module_name.clone()), + Some(b) => resolve_expr_types(b.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2707,7 +2739,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.iter().cloned() { + for r in part_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2743,7 +2775,7 @@ pub fn resolve_expr_types( }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in stmt_results.iter().cloned() { + for r in stmt_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2761,14 +2793,16 @@ pub fn resolve_expr_types( ExprData::ExprCast => { let ch = texpr.children.clone(); let r = match ch.clone().first().cloned() { - Some(inner) => resolve_expr_types(inner, env.clone(), module_name.clone()), + Some(inner) => { + resolve_expr_types(inner.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let tr = match ch.get(1 as usize).cloned() { - Some(target) => resolve_node(target, env.clone(), module_name.clone()), + let tr = match ch.clone().get(1 as usize).cloned() { + Some(target) => resolve_node(target.clone(), env.clone(), module_name.clone()), None => Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), @@ -2787,14 +2821,14 @@ pub fn resolve_expr_types( ExprData::ExprForEach => { let ch = texpr.children.clone(); let cr = match ch.clone().first().cloned() { - Some(c) => resolve_expr_types(c, env.clone(), module_name.clone()), + Some(c) => resolve_expr_types(c.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let br = match ch.get(1 as usize).cloned() { - Some(b) => resolve_expr_types(b, env.clone(), module_name.clone()), + let br = match ch.clone().get(1 as usize).cloned() { + Some(b) => resolve_expr_types(b.clone(), env.clone(), module_name.clone()), None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2815,14 +2849,18 @@ pub fn resolve_expr_types( ExprData::ExprIndex => { let ch = texpr.children.clone(); let br = match ch.clone().first().cloned() { - Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), + Some(base) => { + resolve_expr_types(base.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let ir = match ch.get(1 as usize).cloned() { - Some(index) => resolve_expr_types(index, env.clone(), module_name.clone()), + let ir = match ch.clone().get(1 as usize).cloned() { + Some(index) => { + resolve_expr_types(index.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2841,21 +2879,27 @@ pub fn resolve_expr_types( ExprData::ExprSlice => { let ch = texpr.children.clone(); let br = match ch.clone().first().cloned() { - Some(base) => resolve_expr_types(base, env.clone(), module_name.clone()), + Some(base) => { + resolve_expr_types(base.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; let sr = match ch.clone().get(1 as usize).cloned() { - Some(start) => resolve_expr_types(start, env.clone(), module_name.clone()), + Some(start) => { + resolve_expr_types(start.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), }; - let er = match ch.get(2 as usize).cloned() { - Some(end_e) => resolve_expr_types(end_e, env.clone(), module_name.clone()), + let er = match ch.clone().get(2 as usize).cloned() { + Some(end_e) => { + resolve_expr_types(end_e.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -2880,7 +2924,9 @@ pub fn resolve_expr_types( } ExprData::ExprReturn => { let r = match texpr.children.clone().first().cloned() { - Some(inner) => resolve_expr_types(inner, env.clone(), module_name.clone()), + Some(inner) => { + resolve_expr_types(inner.clone(), env.clone(), module_name.clone()) + } None => Rc::new(ExprResolveResult { expr: texpr.clone(), diagnostics: Rc::new(vec![]), @@ -3000,10 +3046,9 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) } else { Rc::new(vec![]) }; - let env = tp_names - .iter() - .cloned() - .fold(env.clone(), |e: Rc, tp_name: String| { + let env = tp_names.clone().iter().cloned().fold( + env.clone(), + |e: Rc, tp_name: String| { let tp_binding = Rc::new(TypeBinding { name: tp_name.clone(), resolved: Rc::new(Node { @@ -3049,7 +3094,8 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) source_indices: e.source_indices.clone(), intern_table: e.intern_table.clone(), }) - }); + }, + ); let param_results = Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { @@ -3066,7 +3112,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for pr in param_results.iter().cloned() { + for pr in param_results.clone().iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result @@ -3075,7 +3121,11 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) match item.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: authored_rhs, .. - }) => resolve_nominal_alias_rhs(authored_rhs, env.clone(), module_name.clone()), + }) => resolve_nominal_alias_rhs( + authored_rhs.clone(), + env.clone(), + module_name.clone(), + ), _ => resolve_optional_node( item.inferred.clone(), env.clone(), @@ -3112,7 +3162,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }); let use_diags = Rc::new({ let mut __result = Vec::new(); - for ur in use_results.iter().cloned() { + for ur in use_results.clone().iter().cloned() { __result.extend((*ur.diagnostics.clone()).iter().cloned()); } __result @@ -3195,7 +3245,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }); let prop_diags = Rc::new({ let mut __result = Vec::new(); - for pr in prop_results.iter().cloned() { + for pr in prop_results.clone().iter().cloned() { __result.extend((*pr.diagnostics.clone()).iter().cloned()); } __result @@ -3370,7 +3420,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }); let child_diags = Rc::new({ let mut __result = Vec::new(); - for cr in child_results.iter().cloned() { + for cr in child_results.clone().iter().cloned() { __result.extend((*cr.diagnostics.clone()).iter().cloned()); } __result diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index b2f7a482d01..8d0917f731a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -60,7 +60,7 @@ pub fn is_typed_service_call_receiver( .first() .cloned() { - Some(ch) => ((ch.clone() >= 65) && (ch <= 90)), + Some(ch) => ((ch.clone() >= 65) && (ch.clone() <= 90)), None => false, }, _ => false, @@ -82,7 +82,7 @@ pub fn extract_typed_service_name( ExprData::ExprVar { binding_kind: _, .. } => { - let ns = expr_var_name_at(b, source_indices.clone()); + let ns = expr_var_name_at(b.clone(), source_indices.clone()); Some(v1_rt::concat(v1_rt::concat(ns, ".".to_string()), f)) } _ => None, @@ -122,7 +122,7 @@ pub fn collect_typed_service_calls_into( } => { let r = method_receiver(texpr.clone()); if is_typed_service_call_receiver(r.clone(), source_indices.clone()) { - match extract_typed_service_name(r, source_indices.clone()) { + match extract_typed_service_name(r.clone(), source_indices.clone()) { Some(service_name) => { if emit_map_has(acc.seen.clone(), service_name.clone()) { acc.clone() @@ -133,7 +133,10 @@ pub fn collect_typed_service_calls_into( service_name.clone(), true, ), - result: v1_rt::rc_list_push(acc.result.clone(), service_name), + result: v1_rt::rc_list_push( + acc.result.clone(), + service_name.clone(), + ), }) } } @@ -146,7 +149,7 @@ pub fn collect_typed_service_calls_into( _ => acc.clone(), }; let result = texpr.children.clone().iter().cloned().fold( - this_acc, + this_acc.clone(), |a: Rc, child: Rc| { collect_typed_service_calls_into(child.clone(), a, source_indices.clone()) }, @@ -169,14 +172,14 @@ pub fn collect_called_func_names_into( } else { Rc::new(UniqueAccum { seen: v1_rt::rc_map_insert(acc.seen.clone(), f.clone(), true), - result: v1_rt::rc_list_push(acc.result.clone(), f), + result: v1_rt::rc_list_push(acc.result.clone(), f.clone()), }) } } _ => acc.clone(), }; let result = texpr.children.clone().iter().cloned().fold( - this_acc, + this_acc.clone(), |a: Rc, child: Rc| { collect_called_func_names_into(child.clone(), a, source_indices.clone()) }, @@ -206,7 +209,7 @@ pub fn expand_transitive_services_once( modules: Rc>>, registry: Rc>>, ) -> Rc>> { - modules.iter().cloned().fold(registry, |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { + modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { @@ -269,7 +272,7 @@ pub fn expand_transitive_services( let before = total_service_count(registry.clone()); let next = expand_transitive_services_once(modules.clone(), registry.clone()); let after = total_service_count(next.clone()); - if (before.clone() == after.clone()) { + if (before == after) { break registry.clone(); } else { { @@ -302,7 +305,7 @@ pub fn check_service_field_access_node( field, ); match v1_rt::map_get(&service_registry, path.clone()) { - Some(_) => Some(nominal_type_ref(path)), + Some(_) => Some(nominal_type_ref(path.clone())), None => None, } } @@ -327,7 +330,7 @@ pub fn check_service_method_call_node( Some(ops) => { let matching = Rc::new({ let mut __result = Vec::new(); - for op in ops.iter().cloned() { + for op in ops.clone().iter().cloned() { if (op.name.clone() == method.clone()) { __result.push(op); } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 0d94999a2ee..5d4fde8c998 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -85,7 +85,7 @@ pub fn lookup_in_parent_chain( pub fn lookup_resolved_sig(env: Rc, name: String) -> Option> { match v1_rt::map_get(&env.local.clone(), name.clone()) { - Some(sig) => Some(sig), + Some(sig) => Some(sig.clone()), None => lookup_in_parent_chain(env.parents.clone(), name.clone()), } } @@ -130,7 +130,7 @@ pub fn collect_calls_in_expr( if emit_map_has(local_func_set.clone(), f.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: f, + callee: f.clone(), })]) } else { Rc::new(vec![]) @@ -472,7 +472,7 @@ pub fn topo_resolve_loop( __result }); { - let __tco_0 = next_remaining.clone(); + let __tco_0 = next_remaining; let __tco_1 = ready_accum.signatures.clone(); let __tco_2 = ready_accum.diagnostics.clone(); let __tco_3 = (fuel - 1); @@ -523,11 +523,11 @@ pub fn resolve_func_sigs( v1_rt::rc_empty_map::>(), declared_sigs, call_edges, - local_func_set, + local_func_set.clone(), module_name, Rc::new(vec![]), parent_envs, - (local_func_names.len() as i64), + (local_func_names.clone().len() as i64), ) } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index db063913cb3..e4524ca2d05 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -84,7 +84,7 @@ pub fn type_variable_node(id: String) -> Rc { pub fn resolved_type(n: Rc) -> Rc { match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } } @@ -99,7 +99,7 @@ pub fn child_type_node(ch: Rc) -> Rc { pub fn child_type_at(n: Rc, index: i64) -> Option> { match n.children.clone().get(index as usize).cloned() { - Some(ch) => Some(child_type_node(ch)), + Some(ch) => Some(child_type_node(ch.clone())), None => None, } } @@ -142,8 +142,8 @@ pub fn canonical_template_name( { let nm = authored_name_at(source_indices, n); match container_template_algebra(nm.clone()) { - Some(algebra) => algebra, - None => nm, + Some(algebra) => algebra.clone(), + None => nm.clone(), } } } @@ -243,7 +243,7 @@ pub fn is_fully_resolved( ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let self_is_type_var = match n.inferred.clone() { - Some(inf) => is_type_variable(inf), + Some(inf) => is_type_variable(inf.clone()), None => false, }; if self_is_type_var { @@ -254,7 +254,7 @@ pub fn is_fully_resolved( source_indices.clone(), n.clone(), )) { - Some(expected) => ((n.children.clone().len() as i64) < expected), + Some(expected) => ((n.children.clone().len() as i64) < expected.clone()), None => false, }; if under_param { @@ -295,7 +295,7 @@ pub fn bare_map_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(key_id), + node: type_variable_node(key_id.clone()), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -317,7 +317,7 @@ pub fn bare_map_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(val_id), + node: type_variable_node(val_id.clone()), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -367,7 +367,7 @@ pub fn bare_set_node() -> Option> { connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_variable_node(elem_id), + node: type_variable_node(elem_id.clone()), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -438,7 +438,7 @@ pub fn missing_kernel_container_profile_type(kind_name: String) -> Rc { match_pattern: None, expr_data: Rc::new(ExprData::ExprError { kind: ExprErrorKind::InternalExprError, - message: msg, + message: msg.clone(), }), ident: None, }) @@ -461,7 +461,7 @@ pub fn make_container_type(kind_name: String, element: Rc) -> Rc, value: Rc) -> Rc { Rc::new(Node { name: key_name.clone(), span: kernel_span(key_name.clone()), - ident_span: Some(kernel_span(key_name)), + ident_span: Some(kernel_span(key_name.clone())), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -536,7 +536,7 @@ pub fn make_map_type(key: Rc, value: Rc) -> Rc { Rc::new(Node { name: val_name.clone(), span: kernel_span(val_name.clone()), - ident_span: Some(kernel_span(val_name)), + ident_span: Some(kernel_span(val_name.clone())), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -812,7 +812,7 @@ pub fn algebra_child_or_placeholder( .first() .cloned() { - Some(child) => child_type_node(child), + Some(child) => child_type_node(child.clone()), None => type_variable_node(placeholder), } } @@ -844,12 +844,12 @@ pub fn instantiate_algebra_type( diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::NamedTemplate { name: n, .. } => Rc::new(KernelTypeBuild { - ty: nominal_type_ref(n), + ty: nominal_type_ref(n.clone()), diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { Rc::new(KernelTypeBuild { - ty: type_variable_node(var_id), + ty: type_variable_node(var_id.clone()), diagnostics: Rc::new(vec![]), }) } @@ -858,13 +858,14 @@ pub fn instantiate_algebra_type( element: inner, .. } => { - let kind_name = match (*src).clone() { + let kind_name = match (*src.clone()).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), base.clone()) } - ContainerSource::Named { name: n, .. } => n, + ContainerSource::Named { name: n, .. } => n.clone(), }; - let inner_b = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); + let inner_b = + instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); let built = make_container_type(kind_name, inner_b.ty.clone()); Rc::new(KernelTypeBuild { ty: built.ty.clone(), @@ -875,14 +876,16 @@ pub fn instantiate_algebra_type( }) } AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => { - let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); + let ib = + instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { - let ib = instantiate_algebra_type(inner, base.clone(), source_indices.clone()); + let ib = + instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { ty: built.ty.clone(), @@ -890,10 +893,12 @@ pub fn instantiate_algebra_type( }) } AlgebraTypeTemplate::TupleOf { first, second, .. } => { - let fb = instantiate_algebra_type(first, base.clone(), source_indices.clone()); - let sb = instantiate_algebra_type(second, base.clone(), source_indices.clone()); + let fb = + instantiate_algebra_type(first.clone(), base.clone(), source_indices.clone()); + let sb = + instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -904,7 +909,7 @@ pub fn instantiate_algebra_type( } => { let param_bs = Rc::new({ let mut __result = Vec::new(); - for tp in p.iter().cloned() { + for tp in p.clone().iter().cloned() { __result.push(instantiate_algebra_type( tp.clone(), base.clone(), @@ -922,14 +927,14 @@ pub fn instantiate_algebra_type( }); let param_nodes = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.iter().cloned() { + for b in param_bs.clone().iter().cloned() { __result.push((*b.ty).clone()); } __result }); - let rb = instantiate_algebra_type(r, base.clone(), source_indices.clone()); + let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))))))))(param_nodes, (*rb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -963,7 +968,7 @@ pub fn instantiate_algebra_field( }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.iter().cloned() { + for b in param_bs.clone().iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result @@ -974,7 +979,11 @@ pub fn instantiate_algebra_field( source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))))))))(template.name.clone(), param_types, (*return_b.ty).clone()) + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))( + template.name.clone(), + param_types.clone(), + (*return_b.ty).clone(), + ) } else { algebra_value_field(template.name.clone(), return_b.ty.clone()) }; @@ -996,7 +1005,7 @@ pub fn enrich_kernel_type( Some(p) => { let field_bs = Rc::new({ let mut __result = Vec::new(); - for template in algebra_templates_for_profile(p).iter().cloned() { + for template in algebra_templates_for_profile(p.clone()).iter().cloned() { __result.push(instantiate_algebra_field( template.clone(), base.clone(), @@ -1014,7 +1023,7 @@ pub fn enrich_kernel_type( }); let field_diags = Rc::new({ let mut __result = Vec::new(); - for b in field_bs.iter().cloned() { + for b in field_bs.clone().iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result @@ -1042,62 +1051,70 @@ pub fn unify_template( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*template).clone() { AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { if (v1_rt::map_get(&subst, var_id.clone()) != None) { - subst + subst.clone() } else { - v1_rt::rc_map_insert(subst, var_id, concrete.clone()) + v1_rt::rc_map_insert(subst.clone(), var_id.clone(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverSelf => { let s1 = match concrete.children.clone().first().cloned() { Some(k) => { if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { - subst + subst.clone() } else { - v1_rt::rc_map_insert(subst, "__key__".to_string(), child_type_node(k)) + v1_rt::rc_map_insert( + subst.clone(), + "__key__".to_string(), + child_type_node(k.clone()), + ) } } - None => subst, + None => subst.clone(), }; match concrete.children.clone().get(1 as usize).cloned() { Some(v) => { if (v1_rt::map_get(&s1, "__value__".to_string()) != None) { - s1 + s1.clone() } else { - v1_rt::rc_map_insert(s1, "__value__".to_string(), child_type_node(v)) + v1_rt::rc_map_insert( + s1.clone(), + "__value__".to_string(), + child_type_node(v.clone()), + ) } } - None => s1, + None => s1.clone(), } } AlgebraTypeTemplate::ReceiverKey => { if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { - subst + subst.clone() } else { - v1_rt::rc_map_insert(subst, "__key__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst.clone(), "__key__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverValue => { if (v1_rt::map_get(&subst, "__value__".to_string()) != None) { - subst + subst.clone() } else { - v1_rt::rc_map_insert(subst, "__value__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst.clone(), "__value__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverElement => { if (v1_rt::map_get(&subst, "__element__".to_string()) != None) { - subst + subst.clone() } else { - v1_rt::rc_map_insert(subst, "__element__".to_string(), concrete.clone()) + v1_rt::rc_map_insert(subst.clone(), "__element__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::CallableOf { return_type: ret_template, .. } => unify_template( - ret_template, + ret_template.clone(), concrete.clone(), receiver.clone(), - subst, + subst.clone(), source_indices.clone(), ), AlgebraTypeTemplate::ContainerOf { @@ -1105,24 +1122,24 @@ pub fn unify_template( element: elem_template, .. } => { - let expected_name = match (*src).clone() { + let expected_name = match (*src.clone()).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), receiver.clone()) } - ContainerSource::Named { name: n, .. } => n, + ContainerSource::Named { name: n, .. } => n.clone(), }; if (authored_name_at(source_indices.clone(), concrete.clone()) != expected_name) { - subst + subst.clone() } else { match concrete.children.clone().first().cloned() { Some(child) => unify_template( - elem_template, - child_type_node(child), + elem_template.clone(), + child_type_node(child.clone()), receiver.clone(), - subst, + subst.clone(), source_indices.clone(), ), - None => subst, + None => subst.clone(), } } } @@ -1131,13 +1148,13 @@ pub fn unify_template( .. } => match concrete.children.clone().first().cloned() { Some(child) => unify_template( - inner_template, - child_type_node(child), + inner_template.clone(), + child_type_node(child.clone()), receiver.clone(), - subst, + subst.clone(), source_indices.clone(), ), - None => subst, + None => subst.clone(), }, AlgebraTypeTemplate::TupleOf { first: ft, @@ -1146,18 +1163,18 @@ pub fn unify_template( } => { let s2 = match concrete.children.clone().first().cloned() { Some(c) => unify_template( - ft, + ft.clone(), child_type_node(c.clone()), receiver.clone(), - subst, + subst.clone(), source_indices.clone(), ), - None => subst, + None => subst.clone(), }; match concrete.children.clone().get(1 as usize).cloned() { Some(c) => unify_template( - st, - child_type_node(c), + st.clone(), + child_type_node(c.clone()), receiver.clone(), s2, source_indices.clone(), @@ -1165,7 +1182,7 @@ pub fn unify_template( None => s2, } } - _ => subst, + _ => subst.clone(), }) } @@ -1185,7 +1202,7 @@ pub fn build_type_substitution( ) -> Rc>> { { let first_is_self = match param_templates.clone().first().cloned() { - Some(t) => is_receiver_self(t), + Some(t) => is_receiver_self(t.clone()), None => false, }; let non_receiver_templates = if first_is_self { @@ -1220,7 +1237,7 @@ pub fn build_type_substitution( __result }); pairs.iter().cloned().fold( - base_subst, + base_subst.clone(), |subst: Rc>>, pair: (i64, Rc)| { let arg_type = match Rc::new({ let mut __result = Vec::new(); @@ -1279,11 +1296,11 @@ pub fn apply_type_substitution( AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { match v1_rt::map_get(&subst, var_id.clone()) { Some(resolved) => Rc::new(KernelTypeBuild { - ty: resolved, + ty: resolved.clone(), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { - ty: type_variable_node(var_id), + ty: type_variable_node(var_id.clone()), diagnostics: Rc::new(vec![]), }), } @@ -1318,10 +1335,10 @@ pub fn apply_type_substitution( match v1_rt::map_get(&subst, "__key__".to_string()) { Some(key) => { let val = match v1_rt::map_get(&subst, "__value__".to_string()) { - Some(v) => v, + Some(v) => v.clone(), None => type_variable_node("V".to_string()), }; - make_map_type(key, val) + make_map_type(key.clone(), val) } None => Rc::new(KernelTypeBuild { ty: receiver.clone(), @@ -1329,9 +1346,11 @@ pub fn apply_type_substitution( }), } } else { - if (arity == Some(1)) { + if (arity.clone() == Some(1)) { match v1_rt::map_get(&subst, "__element__".to_string()) { - Some(elem) => make_container_type(receiver_name_str, elem), + Some(elem) => { + make_container_type(receiver_name_str.clone(), elem.clone()) + } None => Rc::new(KernelTypeBuild { ty: receiver.clone(), diagnostics: Rc::new(vec![]), @@ -1354,25 +1373,25 @@ pub fn apply_type_substitution( } AlgebraTypeTemplate::ReceiverElement => match receiver.children.clone().first().cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child), + ty: child_type_node(child.clone()), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__element__".to_string()) { Some(elem) => Rc::new(KernelTypeBuild { - ty: elem, + ty: elem.clone(), diagnostics: Rc::new(vec![]), }), None => { let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 0) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n), + ty: type_variable_node(n.clone()), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![kernel_container_profile_miss_diagnostic( - rname, + rname.clone(), )]), }), } @@ -1381,25 +1400,25 @@ pub fn apply_type_substitution( }, AlgebraTypeTemplate::ReceiverKey => match receiver.children.clone().first().cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child), + ty: child_type_node(child.clone()), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__key__".to_string()) { Some(key) => Rc::new(KernelTypeBuild { - ty: key, + ty: key.clone(), diagnostics: Rc::new(vec![]), }), None => { let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 0) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n), + ty: type_variable_node(n.clone()), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![kernel_container_profile_miss_diagnostic( - rname, + rname.clone(), )]), }), } @@ -1409,7 +1428,7 @@ pub fn apply_type_substitution( AlgebraTypeTemplate::ReceiverValue => { match receiver.children.clone().get(1 as usize).cloned() { Some(child) => Rc::new(KernelTypeBuild { - ty: child_type_node(child), + ty: child_type_node(child.clone()), diagnostics: Rc::new(vec![]), }), None => match v1_rt::map_get(&subst, "__value__".to_string()) { @@ -1421,13 +1440,13 @@ pub fn apply_type_substitution( let rname = authored_name_at(source_indices.clone(), receiver.clone()); match container_param_name(rname.clone(), 1) { Some(n) => Rc::new(KernelTypeBuild { - ty: type_variable_node(n), + ty: type_variable_node(n.clone()), diagnostics: Rc::new(vec![]), }), None => Rc::new(KernelTypeBuild { ty: missing_kernel_container_profile_type(rname.clone()), diagnostics: Rc::new(vec![ - kernel_container_profile_miss_diagnostic(rname), + kernel_container_profile_miss_diagnostic(rname.clone()), ]), }), } @@ -1436,7 +1455,7 @@ pub fn apply_type_substitution( } } AlgebraTypeTemplate::NamedTemplate { name: n, .. } => Rc::new(KernelTypeBuild { - ty: nominal_type_ref(n), + ty: nominal_type_ref(n.clone()), diagnostics: Rc::new(vec![]), }), AlgebraTypeTemplate::ContainerOf { @@ -1444,14 +1463,14 @@ pub fn apply_type_substitution( element: inner, .. } => { - let kind_name = match (*src).clone() { + let kind_name = match (*src.clone()).clone() { ContainerSource::SameAsReceiver => { authored_name_at(source_indices.clone(), receiver.clone()) } - ContainerSource::Named { name: n, .. } => n, + ContainerSource::Named { name: n, .. } => n.clone(), }; let inner_applied = apply_type_substitution( - inner, + inner.clone(), subst.clone(), receiver.clone(), source_indices.clone(), @@ -1467,7 +1486,7 @@ pub fn apply_type_substitution( } AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => { let ib = apply_type_substitution( - inner, + inner.clone(), subst.clone(), receiver.clone(), source_indices.clone(), @@ -1479,7 +1498,7 @@ pub fn apply_type_substitution( } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = apply_type_substitution( - inner, + inner.clone(), subst.clone(), receiver.clone(), source_indices.clone(), @@ -1496,19 +1515,19 @@ pub fn apply_type_substitution( .. } => { let fb = apply_type_substitution( - ft, + ft.clone(), subst.clone(), receiver.clone(), source_indices.clone(), ); let sb = apply_type_substitution( - st, + st.clone(), subst.clone(), receiver.clone(), source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1519,7 +1538,7 @@ pub fn apply_type_substitution( } => { let param_bs = Rc::new({ let mut __result = Vec::new(); - for tp in p.iter().cloned() { + for tp in p.clone().iter().cloned() { __result.push(apply_type_substitution( tp.clone(), subst.clone(), @@ -1538,13 +1557,17 @@ pub fn apply_type_substitution( }); let param_diags = Rc::new({ let mut __result = Vec::new(); - for b in param_bs.iter().cloned() { + for b in param_bs.clone().iter().cloned() { __result.extend((*b.diagnostics.clone()).iter().cloned()); } __result }); - let rb = - apply_type_substitution(r, subst.clone(), receiver.clone(), source_indices.clone()); + let rb = apply_type_substitution( + r.clone(), + subst.clone(), + receiver.clone(), + source_indices.clone(), + ); Rc::new(KernelTypeBuild { ty: make_callable_type( Rc::new({ @@ -1579,15 +1602,15 @@ pub fn template_return_has_variables(template: Rc) -> bool pub fn has_type_variable(t: Rc) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*t).clone() { AlgebraTypeTemplate::AlgebraTypeVariable { id: _, .. } => true, - AlgebraTypeTemplate::ContainerOf { element: inner, .. } => has_type_variable(inner), - AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => has_type_variable(inner), - AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => has_type_variable(inner), + AlgebraTypeTemplate::ContainerOf { element: inner, .. } => has_type_variable(inner.clone()), + AlgebraTypeTemplate::OptionalOf { inner: inner, .. } => has_type_variable(inner.clone()), + AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => has_type_variable(inner.clone()), AlgebraTypeTemplate::TupleOf { first: f, second: s, .. - } => (has_type_variable(f) || has_type_variable(s)), - AlgebraTypeTemplate::CallableOf { return_type: r, .. } => has_type_variable(r), + } => (has_type_variable(f.clone()) || has_type_variable(s.clone())), + AlgebraTypeTemplate::CallableOf { return_type: r, .. } => has_type_variable(r.clone()), _ => false, }) } @@ -1621,7 +1644,7 @@ pub fn callable_inferred(n: Rc) -> Rc { let is_callable = ((n.params.clone().len() as i64) > 0); if is_callable { match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: ret, .. }) => ret, + Some(InferredNode::Resolved { node: ret, .. }) => ret.clone(), None => error_type(), _ => error_type(), } @@ -1634,19 +1657,19 @@ pub fn callable_inferred(n: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if ((n.type_annotation.clone() != None) && has_structure.clone()) { + let unwrapped = if ((n.type_annotation.clone() != None) && has_structure) { n.children.clone().first().cloned() } else { None }; - match unwrapped.clone() { + match unwrapped { Some(base) => { let __tco_0 = base.clone(); n = __tco_0; continue; } None => { - break n; + break n.clone(); } } } @@ -1670,8 +1693,10 @@ pub fn node_type_shape( && (rt.ident_span.clone() != None)) && (authored_name_at(source_indices.clone(), rt.clone()) != "None".to_string())) - && (is_kernel_type(authored_name_at(source_indices.clone(), rt)) - == false)) + && (is_kernel_type(authored_name_at( + source_indices.clone(), + rt.clone(), + )) == false)) } _ => false, }; @@ -1719,7 +1744,7 @@ pub fn node_type_shape( { let elem_shape = match n.children.clone().first().cloned() { Some(el) => node_type_shape( - child_type_node(el), + child_type_node(el.clone()), source_indices.clone(), ), None => "?".to_string(), @@ -1796,23 +1821,23 @@ pub fn node_type_compatible( let right_opt = (right.return_cardinality.clone() == Cardinality::CardOptional); let right_is_unit = is_unit_like(right.clone()); let left_is_unit = is_unit_like(left.clone()); - if (left_err.clone() || right_err.clone()) { + if (left_err || right_err) { break true; } else { - if (left_tv.clone() || right_tv.clone()) { + if (left_tv || right_tv) { break true; } else { - if (left_opt.clone() && right_is_unit.clone()) { + if (left_opt.clone() && right_is_unit) { break true; } else { - if (left_is_unit.clone() && right_opt.clone()) { + if (left_is_unit && right_opt.clone()) { break true; } else { let left_is_container = node_is_element_collection(left.clone(), source_indices.clone()); let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); - if (left_is_container.clone() && right_is_container.clone()) { + if (left_is_container && right_is_container) { if (canonical_template_name(left.clone(), source_indices.clone()) != canonical_template_name(right.clone(), source_indices.clone())) { @@ -1827,9 +1852,7 @@ pub fn node_type_compatible( let left_el_is_unit = is_unit_like(left_el.clone()); let right_el_is_unit = is_unit_like(right_el.clone()); - if (left_el_is_unit.clone() - || right_el_is_unit.clone()) - { + if (left_el_is_unit || right_el_is_unit) { break true; } else { { @@ -1909,7 +1932,7 @@ pub fn node_type_compatible( let right_inner = with_required_cardinality(right.clone()); let left_inner_is_unit = is_unit_like(left_inner.clone()); let right_inner_is_unit = is_unit_like(right_inner.clone()); - if (left_inner_is_unit.clone() || right_inner_is_unit.clone()) { + if (left_inner_is_unit || right_inner_is_unit) { break true; } else { { @@ -1955,7 +1978,7 @@ pub fn prefer_specific_type( let left_is_unit_inner = if left_is_container.clone() { match left_first_child { Some(ch) => { - let el = child_type_node(ch); + let el = child_type_node(ch.clone()); let el_is_unit = is_unit_like(el); el_is_unit } @@ -1973,24 +1996,24 @@ pub fn prefer_specific_type( }; let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); - let same_kind = if (left_is_container && right_is_container) { + let same_kind = if (left_is_container.clone() && right_is_container) { (left_norm_name == authored_name_at(source_indices.clone(), right.clone())) } else { - if (left_is_optional && right_is_optional) { + if (left_is_optional.clone() && right_is_optional) { true } else { false } }; if (same_kind && left_is_unit_inner) { - right + right.clone() } else { if (is_fully_resolved(right.clone(), source_indices.clone()) && !is_fully_resolved(left.clone(), source_indices.clone())) { - right + right.clone() } else { - left + left.clone() } } } @@ -2032,7 +2055,7 @@ pub fn node_type_equals( if (left_tv.clone() && right_tv.clone()) { true } else { - if (left_tv || right_tv) { + if (left_tv.clone() || right_tv.clone()) { false } else { if (left_opt.clone() && right_is_unit_eq) { @@ -2041,7 +2064,7 @@ pub fn node_type_equals( if (left_is_unit_eq && right_opt.clone()) { true } else { - if (left_opt && right_opt) { + if (left_opt.clone() && right_opt.clone()) { node_type_equals_core( with_required_cardinality(left.clone()), with_required_cardinality(right.clone()), @@ -2128,10 +2151,10 @@ pub fn node_type_equals_core( } } } else { - if (left_leaf && right_struct) { + if (left_leaf.clone() && right_struct.clone()) { (left_name == right_name) } else { - if (left_struct && right_leaf) { + if (left_struct.clone() && right_leaf.clone()) { (left_name == right_name) } else { { @@ -2147,8 +2170,8 @@ pub fn node_type_equals_core( Some(left_ch) => { match right.children.clone().first().cloned() { Some(right_ch) => node_type_equals( - child_type_node(left_ch), - child_type_node(right_ch), + child_type_node(left_ch.clone()), + child_type_node(right_ch.clone()), source_indices.clone(), ), None => false, @@ -2171,41 +2194,46 @@ pub fn node_type_equals_core( && ((right.children.clone().len() as i64) == 2)) { match left.children.clone().first().cloned() { - Some(left_first) => match right - .children - .clone() - .first() - .cloned() - { - Some(right_first) => match left - .children - .clone() - .get(1 as usize) - .cloned() - { - Some(left_second) => match right + Some(left_first) => { + match right.children.clone().first().cloned() { + Some(right_first) => match left .children .clone() .get(1 as usize) .cloned() { - Some(right_second) => { - (node_type_equals( - child_type_node(left_first), - child_type_node(right_first), - source_indices.clone(), - ) && node_type_equals( - child_type_node(left_second), - child_type_node(right_second), - source_indices.clone(), - )) - } + Some(left_second) => match right + .children + .clone() + .get(1 as usize) + .cloned() + { + Some(right_second) => { + (node_type_equals( + child_type_node( + left_first.clone(), + ), + child_type_node( + right_first.clone(), + ), + source_indices.clone(), + ) && node_type_equals( + child_type_node( + left_second.clone(), + ), + child_type_node( + right_second.clone(), + ), + source_indices.clone(), + )) + } + None => false, + }, None => false, }, None => false, - }, - None => false, - }, + } + } None => false, } } else { @@ -2280,8 +2308,8 @@ pub fn node_type_equals_core( node: right_ret, .. }) => node_type_equals( - left_ret, - right_ret, + left_ret.clone(), + right_ret.clone(), source_indices.clone(), ), None => false, @@ -2343,7 +2371,7 @@ pub fn node_type_deps( if __is_named_ref { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - Rc::new(vec![authored_name_at(source_indices.clone(), rt)]) + Rc::new(vec![authored_name_at(source_indices.clone(), rt.clone())]) } _ => Rc::new(vec![]), } @@ -2375,7 +2403,7 @@ pub fn node_type_deps( if (n.inferred.clone() != None) { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - node_type_deps(rt, source_indices.clone()) + node_type_deps(rt.clone(), source_indices.clone()) } _ => Rc::new(vec![]), } @@ -2396,7 +2424,7 @@ pub fn node_type_deps( if ((n.ident_span.clone() != None) && (is_kernel_type(n_name.clone()) == false)) { - v1_rt::concat(Rc::new(vec![n_name]), child_deps) + v1_rt::concat(Rc::new(vec![n_name.clone()]), child_deps) } else { child_deps } @@ -2408,7 +2436,7 @@ pub fn node_type_deps( { Rc::new(vec![]) } else { - Rc::new(vec![n_name]) + Rc::new(vec![n_name.clone()]) } } } @@ -2436,7 +2464,7 @@ pub fn method_receiver_element_node( let normed = normalize_access_type_node(receiver_type.clone()); let maybe_element = if node_is_keyed_collection(normed.clone(), source_indices) { match normed.children.clone().get(1 as usize).cloned() { - Some(ch) => Some(child_type_node(ch)), + Some(ch) => Some(child_type_node(ch.clone())), None => None, } } else { @@ -2444,7 +2472,7 @@ pub fn method_receiver_element_node( && ((normed.children.clone().len() as i64) == 1)) { match normed.children.clone().first().cloned() { - Some(ch) => Some(child_type_node(ch)), + Some(ch) => Some(child_type_node(ch.clone())), None => None, } } else { @@ -2452,8 +2480,8 @@ pub fn method_receiver_element_node( } }; match maybe_element { - Some(el) => el, - None => receiver_type, + Some(el) => el.clone(), + None => receiver_type.clone(), } } } @@ -2462,17 +2490,17 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { - with_required_cardinality(n) + with_required_cardinality(n.clone()) } else { if ((n.name.clone() == "Optional".to_string()) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { - Some(inner) => inner, - None => n, + Some(inner) => inner.clone(), + None => n.clone(), } } else { - n + n.clone() } } } @@ -2622,7 +2650,7 @@ pub fn infer_binop_type_node( Some(InferredNode::Resolved { node: return_type, .. }) => Rc::new(BinOpInferred { - result_type: return_type, + result_type: return_type.clone(), algebra_field: Some(m.field_kind.clone()), }), _ => Rc::new(BinOpInferred { @@ -2632,7 +2660,7 @@ pub fn infer_binop_type_node( } } else { Rc::new(BinOpInferred { - result_type: rt, + result_type: rt.clone(), algebra_field: Some(m.field_kind.clone()), }) } @@ -2667,14 +2695,14 @@ pub fn for_each_element_type_node( && ((normed.children.clone().len() as i64) == 1)); let extracted = if is_single_child { match normed.children.clone().first().cloned() { - Some(ch) => Some(child_type_node(ch)), + Some(ch) => Some(child_type_node(ch.clone())), None => None, } } else { None }; match extracted { - Some(el) => el, + Some(el) => el.clone(), None => { if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) @@ -2683,7 +2711,7 @@ pub fn for_each_element_type_node( { string_type() } else { - normed + normed.clone() } } } diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index a2e7bfec996..8d9415b728c 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -305,7 +305,7 @@ impl ServiceReturnStrategy { pub fn service_self_param(spec: Rc) -> String { match (*spec.service_method.clone()).clone() { - ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp, + ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp.clone(), ServiceMethodStrategy::ExternalReceiver { var_name: _, .. } => "".to_string(), } } @@ -315,7 +315,7 @@ pub fn service_receiver_str(spec: Rc, service_name: String) -> Str ServiceMethodStrategy::SelfInParams { self_param: _, .. } => "".to_string(), ServiceMethodStrategy::ExternalReceiver { var_name: v, .. } => v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat("(".to_string(), v), " *".to_string()), + v1_rt::concat(v1_rt::concat("(".to_string(), v.clone()), " *".to_string()), service_name, ), ") ".to_string(), @@ -345,7 +345,7 @@ pub fn service_return_str(spec: Rc, ret_type: String) -> String { ServiceReturnStrategy::ErrorTupleReturn { error_type: et, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat(v1_rt::concat(" (".to_string(), ret_type), ", ".to_string()), - et, + et.clone(), ), ")".to_string(), ), @@ -1224,18 +1224,18 @@ pub fn language_spec_for_target(target: RenderTarget) -> Rc { pub fn target_keyword(target: RenderTarget, key: String) -> String { match target { RenderTarget::Rust => match v1_rt::lookup(&rust_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw, - v1_rt::Witness::Violates { diagnostic: _, .. } => key, + v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), + v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), }, RenderTarget::Go => match v1_rt::lookup(&go_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw, - v1_rt::Witness::Violates { diagnostic: _, .. } => key, + v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), + v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), }, RenderTarget::Python => match v1_rt::lookup(&python_keywords(), key.clone()) { - v1_rt::Witness::Holds { value: kw, .. } => kw, - v1_rt::Witness::Violates { diagnostic: _, .. } => key, + v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), + v1_rt::Witness::Violates { diagnostic: _, .. } => key.clone(), }, - RenderTarget::Dag => key, + RenderTarget::Dag => key.clone(), } } @@ -1285,10 +1285,10 @@ pub fn binop_symbol( None => None, }; let result = match specific.clone() { - Some(_) => specific, + Some(_) => specific.clone(), None => Rc::new({ let mut __result = Vec::new(); - for spec in op_matching.iter().cloned() { + for spec in op_matching.clone().iter().cloned() { if (spec.algebra_field.clone() == None) { __result.push(spec); } diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 43ab91291d0..5e140789267 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -54,8 +54,8 @@ pub fn check_bare_containers( { Rc::new(vec![make_error_node( Rc::new(CompilerDiagnostic::ArityMismatch { - name: nname, - expected: expected, + name: nname.clone(), + expected: expected.clone(), got: 0, span: n.span.clone(), }), @@ -99,21 +99,27 @@ pub fn check_bare_containers( __result }); let type_ann_diags = match n.type_annotation.clone() { - Some(ta) => check_bare_containers(ta, module_name.clone(), source_indices.clone()), + Some(ta) => { + check_bare_containers(ta.clone(), module_name.clone(), source_indices.clone()) + } None => Rc::new(vec![]), }; let body_diags = match n.body.clone() { - Some(b) => check_bare_containers(b, module_name.clone(), source_indices.clone()), + Some(b) => { + check_bare_containers(b.clone(), module_name.clone(), source_indices.clone()) + } None => Rc::new(vec![]), }; let inferred_diags = if ((n.params.clone().len() as i64) > 0) { Rc::new(vec![]) } else { match n.inferred.clone() { - Some(inf) => match (*inf).clone() { - InferredNode::Resolved { node: rn, .. } => { - check_bare_containers(rn, module_name.clone(), source_indices.clone()) - } + Some(inf) => match (*inf.clone()).clone() { + InferredNode::Resolved { node: rn, .. } => check_bare_containers( + rn.clone(), + module_name.clone(), + source_indices.clone(), + ), _ => Rc::new(vec![]), }, None => Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 7b93d49aedc..0c41f844575 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -167,7 +167,7 @@ pub fn record_use( span_start: span_start, }); let existing = match v1_rt::map_get(&accum.bindings.clone(), name.clone()) { - Some(usage) => usage, + Some(usage) => usage.clone(), None => Rc::new(BindingUsage { name: name.clone(), binding_kind: None, @@ -193,9 +193,9 @@ pub fn record_use( pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc { if (binding_fan_out(b.clone()) > binding_fan_out(a.clone())) { - b + b.clone() } else { - a + a.clone() } } @@ -208,7 +208,7 @@ pub fn map_usage_merge_at( Some(existing) => v1_rt::rc_map_insert( base.clone(), key.clone(), - max_usage_by_fan_out(existing, new_val), + max_usage_by_fan_out(existing.clone(), new_val), ), None => v1_rt::rc_map_insert(base.clone(), key.clone(), new_val), } @@ -271,13 +271,13 @@ pub fn walk_expr( binding_kind: bk, .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if in_tail { + if in_tail.clone() { record_use( accum, n, EdgeKind::Consumed, "return".to_string(), - bk, + bk.clone(), texpr.span.clone().start.clone(), ) } else { @@ -286,7 +286,7 @@ pub fn walk_expr( n, EdgeKind::Read, "read".to_string(), - bk, + bk.clone(), texpr.span.clone().start.clone(), ) } @@ -298,18 +298,18 @@ pub fn walk_expr( ExprData::ExprVar { binding_kind: bk, .. } => { - let vn = expr_var_name_at(base_node, si.clone()); + let vn = expr_var_name_at(base_node.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); record_use( accum, vn, EdgeKind::Projected, v1_rt::concat(".".to_string(), f), - bk, + bk.clone(), texpr.span.clone().start.clone(), ) } - _ => walk_expr(accum, base_node, false, si.clone()), + _ => walk_expr(accum, base_node.clone(), false, si.clone()), } } ExprData::ExprCall { .. } => { @@ -329,7 +329,7 @@ pub fn walk_expr( .cloned(); let threaded_accum = match init_arg { Some(ia) => { - let ia_val = arg_value(ia); + let ia_val = arg_value(ia.clone()); match (*ia_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. @@ -340,11 +340,11 @@ pub fn walk_expr( vn, EdgeKind::Threaded, "fold_init".to_string(), - bk, + bk.clone(), ia_val.span.clone().start.clone(), ) } - _ => walk_expr(accum, ia_val, false, si.clone()), + _ => walk_expr(accum, ia_val.clone(), false, si.clone()), } } None => accum, @@ -359,7 +359,7 @@ pub fn walk_expr( __result }); non_init.iter().cloned().fold( - threaded_accum, + threaded_accum.clone(), |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -394,7 +394,7 @@ pub fn walk_expr( .cloned(); let threaded_accum = match init_arg { Some(ia) => { - let ia_val = arg_value(ia); + let ia_val = arg_value(ia.clone()); match (*ia_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. @@ -405,18 +405,18 @@ pub fn walk_expr( vn, EdgeKind::Threaded, "fold_init".to_string(), - bk, + bk.clone(), ia_val.span.clone().start.clone(), ) } - _ => walk_expr(recv_accum, ia_val, false, si.clone()), + _ => walk_expr(recv_accum, ia_val.clone(), false, si.clone()), } } None => recv_accum, }; let non_init = Rc::new({ let mut __result = Vec::new(); - for a in mc_args.iter().cloned() { + for a in mc_args.clone().iter().cloned() { if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } @@ -424,7 +424,7 @@ pub fn walk_expr( __result }); let walked = non_init.iter().cloned().fold( - threaded_accum, + threaded_accum.clone(), |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -440,7 +440,7 @@ pub fn walk_expr( } else { { let recv_accum = walk_expr(accum, recv, false, si.clone()); - mc_args.iter().cloned().fold( + mc_args.clone().iter().cloned().fold( recv_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) @@ -465,7 +465,7 @@ pub fn walk_expr( } __result }); - merge_branch_usages(s_accum, branch_accums) + merge_branch_usages(s_accum.clone(), branch_accums) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); @@ -473,16 +473,16 @@ pub fn walk_expr( let c_accum = walk_expr(accum, c, false, si.clone()); let t_accum = walk_expr(c_accum.clone(), t, in_tail.clone(), si.clone()); let e_accum = match if_else_branch(texpr.clone()) { - Some(eb) => walk_expr(c_accum.clone(), eb, in_tail, si.clone()), + Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail.clone(), si.clone()), None => c_accum.clone(), }; - merge_branch_usages(c_accum, Rc::new(vec![t_accum, e_accum])) + merge_branch_usages(c_accum.clone(), Rc::new(vec![t_accum, e_accum])) } ExprData::ExprLet => { let v = let_value(texpr.clone()); let v_accum = walk_expr(accum, v, false, si.clone()); match let_body(texpr.clone()) { - Some(b) => walk_expr(v_accum, b, in_tail, si.clone()), + Some(b) => walk_expr(v_accum, b.clone(), in_tail.clone(), si.clone()), None => v_accum, } } @@ -520,10 +520,13 @@ pub fn walk_expr( walk_expr(acc, p.1.clone(), false, si.clone()) }, ); - match ss.last().cloned() { - Some(last_expr) => { - walk_expr(init_accum, last_expr, in_tail, si.clone()) - } + match ss.clone().last().cloned() { + Some(last_expr) => walk_expr( + init_accum, + last_expr.clone(), + in_tail.clone(), + si.clone(), + ), None => init_accum, } } @@ -576,7 +579,7 @@ pub fn walk_expr( .iter() .cloned() .fold( - coll_accum, + coll_accum.clone(), |acc: Rc, usage: Rc| { let a1 = record_use( acc, @@ -666,7 +669,7 @@ pub fn make_decision(usage: Rc) -> Rc { }); Rc::new(OwnershipDecision::SharedError { binding: usage.name.clone(), - consumer_count: sc, + consumer_count: sc.clone(), sites: sites, }) } @@ -788,7 +791,7 @@ pub fn collect_callable_refs( match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: bk, .. - } => match bk.as_deref().cloned() { + } => match bk.clone().as_deref().cloned() { Some(VarBindingKind::FunctionValueBinding) => { let n = expr_var_name_at(texpr.clone(), si.clone()); v1_rt::rc_set_insert(v1_rt::rc_empty_set::<_>(), n) @@ -814,7 +817,7 @@ pub fn collect_callable_refs( } => { let recv = collect_callable_refs(method_receiver(texpr.clone()), si.clone()); method_arg_nodes(texpr.clone()).iter().cloned().fold( - recv, + recv.clone(), |acc: Rc>, a: Rc| { v1_rt::rc_set_union( acc, @@ -827,7 +830,7 @@ pub fn collect_callable_refs( let cond = collect_callable_refs(if_condition(texpr.clone()), si.clone()); let then_br = collect_callable_refs(if_then_branch(texpr.clone()), si.clone()); let else_br = match if_else_branch(texpr.clone()) { - Some(eb) => collect_callable_refs(eb, si.clone()), + Some(eb) => collect_callable_refs(eb.clone(), si.clone()), None => v1_rt::rc_empty_set::(), }; v1_rt::rc_set_union(v1_rt::rc_set_union(cond, then_br), else_br) @@ -835,7 +838,7 @@ pub fn collect_callable_refs( ExprData::ExprMatch => { let scrut = collect_callable_refs(match_scrutinee(texpr.clone()), si.clone()); match_arm_nodes(texpr.clone()).iter().cloned().fold( - scrut, + scrut.clone(), |acc: Rc>, arm: Rc| { v1_rt::rc_set_union( acc, @@ -847,7 +850,9 @@ pub fn collect_callable_refs( ExprData::ExprLet => { let val = collect_callable_refs(let_value(texpr.clone()), si.clone()); match let_body(texpr.clone()) { - Some(lb) => v1_rt::rc_set_union(val, collect_callable_refs(lb, si.clone())), + Some(lb) => { + v1_rt::rc_set_union(val, collect_callable_refs(lb.clone(), si.clone())) + } None => val, } } @@ -858,7 +863,7 @@ pub fn collect_callable_refs( }, ), ExprData::ExprReturn => match texpr.children.clone().first().cloned() { - Some(child) => collect_callable_refs(child, si.clone()), + Some(child) => collect_callable_refs(child.clone(), si.clone()), None => v1_rt::rc_empty_set::(), }, ExprData::ExprLambda => collect_callable_refs(lambda_body(texpr.clone()), si.clone()), @@ -944,7 +949,7 @@ pub fn summarize_fold_acc_uses( binding_kind: _, .. } => { if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { - if inside_nested { + if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -966,11 +971,11 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base, si.clone()) == acc_name.clone()), + } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), _ => false, }; if is_direct { - if inside_nested { + if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -1028,7 +1033,7 @@ pub fn summarize_fold_acc_uses( foreach_collection(node.clone()), acc_name.clone(), si.clone(), - inside_nested, + inside_nested.clone(), ); let body_summary = summarize_fold_acc_uses( foreach_body(node.clone()), @@ -1092,7 +1097,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal) == acc_type_name) + (authored_name_at(si, terminal.clone()) == acc_type_name) } _ => false, } @@ -1142,8 +1147,8 @@ pub fn analyze_single_fold( Some(a) => arg_value(a.clone()), None => method_call.clone(), }; - let fold_lambda_node = match args.get(1 as usize).cloned() { - Some(a) => arg_value(a), + let fold_lambda_node = match args.clone().get(1 as usize).cloned() { + Some(a) => arg_value(a.clone()), None => method_call.clone(), }; let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { @@ -1152,7 +1157,7 @@ pub fn analyze_single_fold( .first() .cloned() { - Some(n) => n, + Some(n) => n.clone(), None => "".to_string(), } } @@ -1180,17 +1185,20 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let cond_safe = - fold_body_safe_field_moves(fold_lambda_node, acc_param_name.clone(), si.clone()); + let cond_safe = fold_body_safe_field_moves( + fold_lambda_node.clone(), + acc_param_name.clone(), + si.clone(), + ); let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), - acc_param_name: acc_param_name, - acc_type_name: acc_type_name, - body_constructs_acc: cond_struct, - whole_acc_single_use: cond_whole_acc, - safe_field_moves: cond_safe, + acc_param_name: acc_param_name.clone(), + acc_type_name: acc_type_name.clone(), + body_constructs_acc: cond_struct.clone(), + whole_acc_single_use: cond_whole_acc.clone(), + safe_field_moves: cond_safe.clone(), eligible: eligible, }) } @@ -1208,7 +1216,7 @@ pub fn analyze_ownership( .iter() .cloned() .fold(empty_usage_accum(), |acc: Rc, p: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:23177:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let p_name = authored_name_at(si.clone(), p.clone()); Rc::new(UsageAccum { @@ -1282,7 +1290,7 @@ pub fn empty_live_state(name: String) -> Rc { pub fn live_state_of(acc: Rc, name: String) -> Rc { match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st, + Some(st) => st.clone(), None => empty_live_state(name.clone()), } } @@ -1374,7 +1382,7 @@ pub fn merge_branch_licenses(branches: Rc>>) -> Rc(), }), |acc: Rc, br: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:26035:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) .iter() @@ -1435,12 +1443,17 @@ pub fn license_walk( binding_kind: _, .. } => record_field_use_site( acc.clone(), - expr_var_name_at(base_node, si.clone()), + expr_var_name_at(base_node.clone(), si.clone()), field_access_field_at(texpr.clone(), si.clone()), texpr.span.clone().start.clone(), in_capture.clone(), ), - _ => license_walk(acc.clone(), base_node, in_capture.clone(), si.clone()), + _ => license_walk( + acc.clone(), + base_node.clone(), + in_capture.clone(), + si.clone(), + ), } } ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) @@ -1471,7 +1484,9 @@ pub fn license_walk( si.clone(), ); let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => license_walk(acc.clone(), eb, in_capture.clone(), si.clone()), + Some(eb) => { + license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) + } None => acc.clone(), }; let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); @@ -1505,7 +1520,7 @@ pub fn license_walk( } ExprData::ExprLet => { let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b, in_capture.clone(), si.clone()), + Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), None => acc.clone(), }; license_walk( diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index f243f2d79c5..0858d6d4efe 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -767,7 +767,7 @@ pub fn token_span(tok: Option>) -> Rc { pub fn advance(tokens: Rc) -> Rc { match token_stream_first(tokens.clone()) { Some(t) => Rc::new(AdvanceResult::AdvanceOk { - token: t, + token: t.clone(), tokens: token_stream_advance(tokens.clone(), 1), }), None => Rc::new(AdvanceResult::AdvanceEof), @@ -806,7 +806,7 @@ pub fn parse_string_literal_value(tokens: Rc) -> Rc) -> Rc { let n_opt = v1_rt::parse_int(t.text.clone()); match n_opt { Some(n) => Rc::new(IntLitResult { - value: n, + value: n.clone(), tokens: token_stream_advance(tokens.clone(), 1), err: None, }), @@ -847,7 +847,7 @@ pub fn parse_int_literal_value(tokens: Rc) -> Rc { ), "'".to_string(), ), - token_span(tok), + token_span(tok.clone()), )), }), } @@ -857,7 +857,7 @@ pub fn parse_int_literal_value(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( "expected integer literal".to_string(), - token_span(tok), + token_span(tok.clone()), )), }), }, @@ -1462,9 +1462,10 @@ pub fn token_display_name(token: Rc) -> String { pub fn expected_token_name(expected: Rc) -> String { match (*expected).clone() { - ExpectedToken::ExpectKeyword { text: kw, .. } => { - v1_rt::concat("keyword '".to_string(), v1_rt::concat(kw, "'".to_string())) - } + ExpectedToken::ExpectKeyword { text: kw, .. } => v1_rt::concat( + "keyword '".to_string(), + v1_rt::concat(kw.clone(), "'".to_string()), + ), ExpectedToken::ExpectLBrace => "LBrace".to_string(), ExpectedToken::ExpectRBrace => "RBrace".to_string(), ExpectedToken::ExpectLParen => "LParen".to_string(), @@ -1487,7 +1488,7 @@ pub fn expected_token_name(expected: Rc) -> String { pub fn token_matches_expected(token: Rc, expected: Rc) -> bool { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { - (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw)) + (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw.clone())) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1524,7 +1525,7 @@ pub fn expect(tokens: Rc, expected: Rc) -> Rc token_display_name(t), + Some(t) => token_display_name(t.clone()), None => "EOF".to_string(), }; let wanted = expected_token_name(expected.clone()); @@ -1537,7 +1538,7 @@ pub fn expect(tokens: Rc, expected: Rc) -> Rc) -> Rc { }) } _ => { - let found = match sh { - Some(shape) => shape_display_name(shape), + let found = match sh.clone() { + Some(shape) => shape_display_name(shape.clone()), None => "EOF".to_string(), }; Rc::new(NameResult { @@ -1574,7 +1575,7 @@ pub fn expect_ident(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( v1_rt::concat("expected identifier, found ".to_string(), found), - token_span(tok), + token_span(tok.clone()), )), }) } @@ -1614,7 +1615,7 @@ pub fn expect_name(tokens: Rc) -> Rc { } None => { let found = match tok.clone() { - Some(t) => token_display_name(t), + Some(t) => token_display_name(t.clone()), None => "EOF".to_string(), }; Rc::new(NameResult { @@ -1623,7 +1624,7 @@ pub fn expect_name(tokens: Rc) -> Rc { tokens: tokens.clone(), err: Some(parse_error( v1_rt::concat("expected name, found ".to_string(), found), - token_span(tok), + token_span(tok.clone()), )), }) } @@ -1698,7 +1699,7 @@ pub fn eat(tokens: Rc, expected: Rc) -> Rc { if token_matches_expected(t.clone(), expected) { Rc::new(EatResult::EatConsumed { - token: t, + token: t.clone(), tokens: token_stream_advance(tokens.clone(), 1), }) } else { @@ -1722,7 +1723,7 @@ pub fn parser_result_base_var( Some(base) => match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => Some(expr_var_name_at(base, source_indices)), + } => Some(expr_var_name_at(base.clone(), source_indices)), _ => None, }, None => None, @@ -1778,7 +1779,9 @@ pub fn parser_progress_flag_var( match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((field.clone() == "consumed".to_string()) || (field == "changed".to_string())) { + if ((field.clone() == "consumed".to_string()) + || (field.clone() == "changed".to_string())) + { parser_result_base_var(expr.clone(), source_indices.clone()) } else { None @@ -1819,7 +1822,7 @@ pub fn parser_passthrough_state_expr( } Some(ParserHelperIdentity::ParserHelperWith) => { match expr.children.clone().first().cloned() { - Some(base_arg) => Some(arg_value(base_arg)), + Some(base_arg) => Some(arg_value(base_arg.clone())), None => None, } } @@ -1841,10 +1844,14 @@ pub fn parser_result_witness( ref __s if __s == "eat" => Rc::new(ParserResultWitness::ParserWitnessEat), callee => match parser_helper_identity(callee.clone()) { Some(helper) => Rc::new(ParserResultWitness::ParserWitnessCall { - callee: Rc::new(ParserCallIdentity::ParserCallHelper { helper: helper }), + callee: Rc::new(ParserCallIdentity::ParserCallHelper { + helper: helper.clone(), + }), }), None => Rc::new(ParserResultWitness::ParserWitnessCall { - callee: Rc::new(ParserCallIdentity::ParserCallFunction { name: callee }), + callee: Rc::new(ParserCallIdentity::ParserCallFunction { + name: callee.clone(), + }), }), }, }, @@ -1912,7 +1919,7 @@ pub fn parse_type_angle_arg(tokens: Rc, ctx: Rc) -> R Some(t) => Some(t.shape.clone()), None => None, }; - let span = token_span(tok); + let span = token_span(tok.clone()); match sh { Some(TokenShape::ShLitInt) => { let r = parse_int_literal_value(tokens.clone()); @@ -1943,7 +1950,7 @@ pub fn is_conj_with_children(n: Rc) -> bool { pub fn child_inferred_or_empty(ch: Rc) -> Rc { match ch.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => rt, + Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => error_type(), } } @@ -2004,7 +2011,7 @@ pub fn parse_dotted_ident(tokens: Rc) -> Rc { { let r = expect_name(tokens); if has_err(r.err.clone()) { - return r; + return r.clone(); } parse_dotted_ident_rest(r.tokens.clone(), r.name.clone(), r.span.clone()) } @@ -2016,11 +2023,11 @@ pub fn parse_dotted_ident_rest( mut span: Rc, ) -> Rc { loop { - match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectDot))).clone() { + match (*eat(tokens, Rc::new(ExpectedToken::ExpectDot))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let r = expect_name(__ec.clone()); if has_err(r.err.clone()) { - return r; + return r.clone(); } let extended = Rc::new(SourceSpan { file: span.file.clone(), @@ -2031,7 +2038,7 @@ pub fn parse_dotted_ident_rest( let __tco_0 = r.tokens.clone(); let __tco_1 = v1_rt::concat(v1_rt::concat(acc, ".".to_string()), r.name.clone()); - let __tco_2 = extended.clone(); + let __tco_2 = extended; tokens = __tco_0; acc = __tco_1; span = __tco_2; @@ -2040,7 +2047,7 @@ pub fn parse_dotted_ident_rest( } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(NameResult { - name: acc.clone(), + name: acc, span: span.clone(), tokens: __eu.clone(), err: None, @@ -2172,8 +2179,8 @@ pub fn parse_module(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let r = parse_import_names(__ec, ctx.clone()); + let r = parse_import_names(__ec.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ImportResult { import: err_import.clone(), @@ -2340,16 +2347,21 @@ pub fn parse_import(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); { - let __tco_0 = v1_rt::rc_list_push(acc, name_node.clone()); + let __tco_0 = v1_rt::rc_list_push(acc, name_node); acc = __tco_0; continue; } @@ -2455,7 +2467,7 @@ pub fn find_item_form(forms: Rc>>, keyword: String) -> Option None, - _ => Some(matches.first().cloned().clone().unwrap()), + _ => Some(matches.clone().first().cloned().clone().unwrap()), } } } @@ -2466,10 +2478,10 @@ pub fn parse_item(tokens: Rc, ctx: Rc) -> Rc parse_item_by_form(tokens.clone(), ctx, f), + Some(f) => parse_item_by_form(tokens.clone(), ctx, f.clone()), None => Rc::new(ItemResult { item: Rc::new(Node { name: "".to_string(), @@ -2493,7 +2505,7 @@ pub fn parse_item(tokens: Rc, ctx: Rc) -> Rc { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_fn_body_from_prefix(prefix, start_span) + parse_fn_body_from_prefix(prefix.clone(), start_span.clone()) } BodyKind::BlockBody => { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_block_body_from_prefix(prefix, start_span) + parse_block_body_from_prefix(prefix.clone(), start_span.clone()) } BodyKind::ServiceBody => { - parse_service_after_kw(tokens.clone(), ctx.clone(), start_span) + parse_service_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) } BodyKind::ResourceBody => { - parse_resource_after_kw(tokens.clone(), ctx.clone(), start_span) + parse_resource_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) + } + BodyKind::ValueBody => { + parse_data_after_kw(tokens.clone(), ctx.clone(), start_span.clone()) } - BodyKind::ValueBody => parse_data_after_kw(tokens.clone(), ctx.clone(), start_span), BodyKind::NoBody => { let prefix = parse_item_prefix(tokens.clone(), ctx.clone(), form.clone()); if has_err(prefix.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: prefix.tokens.clone(), ctx: prefix.ctx.clone(), err: prefix.err.clone(), }); } - parse_no_body_from_prefix(prefix, start_span) + parse_no_body_from_prefix(prefix.clone(), start_span.clone()) } } } @@ -2760,7 +2774,7 @@ pub fn field_to_child_node( "from_key".to_string(), make_expr_node( Rc::new(ExprData::ExprLiteral { - value: Rc::new(LiteralValue::LitStr { value: key }), + value: Rc::new(LiteralValue::LitStr { value: key.clone() }), }), Rc::new(vec![]), None, @@ -2812,7 +2826,7 @@ pub fn variant_to_child_node( span: variant.span.clone(), ident_span: variant.ident_span.clone(), children: children, - connective: if ((fields.len() as i64) > 0) { + connective: if ((fields.clone().len() as i64) > 0) { Connective::Conj } else { Connective::NoConnective @@ -3005,7 +3019,7 @@ pub fn parse_type_def(tokens: Rc, ctx: Rc) -> Rc { - let r = parse_field_list(skip_newlines(__ec), ctx.clone()); + let r = parse_field_list(skip_newlines(__ec.clone()), ctx.clone()); let named_dummy = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -3092,7 +3106,7 @@ pub fn parse_type_after_kw( let r2 = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBrace)); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy, + item: named_dummy.clone(), tokens: r2.tokens.clone(), ctx: ctx.clone(), err: r2.err.clone(), @@ -3123,12 +3137,12 @@ pub fn parse_type_after_kw( Rc::new(vec![]) }; let item = Rc::new(Node { - name: name, + name: name.clone(), span: start_span.clone(), - ident_span: Some(name_span), + ident_span: Some(name_span.clone()), children: type_children, connective: Connective::Conj, - params: type_params, + params: type_params.clone(), inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3152,14 +3166,14 @@ pub fn parse_type_after_kw( EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectEq))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = skip_newlines(__ec); + let tokens = skip_newlines(__ec.clone()); parse_type_body_after_eq( tokens.clone(), ctx.clone(), - name, - name_span, + name.clone(), + name_span.clone(), start_span.clone(), - type_params, + type_params.clone(), ) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -3169,9 +3183,9 @@ pub fn parse_type_after_kw( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), connective: Connective::NoConnective, - params: type_params, + params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: leaf_type_node(name, name_span), + node: leaf_type_node(name.clone(), name_span.clone()), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3187,7 +3201,7 @@ pub fn parse_type_after_kw( }); Rc::new(ItemResult { item: item, - tokens: __eu, + tokens: __eu.clone(), ctx: ctx.clone(), err: None, }) @@ -3232,10 +3246,10 @@ pub fn parse_type_body_from_prefix( token_stream_first(raw_tokens.clone()), "sole_constructor".to_string(), ); - let tokens = type_body_tokens_after_modifiers(raw_tokens); + let tokens = type_body_tokens_after_modifiers(raw_tokens.clone()); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBrace))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_field_list(skip_newlines(__ec), ctx.clone()); + let r = parse_field_list(skip_newlines(__ec.clone()), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ItemResult { item: named_dummy.clone(), @@ -3246,10 +3260,10 @@ pub fn parse_type_body_from_prefix( } let tokens = skip_newlines(r.tokens.clone()); let ctx = r.ctx.clone(); - let r2 = expect(tokens, Rc::new(ExpectedToken::ExpectRBrace)); + let r2 = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBrace)); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy, + item: named_dummy.clone(), tokens: r2.tokens.clone(), ctx: ctx.clone(), err: r2.err.clone(), @@ -3280,12 +3294,12 @@ pub fn parse_type_body_from_prefix( Rc::new(vec![]) }; let item = Rc::new(Node { - name: name, + name: name.clone(), span: start_span.clone(), - ident_span: Some(name_span), + ident_span: Some(name_span.clone()), children: type_children, connective: Connective::Conj, - params: type_params, + params: type_params.clone(), inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3302,21 +3316,21 @@ pub fn parse_type_body_from_prefix( Rc::new(ItemResult { item: item, tokens: skip_newlines(r2.tokens.clone()), - ctx: ctx, + ctx: ctx.clone(), err: None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectEq))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = skip_newlines(__ec); + let tokens = skip_newlines(__ec.clone()); parse_type_body_after_eq( - tokens, - ctx, - name, - name_span, + tokens.clone(), + ctx.clone(), + name.clone(), + name_span.clone(), start_span.clone(), - type_params, + type_params.clone(), ) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -3326,9 +3340,9 @@ pub fn parse_type_body_from_prefix( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), connective: Connective::NoConnective, - params: type_params, + params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: leaf_type_node(name, name_span), + node: leaf_type_node(name.clone(), name_span.clone()), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3344,8 +3358,8 @@ pub fn parse_type_body_from_prefix( }); Rc::new(ItemResult { item: item, - tokens: __eu, - ctx: ctx, + tokens: __eu.clone(), + ctx: ctx.clone(), err: None, }) } @@ -3386,7 +3400,7 @@ pub fn parse_type_body_after_eq( }); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectPipe))).clone() { EatResult::EatConsumed { tokens: __lead, .. } => { - let tokens = skip_newlines(__lead); + let tokens = skip_newlines(__lead.clone()); let rid = expect_ident(tokens.clone()); if has_err(rid.err.clone()) { return Rc::new(ItemResult { @@ -3416,7 +3430,7 @@ pub fn parse_type_body_after_eq( ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: rest.tokens.clone(), ctx: rest.ctx.clone(), err: rest.err.clone(), @@ -3498,7 +3512,7 @@ pub fn parse_type_body_after_eq( ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: rest.tokens.clone(), ctx: rest.ctx.clone(), err: rest.err.clone(), @@ -3566,7 +3580,7 @@ pub fn parse_type_body_after_eq( ); if has_err(wr.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: wr.tokens.clone(), ctx: wr.ctx.clone(), err: wr.err.clone(), @@ -3622,7 +3636,7 @@ pub fn parse_type_body_after_eq( ); if has_err(wr.err.clone()) { return Rc::new(ItemResult { - item: dummy, + item: dummy.clone(), tokens: wr.tokens.clone(), ctx: wr.ctx.clone(), err: wr.err.clone(), @@ -3672,7 +3686,7 @@ pub fn try_where_clause( if tok_is_keyword(token_stream_first(tokens.clone()), "where".to_string()) { match (*advance(tokens.clone())).clone() { AdvanceResult::AdvanceOk { tokens: rest, .. } => { - let r = parse_predicates(rest, ctx); + let r = parse_predicates(rest.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(TypeResult { type_expr: base_te.clone(), @@ -3755,7 +3769,7 @@ pub fn parse_predicates_acc( mut acc: Rc>>, ) -> Rc { loop { - let r = parse_single_predicate(tokens.clone(), ctx.clone()); + let r = parse_single_predicate(tokens, ctx); if has_err(r.err.clone()) { return Rc::new(PredsResult { predicates: Rc::new(vec![]), @@ -3814,7 +3828,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let tokens = r.tokens.clone(); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLParen))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let tokens = __ec; + let tokens = __ec.clone(); match pred_name.clone().as_str() { "pattern" => { let r2 = parse_string_literal_value(tokens.clone()); @@ -3829,7 +3843,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3849,7 +3863,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3869,7 +3883,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3889,7 +3903,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3909,7 +3923,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3929,7 +3943,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3949,7 +3963,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -3969,7 +3983,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -3989,7 +4003,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), err: r3.err.clone(), @@ -4009,7 +4023,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -4029,7 +4043,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectRParen)); if has_err(r3.err.clone()) { return Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -4083,7 +4097,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), @@ -4091,12 +4105,15 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }) } _ => Rc::new(PredResult { - predicate: dummy_pred, + predicate: dummy_pred.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: Some(parse_error( v1_rt::concat( - v1_rt::concat("unknown where predicate `".to_string(), pred_name), + v1_rt::concat( + "unknown where predicate `".to_string(), + pred_name.clone(), + ), "`".to_string(), ), token_span(token_stream_first(tokens.clone())), @@ -4117,7 +4134,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: tokens.clone(), ctx: ctx.clone(), @@ -4125,7 +4142,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), _ => Rc::new(PredResult { predicate: make_field_init_node( - pred_name, + pred_name.clone(), make_expr_node( Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitBool { value: true }), @@ -4135,7 +4152,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> zero_span.clone(), ), zero_span.clone(), - zero_span, + zero_span.clone(), ), tokens: tokens.clone(), ctx: ctx.clone(), @@ -4160,7 +4177,7 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R } match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r2 = parse_single_named_int(skip_newlines(__ec), r.ctx.clone()); + let r2 = parse_single_named_int(skip_newlines(__ec.clone()), r.ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(RangeArgsResult { min_val: None, @@ -4256,7 +4273,7 @@ pub fn parse_single_named_int( }); } Rc::new(NamedIntResult { - arg_name: name, + arg_name: name.clone(), arg_value: r3.value.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), @@ -4292,9 +4309,9 @@ pub fn parse_positional_variant_type_fields( match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { token: comma_tok, tokens: __ec, .. } => Rc::new(FieldsResult { fields: Rc::new(vec![]), - tokens: __ec, + tokens: __ec.clone(), ctx: r.ctx.clone(), - err: Some(parse_error("positional variant payload accepts a single type only (comma-separated fields not supported yet)".to_string(), token_span(Some(comma_tok)))), + err: Some(parse_error("positional variant payload accepts a single type only (comma-separated fields not supported yet)".to_string(), token_span(Some(comma_tok.clone())))), }), EatResult::EatUnchanged { tokens: __eu, .. } => Rc::new(FieldsResult { fields: Rc::new(vec![field]), @@ -4316,7 +4333,7 @@ pub fn parse_variant_fields( let start_span = token_span(token_stream_first(tokens.clone())); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBrace))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_field_list(skip_newlines(__ec), ctx); + let r = parse_field_list(skip_newlines(__ec.clone()), ctx); if has_err(r.err.clone()) { return Rc::new(VariantResult { variant: make_variant_node( @@ -4348,7 +4365,7 @@ pub fn parse_variant_fields( let v = make_variant_node( vname.clone(), r.fields.clone(), - start_span, + start_span.clone(), vname_span.clone(), ); Rc::new(VariantResult { @@ -4361,7 +4378,7 @@ pub fn parse_variant_fields( EatResult::EatUnchanged { tokens: __eu, .. } => { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLParen))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_positional_variant_type_fields(__ec, ctx); + let r = parse_positional_variant_type_fields(__ec.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(VariantResult { variant: make_variant_node( @@ -4392,7 +4409,7 @@ pub fn parse_variant_fields( let v = make_variant_node( vname.clone(), r.fields.clone(), - start_span, + start_span.clone(), vname_span.clone(), ); Rc::new(VariantResult { @@ -4471,7 +4488,7 @@ pub fn parse_more_variants_acc( } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(VariantsResult { - variants: acc.clone(), + variants: acc, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -4516,7 +4533,7 @@ pub fn parse_type_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(TypeResult { type_expr: leaf_type_node("".to_string(), span.clone()), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error("expected type expression".to_string(), span)), + err: Some(parse_error( + "expected type expression".to_string(), + span.clone(), + )), }), } } @@ -4640,7 +4663,7 @@ pub fn parse_callable_type_expr( let ret = parse_type_expr(r3.tokens.clone(), params_result.ctx.clone()); if has_err(ret.err.clone()) { return Rc::new(TypeResult { - type_expr: dummy_te, + type_expr: dummy_te.clone(), tokens: ret.tokens.clone(), ctx: ret.ctx.clone(), err: ret.err.clone(), @@ -4678,7 +4701,7 @@ pub fn parse_callable_param_types( mut acc: Rc>>, ) -> Rc { loop { - let r = parse_type_expr(tokens.clone(), ctx.clone()); + let r = parse_type_expr(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(ParamsResult { params: Rc::new(vec![]), @@ -4694,7 +4717,7 @@ pub fn parse_callable_param_types( (*r.type_expr).clone().span.clone(), (*r.type_expr).clone().span.clone(), ); - acc = v1_rt::rc_list_push(acc.clone(), param.clone()); + acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -4735,9 +4758,9 @@ pub fn finish_type_expr_from_name( let dummy_te = leaf_type_node(type_name.clone(), start_span.clone()); match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLt))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_angle_arg(__ec, ctx); + let r = parse_type_angle_arg(__ec.clone(), ctx); if has_err(r.err.clone()) { - return r; + return r.clone(); } let first_arg = (*r.type_expr).clone(); let type_args = @@ -4753,7 +4776,7 @@ pub fn finish_type_expr_from_name( let r3 = expect(type_args.tokens.clone(), Rc::new(ExpectedToken::ExpectGt)); if has_err(r3.err.clone()) { return Rc::new(TypeResult { - type_expr: dummy_te, + type_expr: dummy_te.clone(), tokens: r3.tokens.clone(), ctx: type_args.ctx.clone(), err: r3.err.clone(), @@ -4807,7 +4830,7 @@ pub fn parse_optional_type_params( ) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLt))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let params_result = collect_type_param_names(__ec, ctx, Rc::new(vec![])); + let params_result = collect_type_param_names(__ec.clone(), ctx, Rc::new(vec![])); let r = expect( params_result.tokens.clone(), Rc::new(ExpectedToken::ExpectGt), @@ -4842,28 +4865,28 @@ pub fn collect_type_param_names( span.clone(), span.clone(), ); - let next_params = v1_rt::rc_list_push(params.clone(), param.clone()); + let next_params = v1_rt::rc_list_push(params, param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); - let __tco_1 = next_params.clone(); + let __tco_1 = next_params; tokens = __tco_0; params = __tco_1; continue; } EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(TypeParamsResult { - params: next_params.clone(), + params: next_params, tokens: r.tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, }); } } } else { break Rc::new(TypeParamsResult { - params: params.clone(), + params: params, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, }); } } @@ -4885,7 +4908,7 @@ pub fn collect_type_args( loop { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_angle_arg(__ec.clone(), ctx.clone()); + let r = parse_type_angle_arg(__ec.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(TypeArgsResult { args: args.clone(), @@ -4908,7 +4931,7 @@ pub fn collect_type_args( break Rc::new(TypeArgsResult { args: args.clone(), tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } @@ -4946,7 +4969,7 @@ pub fn maybe_optional( }); Rc::new(TypeResult { type_expr: ote, - tokens: __ec, + tokens: __ec.clone(), ctx: ctx, err: None, }) @@ -4974,14 +4997,14 @@ pub fn parse_field_list_acc( let tok = token_stream_first(tokens.clone()); if ((tok_is_rbrace(tok.clone()) || tok_is_rparen(tok.clone())) || tok_is_eof(tok.clone())) { break Rc::new(FieldsResult { - fields: acc.clone(), + fields: acc, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } else { if (tok_is_ident(tok.clone()) || tok_is_keyword_name(tok.clone())) { - let r = parse_field(tokens.clone(), ctx.clone()); + let r = parse_field(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(FieldsResult { fields: Rc::new(vec![]), @@ -4992,7 +5015,7 @@ pub fn parse_field_list_acc( } tokens = r.tokens.clone(); let e = eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); @@ -5005,9 +5028,9 @@ pub fn parse_field_list_acc( } } else { break Rc::new(FieldsResult { - fields: acc.clone(), + fields: acc, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } @@ -5080,10 +5103,10 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc { - let r4 = parse_expr(__ec, ctx.clone()); + let r4 = parse_expr(__ec.clone(), ctx.clone()); if has_err(r4.err.clone()) { return Rc::new(FieldResult { - field: dummy_field, + field: dummy_field.clone(), tokens: r4.tokens.clone(), ctx: r4.ctx.clone(), err: r4.err.clone(), @@ -5095,7 +5118,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc>>, ) -> Rc { loop { - let r = parse_uses_entry(tokens.clone(), ctx.clone()); + let r = parse_uses_entry(tokens, ctx); if has_err(r.err.clone()) { return Rc::new(UsesResult { uses: Rc::new(vec![]), @@ -5894,7 +5917,7 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc { - let ar = parse_resource_config_args(__ec, r3.ctx.clone()); + let ar = parse_resource_config_args(__ec.clone(), r3.ctx.clone()); if has_err(ar.err.clone()) { return Rc::new(ResUseResult { resource_use: dummy.clone(), @@ -5906,7 +5929,7 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = skip_newlines(__ec.clone()); @@ -6046,7 +6064,7 @@ pub fn parse_resource_config_acc( pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectArrow))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_type_expr(__ec, ctx); + let r = parse_type_expr(__ec.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(OptRetResult { inferred: None, @@ -6110,7 +6128,7 @@ pub fn parse_service_def(tokens: Rc, ctx: Rc) -> Rc Rc::new(vec![]), }; let item = Rc::new(Node { - name: name, + name: name.clone(), span: start_span.clone(), - ident_span: Some(svc_name_span), + ident_span: Some(svc_name_span.clone()), children: r.operations.clone(), params: Rc::new(vec![]), inferred: None, @@ -6296,7 +6314,7 @@ pub fn parse_service_entries( None => None, }; let span = token_span(tok.clone()); - match sh.clone() { + match sh { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); if (id.clone() == "config".to_string()) { @@ -6384,7 +6402,7 @@ pub fn parse_service_entries( err: Some(parse_error( "expected config, transport, or operation in service block" .to_string(), - span.clone(), + span, )), }); } @@ -6392,7 +6410,7 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.clone() == "operation".to_string()) { + if (kw_text == "operation".to_string()) { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6423,7 +6441,7 @@ pub fn parse_service_entries( err: Some(parse_error( "expected config, transport, or operation in service block" .to_string(), - span.clone(), + span, )), }); } @@ -6437,7 +6455,7 @@ pub fn parse_service_entries( ctx: ctx.clone(), err: Some(parse_error( "expected config, transport, or operation in service block".to_string(), - span.clone(), + span, )), }); } @@ -6469,7 +6487,7 @@ pub fn parse_config_fields( || tok_is_eof(token_stream_first(tokens.clone()))) { let cfg = Rc::new(ServiceConfig { - endpoint: match endpoint.clone() { + endpoint: match endpoint { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -6482,14 +6500,14 @@ pub fn parse_config_fields( make_span(0, 0), ), }, - auth: auth.clone(), - auth_input: auth_input.clone(), - auth_source: auth_source.clone(), - rate_limit: rate_limit.clone(), - retry: retry.clone(), + auth: auth, + auth_input: auth_input, + auth_source: auth_source, + rate_limit: rate_limit, + retry: retry, }); break Rc::new(ConfigResult { - config: cfg.clone(), + config: cfg, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6547,7 +6565,7 @@ pub fn parse_config_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }; - match fname.clone().as_str() { + match fname.as_str() { "endpoint" => { let __tco_0 = Some((*r3.expr).clone()); endpoint = __tco_0; @@ -6598,7 +6616,7 @@ pub fn parse_transport_binding( Some(t) => t.text.clone(), None => "".to_string(), }; - let sh = match tok { + let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), None => None, }; @@ -6634,7 +6652,7 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy, + transport: dummy.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -6680,7 +6698,7 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy, + transport: dummy.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -6694,7 +6712,7 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text == "file".to_string()) { + if (tok_text.clone() == "file".to_string()) { { let r = expect( token_stream_advance(tokens.clone(), 1), @@ -6726,7 +6744,7 @@ pub fn parse_transport_binding( ); if has_err(r3.err.clone()) { return Rc::new(TransportResult { - transport: dummy, + transport: dummy.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -6741,7 +6759,7 @@ pub fn parse_transport_binding( } } else { Rc::new(TransportResult { - transport: dummy, + transport: dummy.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6751,7 +6769,7 @@ pub fn parse_transport_binding( } } _ => Rc::new(TransportResult { - transport: dummy, + transport: dummy.clone(), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -6795,7 +6813,7 @@ pub fn parse_rest_fields( if (tok_is_rbrace(token_stream_first(tokens.clone())) || tok_is_eof(token_stream_first(tokens.clone()))) { - let bu = match base_url.clone() { + let bu = match base_url { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -6810,14 +6828,14 @@ pub fn parse_rest_fields( }; break Rc::new(TransportResult { transport: rest_transport_node( - bu.clone(), + bu, Rc::new(vec![]), - headers.clone(), - method.clone(), - path_template.clone(), - query.clone(), - request_body.clone(), - response_format.clone(), + headers, + method, + path_template, + query, + request_body, + response_format, span.clone(), ), tokens: tokens.clone(), @@ -6915,7 +6933,7 @@ pub fn parse_rest_fields( }), }; { - let __tco_0 = h.clone(); + let __tco_0 = h; headers = __tco_0; continue; } @@ -6955,12 +6973,7 @@ pub fn parse_shell_fields( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(TransportResult { - transport: shell_transport_node( - argv.clone(), - Rc::new(vec![]), - stdin.clone(), - span.clone(), - ), + transport: shell_transport_node(argv, Rc::new(vec![]), stdin, span.clone()), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -7018,7 +7031,7 @@ pub fn parse_shell_fields( }); } let e = eat(r5.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e.clone()).clone() { + tokens = match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r5.tokens.clone(), }; @@ -7041,7 +7054,7 @@ pub fn parse_shell_fields( }); } let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e.clone()).clone() { + tokens = match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; @@ -7063,7 +7076,7 @@ pub fn parse_shell_fields( }); } let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = match (*e.clone()).clone() { + tokens = match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; @@ -7097,7 +7110,7 @@ pub fn parse_file_fields( if (tok_is_rbrace(token_stream_first(tokens.clone())) || tok_is_eof(token_stream_first(tokens.clone()))) { - let bp = match base_path.clone() { + let bp = match base_path { Some(e) => e.clone(), None => make_expr_node( Rc::new(ExprData::ExprLiteral { @@ -7111,7 +7124,7 @@ pub fn parse_file_fields( ), }; break Rc::new(TransportResult { - transport: file_transport_node(bp.clone(), span.clone()), + transport: file_transport_node(bp, span.clone()), tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -7202,7 +7215,7 @@ pub fn parse_operation_def(tokens: Rc, ctx: Rc) -> Rc let r = expect_ident(r.tokens.clone()); if has_err(r.err.clone()) { return Rc::new(OpResult { - operation: dummy_op, + operation: dummy_op.clone(), tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -7212,9 +7225,21 @@ pub fn parse_operation_def(tokens: Rc, ctx: Rc) -> Rc let name_span = r.span.clone(); let tokens = skip_newlines(r.tokens.clone()); if tok_is_lbrace(token_stream_first(tokens.clone())) { - parse_operation_v1_body(tokens.clone(), ctx.clone(), name, name_span, start_span) + parse_operation_v1_body( + tokens.clone(), + ctx.clone(), + name, + name_span, + start_span.clone(), + ) } else { - parse_operation_v2_inline(tokens.clone(), ctx.clone(), name, name_span, start_span) + parse_operation_v2_inline( + tokens.clone(), + ctx.clone(), + name, + name_span, + start_span.clone(), + ) } } } @@ -7290,7 +7315,7 @@ pub fn parse_operation_v2_inline( let ctx = ret.ctx.clone(); let outputs = match ret.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - node_inferred_to_outputs(rt, ctx.source_indices.clone()) + node_inferred_to_outputs(rt.clone(), ctx.source_indices.clone()) } _ => Rc::new(vec![]), }; @@ -7309,7 +7334,7 @@ pub fn parse_operation_v2_inline( let mock_r = parse_optional_mock_response_block(tokens.clone(), ctx.clone()); if has_err(mock_r.err.clone()) { return Rc::new(OpResult { - operation: dummy_op, + operation: dummy_op.clone(), tokens: mock_r.tokens.clone(), ctx: mock_r.ctx.clone(), err: mock_r.err.clone(), @@ -7395,7 +7420,7 @@ pub fn parse_operation_v1_body( ); if has_err(r3.err.clone()) { return Rc::new(OpResult { - operation: dummy_op, + operation: dummy_op.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: r3.err.clone(), @@ -7457,7 +7482,7 @@ pub fn parse_op_body_entries( Some(t) => Some(t.shape.clone()), None => None, }; - match sh.clone() { + match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); if (kw_text.clone() == "input".to_string()) { @@ -7585,34 +7610,30 @@ pub fn parse_op_body_entries( } } else { if (kw_text.clone() == "idempotent".to_string()) { - let prop = modifier_to_prop("idempotent".to_string(), span.clone()); + let prop = modifier_to_prop("idempotent".to_string(), span); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = v1_rt::rc_list_push(modifier_props, prop.clone()); + let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); tokens = __tco_0; modifier_props = __tco_1; continue; } } else { if (kw_text.clone() == "readonly".to_string()) { - let prop = - modifier_to_prop("readonly".to_string(), span.clone()); + let prop = modifier_to_prop("readonly".to_string(), span); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = - v1_rt::rc_list_push(modifier_props, prop.clone()); + let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); tokens = __tco_0; modifier_props = __tco_1; continue; } } else { if (kw_text.clone() == "hermetic".to_string()) { - let prop = - modifier_to_prop("hermetic".to_string(), span.clone()); + let prop = modifier_to_prop("hermetic".to_string(), span); { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = - v1_rt::rc_list_push(modifier_props, prop.clone()); + let __tco_1 = v1_rt::rc_list_push(modifier_props, prop); tokens = __tco_0; modifier_props = __tco_1; continue; @@ -7846,7 +7867,7 @@ pub fn parse_op_body_entries( "unexpected '{}' in operation body", id.clone() ), - span.clone(), + span, )), }); } @@ -7868,7 +7889,7 @@ pub fn parse_op_body_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected token in operation body".to_string(), - span.clone(), + span, )), }); } @@ -7921,9 +7942,9 @@ pub fn status_expr_to_str( source_indices: Rc>>, ) -> String { match (*expr.expr_data.clone()).clone() { - ExprData::ExprLiteral { value: v, .. } => match (*v).clone() { - LiteralValue::LitInt { value: n, .. } => int_to_string(n), - LiteralValue::LitStr { value: s, .. } => s, + ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { + LiteralValue::LitInt { value: n, .. } => int_to_string(n.clone()), + LiteralValue::LitStr { value: s, .. } => s.clone(), _ => "_".to_string(), }, ExprData::ExprVar { @@ -7967,7 +7988,6 @@ pub fn int_to_string_acc(mut value: i64, mut acc: Rc>) -> Rc>) -> Rc>) -> Rc) -> Rc { match n.children.clone().first().cloned() { - Some(ch) => ch, - None => n, + Some(ch) => ch.clone(), + None => n.clone(), } } pub fn last_child_or_self(n: Rc) -> Rc { match n.children.clone().last().cloned() { - Some(ch) => ch, - None => n, + Some(ch) => ch.clone(), + None => n.clone(), } } @@ -8025,7 +8045,7 @@ pub fn node_to_name_str( } else { n.clone() }; - let opt_prefix = if is_optional { + let opt_prefix = if is_optional.clone() { "Optional_".to_string() } else { "".to_string() @@ -8036,27 +8056,31 @@ pub fn node_to_name_str( if is_keyed_container { match effective_n.children.clone().last().cloned() { Some(ch) => v1_rt::concat( - v1_rt::concat(v1_rt::concat(opt_prefix, effective_name), "_".to_string()), - node_to_name_str(ch, source_indices.clone()), + v1_rt::concat( + v1_rt::concat(opt_prefix, effective_name.clone()), + "_".to_string(), + ), + node_to_name_str(ch.clone(), source_indices.clone()), ), - None => v1_rt::concat(opt_prefix, effective_name), + None => v1_rt::concat(opt_prefix, effective_name.clone()), } } else { if (effective_n.type_annotation.clone() != None) { match effective_n.children.clone().first().cloned() { - Some(ch) => { - v1_rt::concat(opt_prefix, node_to_name_str(ch, source_indices.clone())) - } - None => v1_rt::concat(opt_prefix, effective_name), + Some(ch) => v1_rt::concat( + opt_prefix, + node_to_name_str(ch.clone(), source_indices.clone()), + ), + None => v1_rt::concat(opt_prefix, effective_name.clone()), } } else { if is_container_type(effective_name.clone()) { match effective_n.children.clone().first().cloned() { Some(ch) => v1_rt::concat( v1_rt::concat(opt_prefix, "List_".to_string()), - node_to_name_str(ch, source_indices.clone()), + node_to_name_str(ch.clone(), source_indices.clone()), ), - None => v1_rt::concat(opt_prefix, effective_name), + None => v1_rt::concat(opt_prefix, effective_name.clone()), } } else { if (effective_n.ident_span.clone() == None) { @@ -8069,12 +8093,12 @@ pub fn node_to_name_str( if is_disj { v1_rt::concat(opt_prefix, "Union".to_string()) } else { - v1_rt::concat(opt_prefix, effective_name) + v1_rt::concat(opt_prefix, effective_name.clone()) } } } } else { - v1_rt::concat(opt_prefix, effective_name) + v1_rt::concat(opt_prefix, effective_name.clone()) } } } @@ -8097,7 +8121,7 @@ pub fn parse_exit_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(ExitEntriesResult { - entries: acc.clone(), + entries: acc, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8132,21 +8156,21 @@ pub fn parse_exit_entries_acc( }); } let desc_tok = token_stream_first(r3.tokens.clone()); - let desc_sh = match desc_tok.clone() { + let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), None => None, }; - let desc_tokens = match desc_sh.clone() { + let desc_tokens = match desc_sh { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(Rc::new(code.clone()), ctx.source_indices.clone()); + let code_str = status_expr_to_str(Rc::new(code), ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); - let prop_name = v1_rt::concat("exit_".to_string(), code_str.clone()); + let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( - prop_name.clone(), + prop_name, make_named_expr_node( - type_name.clone(), + type_name, Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, @@ -8157,13 +8181,13 @@ pub fn parse_exit_entries_acc( no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => desc_tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, entry); ctx = __tco_0; acc = __tco_1; continue; @@ -8211,9 +8235,9 @@ pub fn parse_operation_modifiers_acc( } } else { break Rc::new(ModsResult { - modifiers: acc.clone(), + modifiers: acc, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } @@ -8234,7 +8258,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R Some(TokenShape::ShLitInt) => { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v, + Some(v) => v.clone(), None => { return Rc::new(ExprResult { expr: make_expr_error_node( @@ -8269,7 +8293,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 2), ctx: ctx.clone(), @@ -8283,7 +8307,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8298,7 +8322,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8315,7 +8339,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8331,7 +8355,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -8424,7 +8448,7 @@ pub fn parse_response_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(RespEntriesResult { - entries: acc.clone(), + entries: acc, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8458,13 +8482,13 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(Rc::new(status.clone()), ctx.source_indices.clone()); + let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); - let prop_name = v1_rt::concat("response_".to_string(), status_str.clone()); + let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( - prop_name.clone(), + prop_name, make_named_expr_node( - type_name.clone(), + type_name, Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, @@ -8475,13 +8499,13 @@ pub fn parse_response_entries_acc( no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, entry); ctx = __tco_0; acc = __tco_1; continue; @@ -8573,7 +8597,7 @@ pub fn parse_mock_response_entries_acc( || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(MockEntriesResult { - entries: acc.clone(), + entries: acc, tokens: tokens.clone(), ctx: ctx.clone(), err: None, @@ -8609,30 +8633,25 @@ pub fn parse_mock_response_entries_acc( } let body = (*r3.expr).clone(); let desc_tok = token_stream_first(r3.tokens.clone()); - let desc_sh = match desc_tok.clone() { + let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), None => None, }; - let desc_tokens = match desc_sh.clone() { + let desc_tokens = match desc_sh { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(Rc::new(status.clone()), ctx.source_indices.clone()); - let prop_name = v1_rt::concat("mock_".to_string(), status_str.clone()); - let entry = make_field_init_node( - prop_name.clone(), - Rc::new(body.clone()), - make_span(0, 0), - make_span(0, 0), - ); + let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let prop_name = v1_rt::concat("mock_".to_string(), status_str); + let entry = make_field_init_node(prop_name, Rc::new(body), make_span(0, 0), make_span(0, 0)); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => desc_tokens.clone(), }); { let __tco_0 = r3.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, entry.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, entry); ctx = __tco_0; acc = __tco_1; continue; @@ -8678,7 +8697,7 @@ pub fn parse_resource_def(tokens: Rc, ctx: Rc) -> Rc< err: r.err.clone(), }); } - parse_resource_after_kw(r.tokens.clone(), ctx.clone(), start_span) + parse_resource_after_kw(r.tokens.clone(), ctx.clone(), start_span.clone()) } } @@ -8768,16 +8787,16 @@ pub fn parse_resource_after_kw( ); if has_err(r2.err.clone()) { return Rc::new(ItemResult { - item: named_dummy, + item: named_dummy.clone(), tokens: r2.tokens.clone(), ctx: r.ctx.clone(), err: r2.err.clone(), }); } let item = Rc::new(Node { - name: name, + name: name.clone(), span: start_span.clone(), - ident_span: Some(name_span), + ident_span: Some(name_span.clone()), children: r.capabilities.clone(), params: Rc::new(vec![]), inferred: None, @@ -8826,7 +8845,7 @@ pub fn parse_resource_entries( Some(t) => Some(t.shape.clone()), None => None, }; - match sh.clone() { + match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); if (kw_text.clone() == "capability".to_string()) { @@ -8922,7 +8941,7 @@ pub fn parse_resource_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected keyword in resource block".to_string(), - span.clone(), + span, )), }); } @@ -8963,7 +8982,7 @@ pub fn parse_resource_entries( }); } let fi = make_field_init_node( - fname.clone(), + fname, r3.expr.clone(), make_span(0, 0), r.span.clone(), @@ -8971,7 +8990,7 @@ pub fn parse_resource_entries( { let __tco_0 = skip_newlines(r3.tokens.clone()); let __tco_1 = r3.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(properties, fi.clone()); + let __tco_2 = v1_rt::rc_list_push(properties, fi); tokens = __tco_0; ctx = __tco_1; properties = __tco_2; @@ -8985,7 +9004,7 @@ pub fn parse_resource_entries( ctx: ctx.clone(), err: Some(parse_error( "unexpected token in resource block".to_string(), - span.clone(), + span, )), }); } @@ -8999,7 +9018,7 @@ pub fn parse_resource_entries( err: Some(parse_error( "expected capability, acquire, release, or property in resource block" .to_string(), - span.clone(), + span, )), }); } @@ -9019,7 +9038,7 @@ pub fn skip_until_rbrace(tokens: Rc) -> Rc { }) } else { { - let sh = match tok { + let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), None => None, }; @@ -9105,7 +9124,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - node_inferred_to_outputs(rt, ret.ctx.clone().source_indices.clone()) - } + Some(InferredNode::Resolved { node: rt, .. }) => node_inferred_to_outputs( + rt.clone(), + ret.ctx.clone().source_indices.clone(), + ), _ => Rc::new(vec![]), }; let cap = make_capability_node( @@ -9180,7 +9200,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc>>, ) -> Rc { loop { - let r = parse_param(tokens.clone(), ctx.clone()); + let r = parse_param(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(ParamsResult { params: Rc::new(vec![]), @@ -9661,10 +9681,10 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc { - let r4 = parse_expr(__ec, ctx.clone()); + let r4 = parse_expr(__ec.clone(), ctx.clone()); if has_err(r4.err.clone()) { return Rc::new(ParamResult { - param: dummy_param, + param: dummy_param.clone(), tokens: r4.tokens.clone(), ctx: r4.ctx.clone(), err: r4.err.clone(), @@ -9674,7 +9694,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, Rc::new(type_expr), None, start_span, name_span); + let p = make_param_node(name, Rc::new(type_expr), None, start_span.clone(), name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -9725,7 +9745,7 @@ pub fn parse_block(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let kw_text = tok_keyword_text(tok); + let kw_text = tok_keyword_text(tok.clone()); if (kw_text.clone() == "let".to_string()) { parse_let(tokens.clone(), ctx) } else { - if (kw_text == "return".to_string()) { + if (kw_text.clone() == "return".to_string()) { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -9904,7 +9929,7 @@ pub fn parse_constrained_assignment( let r2 = expect(cr.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: r2.tokens.clone(), ctx: cr.ctx.clone(), err: r2.err.clone(), @@ -9912,7 +9937,7 @@ pub fn parse_constrained_assignment( } let r3 = parse_expr(r2.tokens.clone(), cr.ctx.clone()); if has_err(r3.err.clone()) { - return r3; + return r3.clone(); } let node = make_named_expr_node( name, @@ -9943,7 +9968,7 @@ pub fn parse_constrained_assignment( ident: None, }); Rc::new(ExprResult { - expr: node, + expr: node.clone(), tokens: r3.tokens.clone(), ctx: r3.ctx.clone(), err: None, @@ -9985,7 +10010,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc __ec, + EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => { let r2 = expect(cr.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r2.err.clone()) { @@ -10001,18 +10026,18 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc Some((*r3.expr).clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; @@ -10071,12 +10096,12 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> } let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { - return r3; + return r3.clone(); } let cr = try_constraint_annotations(r3.tokens.clone(), r3.ctx.clone()); if has_err(cr.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: cr.err.clone(), @@ -10113,7 +10138,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> ident: None, }); Rc::new(ExprResult { - expr: node, + expr: node.clone(), tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: None, @@ -10121,7 +10146,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> } } else { Rc::new(ExprResult { - expr: node, + expr: node.clone(), tokens: cr.tokens.clone(), ctx: cr.ctx.clone(), err: None, @@ -10142,7 +10167,7 @@ pub fn parse_expr_bp( { let r = parse_prefix(tokens, ctx); if has_err(r.err.clone()) { - return r; + return r.clone(); } let lhs = (*r.expr).clone(); parse_expr_loop(r.tokens.clone(), r.ctx.clone(), Rc::new(lhs), min_bp) @@ -10187,7 +10212,7 @@ pub fn parse_expr_loop( } } else { let bp = infix_bp(tokens.clone()); - match bp.clone() { + match bp { Some(bps) => { if (bps.left.clone() < min_bp.clone()) { break Rc::new(ExprResult { @@ -10221,12 +10246,12 @@ pub fn parse_expr_loop( }), Rc::new(vec![lhs.clone()]), None, - loop_span.clone(), + loop_span, r.span.clone(), ); { let __tco_0 = r.tokens.clone(); - let __tco_1 = new_lhs.clone(); + let __tco_1 = new_lhs; tokens = __tco_0; lhs = __tco_1; continue; @@ -10237,7 +10262,7 @@ pub fn parse_expr_loop( rest.clone(), ctx.clone(), lhs.clone(), - loop_span.clone(), + loop_span, ); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -10275,7 +10300,7 @@ pub fn parse_expr_loop( dag_syntax_spec().operators.clone(), op_tok.text.clone(), ); - match binop_opt.clone() { + match binop_opt { Some(binop) => { let new_lhs = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -10287,12 +10312,12 @@ pub fn parse_expr_loop( r.expr.clone(), ]), None, - loop_span.clone(), + loop_span, ); { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = new_lhs.clone(); + let __tco_2 = new_lhs; tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10310,7 +10335,7 @@ pub fn parse_expr_loop( .to_string(), op_tok.text.clone(), ), - loop_span.clone(), + loop_span, )), }); } @@ -10357,7 +10382,7 @@ pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Optio }); if ((matching.clone().len() as i64) > 0) { { - let op = matching.first().cloned().clone().unwrap(); + let op = matching.clone().first().cloned().clone().unwrap(); Some(BindingPower { left: op.left_bp.clone(), right: op.right_bp.clone(), @@ -10388,7 +10413,14 @@ pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Op __result }); if ((matching.clone().len() as i64) > 0) { - matching.first().cloned().clone().unwrap().binop.clone() + matching + .clone() + .first() + .cloned() + .clone() + .unwrap() + .binop + .clone() } else { None } @@ -10419,7 +10451,7 @@ pub fn parse_pipe_rhs( let r2 = parse_call_args(tokens.clone(), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -10482,7 +10514,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), None => None, }; - let span = token_span(tok); + let span = token_span(tok.clone()); match sh { Some(TokenShape::ShBang) => { let r = parse_expr_bp(token_stream_advance(tokens.clone(), 1), ctx, 12); @@ -10550,7 +10582,7 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc { let spelling = next.clone().unwrap().text.clone(); - let end_span = token_span(next); + let end_span = token_span(next.clone()); let lit_span = make_span(span.start.clone(), end_span.end.clone()); Rc::new(ExprResult { expr: make_expr_node( @@ -10561,13 +10593,13 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc { - let r = parse_expr(token_stream_advance(after_caret, 1), ctx.clone()); + let r = parse_expr(token_stream_advance(after_caret.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { expr: r.expr.clone(), @@ -10601,7 +10633,7 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let found = match next_shape { - Some(shape) => shape_display_name(shape), + let found = match next_shape.clone() { + Some(shape) => shape_display_name(shape.clone()), None => "EOF".to_string(), }; Rc::new(ExprResult { @@ -10624,11 +10656,14 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( - Rc::new(ExprData::ExprLiteral { value: lv }), + Rc::new(ExprData::ExprLiteral { value: lv.clone() }), Rc::new(vec![]), None, - span, + span.clone(), ), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), @@ -10681,14 +10716,14 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc parse_ident_expr(tokens.clone(), ctx.clone(), n), + Some(n) => parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()), None => Rc::new(ExprResult { expr: parse_recovery_expr(span.clone(), format!("expected expression, found keyword '{}'", kw_text.clone())), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text), span)), + err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text.clone()), span.clone())), }), } } @@ -10704,7 +10739,7 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v, + Some(v) => v.clone(), None => { return Rc::new(ExprResult { expr: make_expr_error_node( @@ -10728,11 +10763,11 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc parse_caret_expr(tokens.clone(), ctx.clone()), Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - parse_ident_expr(tokens.clone(), ctx.clone(), n) + parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()) } Some(TokenShape::ShLParen) => parse_paren_expr(tokens.clone(), ctx.clone()), Some(TokenShape::ShLBracket) => parse_list_literal(tokens.clone(), ctx.clone()), Some(TokenShape::ShLBrace) => parse_brace_expr(tokens.clone(), ctx.clone()), _ => { - let tag = match sh { - Some(shape) => shape_display_name(shape), + let tag = match sh.clone() { + Some(shape) => shape_display_name(shape.clone()), None => "EOF".to_string(), }; Rc::new(ExprResult { @@ -10793,8 +10828,8 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc bool { { let ch = v1_rt::char_at(&name, 0); - ((ch.clone() >= "A".to_string()) && (ch <= "Z".to_string())) + ((ch.clone() >= "A".to_string()) && (ch.clone() <= "Z".to_string())) } } @@ -11110,7 +11145,7 @@ pub fn try_postfix( let r = parse_record_literal( tokens.clone(), ctx.clone(), - n, + n.clone(), lhs.span.clone(), ); if has_err(r.err.clone()) { @@ -11187,9 +11222,9 @@ pub fn parse_constraint_annotations( ) -> Rc { match (*eat(tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { - let r = parse_constraint_list(__ec, ctx, Rc::new(vec![])); + let r = parse_constraint_list(__ec.clone(), ctx, Rc::new(vec![])); if has_err(r.err.clone()) { - return r; + return r.clone(); } let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r2.err.clone()) { @@ -11232,7 +11267,7 @@ pub fn parse_constraint_list( } None => false, }; - if !is_constraint_kw.clone() { + if !is_constraint_kw { return Rc::new(ConstraintsResult { constraints: acc.clone(), tokens: tokens.clone(), @@ -11250,13 +11285,8 @@ pub fn parse_constraint_list( err: r.err.clone(), }); } - let fi = make_field_init_node( - kw_name.clone(), - r.expr.clone(), - make_span(0, 0), - make_span(0, 0), - ); - acc = v1_rt::rc_list_push(acc.clone(), fi.clone()); + let fi = make_field_init_node(kw_name, r.expr.clone(), make_span(0, 0), make_span(0, 0)); + acc = v1_rt::rc_list_push(acc.clone(), fi); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); @@ -11384,7 +11414,7 @@ pub fn parse_index_or_slice( let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -11407,7 +11437,7 @@ pub fn parse_index_or_slice( let r = expect(tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: r.tokens.clone(), ctx: ctx.clone(), err: r.err.clone(), @@ -11452,7 +11482,7 @@ pub fn parse_call_args(tokens: Rc, ctx: Rc) -> Rc Rc { loop { tokens = skip_newlines(tokens.clone()); - let r = parse_single_arg(tokens.clone(), ctx.clone()); + let r = parse_single_arg(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(ArgsResult { args: Rc::new(vec![]), @@ -11536,7 +11566,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc= min_bp.clone())) { let span = token_span(token_stream_first(tokens.clone())); - let r = parse_index_or_slice( - tokens.clone(), - ctx.clone(), - lhs.clone(), - span.clone(), - ); + let r = parse_index_or_slice(tokens.clone(), ctx.clone(), lhs.clone(), span); if has_err(r.err.clone()) { return Rc::new(ExprResult { expr: r.expr.clone(), @@ -11791,7 +11818,7 @@ pub fn parse_expr_loop_no_brace( } } else { let bp = infix_bp(tokens.clone()); - match bp.clone() { + match bp { Some(bps) => { if (bps.left.clone() < min_bp.clone()) { break Rc::new(ExprResult { @@ -11825,12 +11852,12 @@ pub fn parse_expr_loop_no_brace( }), Rc::new(vec![lhs.clone()]), None, - loop_span.clone(), + loop_span, r.span.clone(), ); { let __tco_0 = r.tokens.clone(); - let __tco_1 = new_lhs.clone(); + let __tco_1 = new_lhs; tokens = __tco_0; lhs = __tco_1; continue; @@ -11841,7 +11868,7 @@ pub fn parse_expr_loop_no_brace( rest.clone(), ctx.clone(), lhs.clone(), - loop_span.clone(), + loop_span, ); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11879,7 +11906,7 @@ pub fn parse_expr_loop_no_brace( dag_syntax_spec().operators.clone(), op_tok.text.clone(), ); - match binop_opt.clone() { + match binop_opt { Some(binop) => { let new_lhs = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -11891,12 +11918,12 @@ pub fn parse_expr_loop_no_brace( r.expr.clone(), ]), None, - loop_span.clone(), + loop_span, ); { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = new_lhs.clone(); + let __tco_2 = new_lhs; tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -11914,7 +11941,7 @@ pub fn parse_expr_loop_no_brace( .to_string(), op_tok.text.clone(), ), - loop_span.clone(), + loop_span, )), }); } @@ -11965,11 +11992,11 @@ pub fn parse_match_arms_acc( break Rc::new(ArmsResult { arms: acc.clone(), tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } else { - let r = parse_match_arm(tokens.clone(), ctx.clone()); + let r = parse_match_arm(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(ArmsResult { arms: acc.clone(), @@ -11979,7 +12006,7 @@ pub fn parse_match_arms_acc( }); } let e = eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); @@ -12044,13 +12071,13 @@ pub fn parse_match_arm(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> R { let tok = token_stream_first(tokens.clone()); let is_block = (tok_is_keyword(tok.clone(), "let".to_string()) - || tok_is_keyword(tok, "return".to_string())); + || tok_is_keyword(tok.clone(), "return".to_string())); if is_block { { let r = parse_match_arm_stmts(tokens.clone(), ctx, Rc::new(vec![])); @@ -12117,7 +12144,7 @@ pub fn parse_match_arm_stmts( break Rc::new(StmtsResult { stmts: acc.clone(), tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } else { @@ -12125,11 +12152,11 @@ pub fn parse_match_arm_stmts( break Rc::new(StmtsResult { stmts: acc.clone(), tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } else { - let r = parse_stmt(tokens.clone(), ctx.clone()); + let r = parse_stmt(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(StmtsResult { stmts: acc.clone(), @@ -12165,7 +12192,7 @@ pub fn looks_like_arm_start(tokens: Rc) -> bool { if (n.clone() == "_".to_string()) { peek_is_fat_arrow_at(tokens.clone(), 1) } else { - if is_uppercase_start(n) { + if is_uppercase_start(n.clone()) { if peek_is_fat_arrow_at(tokens.clone(), 1) { true } else { @@ -12205,7 +12232,7 @@ pub fn peek_is_expected_at( expected: Rc, ) -> bool { match token_stream_first(token_stream_advance(tokens, offset)) { - Some(t) => token_matches_expected(t, expected), + Some(t) => token_matches_expected(t.clone(), expected), None => false, } } @@ -12310,11 +12337,11 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(PatternResult { - pattern: Rc::new(MatchPattern::LitPattern { value: lv }), + pattern: Rc::new(MatchPattern::LitPattern { value: lv.clone() }), tokens: token_stream_advance(tokens.clone(), 1), ctx: ctx.clone(), err: None, @@ -12343,7 +12370,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc { let n_opt = v1_rt::parse_int(tok.clone().unwrap().text.clone()); let n = match n_opt { - Some(v) => v, + Some(v) => v.clone(), None => { return Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), @@ -12365,7 +12392,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r2.tokens.clone(), }); let fb = make_field_binding_node( field_name.clone(), r2.pattern.clone(), - bind_span.clone(), - field_name_span.clone(), + bind_span, + field_name_span, ); { let __tco_0 = r2.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, fb.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, fb); ctx = __tco_0; acc = __tco_1; continue; @@ -12560,7 +12587,7 @@ pub fn parse_variant_bindings_brace_acc( } EatResult::EatUnchanged { tokens: __eu, .. } => { let e2 = eat(tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e2.clone()).clone() { + tokens = skip_newlines(match (*e2).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => tokens.clone(), }); @@ -12569,11 +12596,11 @@ pub fn parse_variant_bindings_brace_acc( Rc::new(MatchPattern::Bind { name: field_name.clone(), }), - bind_span.clone(), - field_name_span.clone(), + bind_span, + field_name_span, ); { - let __tco_0 = v1_rt::rc_list_push(acc, fb.clone()); + let __tco_0 = v1_rt::rc_list_push(acc, fb); acc = __tco_0; continue; } @@ -12614,7 +12641,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let tokens = skip_newlines(__ec); + let tokens = skip_newlines(__ec.clone()); if tok_is_keyword(token_stream_first(tokens.clone()), "if".to_string()) { { let r2 = parse_if(tokens.clone(), ctx.clone()); @@ -12728,7 +12755,7 @@ pub fn parse_let(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); @@ -12980,7 +13007,7 @@ pub fn parse_field_init(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc t.text.clone(), None => "_".to_string(), }; let r = parse_expr(token_stream_advance(tokens.clone(), 2), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(FieldInitResult { - field: dummy_fi, + field: dummy_fi.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let fi = make_field_init_node(str_name, r.expr.clone(), span, no_span()); + let fi = + make_field_init_node(str_name, r.expr.clone(), span.clone(), no_span()); Rc::new(FieldInitResult { field: fi, tokens: r.tokens.clone(), @@ -13069,14 +13101,18 @@ pub fn parse_field_init(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc< ); if has_err(r2.err.clone()) { return Rc::new(ExprResult { - expr: dummy_expr, + expr: dummy_expr.clone(), tokens: r2.tokens.clone(), ctx: r.ctx.clone(), err: r2.err.clone(), @@ -13156,15 +13192,15 @@ pub fn parse_expr_list_until_acc( Some(t) => token_matches_expected(t.clone(), end_expected.clone()), None => false, }; - if (at_end_tag.clone() || tok_is_eof(token_stream_first(tokens.clone()))) { + if (at_end_tag || tok_is_eof(token_stream_first(tokens.clone()))) { break Rc::new(ExprsResult { - exprs: acc.clone(), + exprs: acc, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } else { - let r = parse_expr(tokens.clone(), ctx.clone()); + let r = parse_expr(tokens.clone(), ctx); if has_err(r.err.clone()) { return Rc::new(ExprsResult { exprs: Rc::new(vec![]), @@ -13174,7 +13210,7 @@ pub fn parse_expr_list_until_acc( }); } let e = eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); - tokens = skip_newlines(match (*e.clone()).clone() { + tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r.tokens.clone(), }); @@ -13268,7 +13304,7 @@ pub fn parse_paren_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = __ec.clone(); - let __tco_1 = new_acc.clone(); + let __tco_1 = new_acc; tokens = __tco_0; acc = __tco_1; continue; @@ -13491,9 +13527,9 @@ pub fn collect_lambda_idents( EatResult::EatUnchanged { tokens: __eu, .. } => { break Rc::new(IdentCollectResult { success: true, - params: new_acc.clone(), + params: new_acc, tokens: token_stream_advance(tokens.clone(), 1), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } @@ -13501,9 +13537,9 @@ pub fn collect_lambda_idents( } else { break Rc::new(IdentCollectResult { success: false, - params: acc.clone(), + params: acc, tokens: tokens.clone(), - ctx: ctx.clone(), + ctx: ctx, err: None, }); } @@ -13522,7 +13558,9 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc Some(TokenShape::ShStrBegin) => { let prefix = tok.clone().unwrap().text.clone(); let parts_init = if (v1_rt::string_length(&prefix) > 0) { - Rc::new(vec![Rc::new(StringPart::Text { value: prefix })]) + Rc::new(vec![Rc::new(StringPart::Text { + value: prefix.clone(), + })]) } else { Rc::new(vec![]) }; @@ -13530,7 +13568,7 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc token_stream_advance(tokens.clone(), 1), ctx, parts_init, - span, + span.clone(), ) } _ => Rc::new(ExprResult { @@ -13542,7 +13580,7 @@ pub fn parse_string_interp(tokens: Rc, ctx: Rc) -> Rc ctx: ctx, err: Some(parse_error( "expected string interpolation".to_string(), - span, + span.clone(), )), }), } @@ -13558,10 +13596,10 @@ pub fn parse_interp_parts( loop { let r = parse_expr(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { - return r; + return r.clone(); } let new_parts = v1_rt::rc_list_push( - parts.clone(), + parts, Rc::new(StringPart::Interpolation { expr: r.expr.clone(), }), @@ -13573,20 +13611,17 @@ pub fn parse_interp_parts( Some(t) => Some(t.shape.clone()), None => None, }; - match interp_sh.clone() { + match interp_sh { Some(TokenShape::ShStrMid) => { let mid = interp_tok.clone().unwrap().text.clone(); let mid_parts = if (v1_rt::string_length(&mid) > 0) { - v1_rt::rc_list_push( - new_parts.clone(), - Rc::new(StringPart::Text { value: mid.clone() }), - ) + v1_rt::rc_list_push(new_parts, Rc::new(StringPart::Text { value: mid.clone() })) } else { - new_parts.clone() + new_parts }; { let __tco_0 = token_stream_advance(tokens, 1); - let __tco_1 = mid_parts.clone(); + let __tco_1 = mid_parts; tokens = __tco_0; parts = __tco_1; continue; @@ -13596,20 +13631,20 @@ pub fn parse_interp_parts( let suffix = interp_tok.clone().unwrap().text.clone(); let final_parts = if (v1_rt::string_length(&suffix) > 0) { v1_rt::rc_list_push( - new_parts.clone(), + new_parts, Rc::new(StringPart::Text { value: suffix.clone(), }), ) } else { - new_parts.clone() + new_parts }; break Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprStringInterp), Rc::new({ let mut __result = Vec::new(); - for p in final_parts.clone().iter().cloned() { + for p in final_parts.iter().cloned() { __result.push(match (*p.clone()).clone() { StringPart::Text { value: v, .. } => { make_text_part_node(v.clone(), span.clone()) @@ -13635,7 +13670,7 @@ pub fn parse_interp_parts( Rc::new(ExprData::ExprStringInterp), Rc::new({ let mut __result = Vec::new(); - for p in new_parts.clone().iter().cloned() { + for p in new_parts.iter().cloned() { __result.push(match (*p.clone()).clone() { StringPart::Text { value: v, .. } => { make_text_part_node(v.clone(), span.clone()) @@ -13687,7 +13722,7 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc { let brace_kw = tok_keyword_text(tok.clone()); if ((brace_kw.clone() == "let".to_string()) - || (brace_kw == "return".to_string())) + || (brace_kw.clone() == "return".to_string())) { { let r = parse_stmts(tokens.clone(), ctx); @@ -13704,7 +13739,7 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, m: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/03_resolve.dag:1814:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let result = resolve_module_imports( m.clone(), @@ -122,7 +122,7 @@ pub fn resolve_modules( let import_diags = resolve_accum.diagnostics.clone(); let topo_result = topological_sort(modules.clone(), source_indices.clone()); let topo_diags = match topo_result.cycle_error.clone() { - Some(diag) => Rc::new(vec![diag]), + Some(diag) => Rc::new(vec![diag.clone()]), None => Rc::new(vec![]), }; let sorted_names = topo_result.sorted.clone(); @@ -237,7 +237,7 @@ pub fn resolve_module_imports( }); let diags = Rc::new({ let mut __result = Vec::new(); - for r in results.iter().cloned() { + for r in results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -277,7 +277,7 @@ pub fn resolve_import( ); Rc::new(ImportResolveResult { resolved: Rc::new(ResolvedImport { - module_path: import_path, + module_path: import_path.clone(), is_all: import_is_all(import.clone()), specific_names: import_specific_names_at( import.clone(), @@ -290,7 +290,7 @@ pub fn resolve_import( } Some(target_mod) => { let exported_set = match v1_rt::map_get(&export_sets, import_path.clone()) { - Some(set) => set, + Some(set) => set.clone(), None => v1_rt::rc_empty_map::(), }; let name_diags = if import_is_all(import.clone()) { @@ -329,13 +329,13 @@ pub fn resolve_import( }; Rc::new(ImportResolveResult { resolved: Rc::new(ResolvedImport { - module_path: import_path, + module_path: import_path.clone(), is_all: import_is_all(import.clone()), specific_names: import_specific_names_at( import.clone(), source_indices.clone(), ), - target_module: Some(target_mod), + target_module: Some(target_mod.clone()), }), diagnostics: name_diags, }) @@ -478,7 +478,7 @@ pub fn adjacency_add_edge( ) -> Rc>>> { { let existing = match v1_rt::map_get(&adjacency, from_module.clone()) { - Some(lst) => lst, + Some(lst) => lst.clone(), None => Rc::new(vec![]), }; v1_rt::rc_map_insert( @@ -493,7 +493,7 @@ pub fn topo_sort_key(name: String) -> String { if (name.clone() == "std.types".to_string()) { "".to_string() } else { - name + name.clone() } } @@ -605,11 +605,11 @@ pub fn topological_sort( let result = kahn_drain( initial_queue, Rc::new(vec![]), - in_degree_map, + in_degree_map.clone(), adjacency, module_count.clone(), ); - if ((result.sorted.clone().len() as i64) == module_count) { + if ((result.sorted.clone().len() as i64) == module_count.clone()) { Rc::new(TopoResult { sorted: result.sorted.clone(), cycle_error: None, @@ -624,7 +624,7 @@ pub fn topological_sort( ); let cycle_members = Rc::new({ let mut __result = Vec::new(); - for name in module_names.iter().cloned() { + for name in module_names.clone().iter().cloned() { if (v1_rt::map_has(&sorted_set, name.clone()) == false) { __result.push(name); } @@ -636,7 +636,7 @@ pub fn topological_sort( sorted: result.sorted.clone(), cycle_error: Some(make_error_node( Rc::new(CompilerDiagnostic::CircularDependency { - modules: cycle_members, + modules: cycle_members.clone(), span: no_span(), }), "".to_string(), @@ -673,7 +673,7 @@ pub fn kahn_drain( in_degree_map: in_degree_map.clone(), }), |state: Rc, node: String| { - let state = v1_rt::take_owned_counted(state, "src/v1/03_resolve.dag:11425:state"); + let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let new_sorted = v1_rt::rc_list_push(state.sorted, node.clone()); let neighbors = match v1_rt::map_get(&adjacency, node.clone()) { @@ -750,7 +750,7 @@ pub fn kahn_drain( __sorted }); { - let __tco_0 = new_zero.clone(); + let __tco_0 = new_zero; let __tco_1 = batch_result.sorted.clone(); let __tco_2 = batch_result.in_degree_map.clone(); let __tco_3 = (fuel - 1); diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index 23bb9dedd25..7b4719aca47 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -94,11 +94,11 @@ pub fn render_stage0_crate_dep(dep: Rc) -> String { match (*dep.source.clone()).clone() { CargoDepSource::RegistryDep { version, features, .. - } => emit_cargo_dep(dep.name.clone(), version, features), + } => emit_cargo_dep(dep.name.clone(), version.clone(), features.clone()), CargoDepSource::LocalPathDep { path: path, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat(dep.name.clone(), " = { path = \"".to_string()), - path, + path.clone(), ), "\" }\n".to_string(), ), diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index 5c15786c023..1e7d9828c41 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -234,12 +234,12 @@ pub fn scan_next_token(source: Rc, pos: Rc) -> Rc ), TokenShape::ShRBrace, ), - interp_depth: replace_last(pos.interp_depth.clone(), (top - 1)), + interp_depth: replace_last(pos.interp_depth.clone(), (top.clone() - 1)), }); } } } - scan_token(source.clone(), pos.clone(), ch) + scan_token(source.clone(), pos.clone(), ch.clone()) } } @@ -250,7 +250,7 @@ pub fn tokenize_loop( mut fuel: i64, ) -> Rc { loop { - let s = skip_spaces(source.clone(), pos.clone()); + let s = skip_spaces(source.clone(), pos); if (s.pos.clone() >= source_len(source.clone())) { return Rc::new(TokenizerState { pos: s.pos.clone(), @@ -389,7 +389,7 @@ pub fn scan_token(source: Rc, pos: Rc, ch: i64) -> Rc, pos: Rc, ch: i64) -> Rc { - emit(pos.clone(), sh, ch_text, 1, source.file.clone()) - } + v1_rt::Witness::Holds { value: sh, .. } => emit( + pos.clone(), + sh.clone(), + ch_text.clone(), + 1, + source.file.clone(), + ), v1_rt::Witness::Violates { diagnostic: _, .. } => emit( pos.clone(), TokenShape::ShUnknown, - ch_text, + ch_text.clone(), 1, source.file.clone(), ), @@ -539,12 +543,12 @@ pub fn scan_ident(source: Rc, pos: Rc) -> Rc { } }; let token = make_token( - text, + text.clone(), make_file_span(source.file.clone(), pos.pos.clone(), end.clone()), shape, ); Rc::new(ScanResult { - pos: end, + pos: end.clone(), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -567,7 +571,7 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { TokenShape::ShLitFloat, ); return Rc::new(ScanResult { - pos: frac_end, + pos: frac_end.clone(), token: token.clone(), interp_depth: pos.interp_depth.clone(), }); @@ -580,13 +584,13 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { None => TokenShape::ShUnknown, }; let token = make_token( - text, + text.clone(), make_file_span(source.file.clone(), pos.pos.clone(), int_end.clone()), shape, ); Rc::new(ScanResult { - pos: int_end, - token: token, + pos: int_end.clone(), + token: token.clone(), interp_depth: pos.interp_depth.clone(), }) } @@ -625,14 +629,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::ClosedString { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShLitStr, ); Rc::new(ScanResult { - pos: (end_pos + 1), + pos: (end_pos.clone() + 1), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -640,14 +644,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::InterpolationStart { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrBegin, ); Rc::new(ScanResult { - pos: (end_pos + 1), + pos: (end_pos.clone() + 1), token: token, interp_depth: Rc::new(v1_rt::append(pos.interp_depth.clone(), 0)), }) @@ -655,14 +659,14 @@ pub fn scan_string(source: Rc, pos: Rc) -> Rc { StringScanResult::UnterminatedString { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, end_pos.clone()), TokenShape::ShUnknown, ); Rc::new(ScanResult { - pos: end_pos, + pos: end_pos.clone(), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -678,14 +682,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::ClosedString { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrEnd, ); Rc::new(ScanResult { - pos: (end_pos + 1), + pos: (end_pos.clone() + 1), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -693,14 +697,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::InterpolationStart { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, (end_pos.clone() + 1)), TokenShape::ShStrMid, ); Rc::new(ScanResult { - pos: (end_pos + 1), + pos: (end_pos.clone() + 1), token: token, interp_depth: Rc::new(v1_rt::append(pos.interp_depth.clone(), 0)), }) @@ -708,14 +712,14 @@ pub fn scan_str_cont(source: Rc, pos: Rc, span_start: i64) -> StringScanResult::UnterminatedString { content, end_pos, .. } => { - let processed = process_escapes(content); + let processed = process_escapes(content.clone()); let token = make_token( processed, make_file_span(source.file.clone(), span_start, end_pos.clone()), TokenShape::ShUnknown, ); Rc::new(ScanResult { - pos: end_pos, + pos: end_pos.clone(), token: token, interp_depth: pos.interp_depth.clone(), }) @@ -732,14 +736,14 @@ pub fn scan_string_body( loop { if (pos.clone() >= source_len(source.clone())) { break Rc::new(StringScanResult::UnterminatedString { - content: acc.clone().join(&"".to_string()), + content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { let ch = source_char(source.clone(), pos.clone()); if (ch.clone() == "\"".to_string()) { break Rc::new(StringScanResult::ClosedString { - content: acc.clone().join(&"".to_string()), + content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { @@ -750,7 +754,7 @@ pub fn scan_string_body( let __tco_0 = (pos + 2); let __tco_1 = v1_rt::rc_list_push( v1_rt::rc_list_push(acc, "\\".to_string()), - escaped.clone(), + escaped, ); pos = __tco_0; acc = __tco_1; @@ -758,7 +762,7 @@ pub fn scan_string_body( } } else { break Rc::new(StringScanResult::UnterminatedString { - content: v1_rt::rc_list_push(acc.clone(), "\\".to_string()) + content: v1_rt::rc_list_push(acc, "\\".to_string()) .join(&"".to_string()), end_pos: (pos.clone() + 1), }); @@ -767,7 +771,7 @@ pub fn scan_string_body( if (ch.clone() == "{".to_string()) { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { - content: acc.clone().join(&"".to_string()), + content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { @@ -801,7 +805,7 @@ pub fn should_start_interpolation(source: Rc, pos: i64) -> bool { { let next = source_code_point(source.clone(), (pos.clone() + 1)); (((is_ident_start(next.clone()) || (next.clone() == 40)) || (next.clone() == 33)) - || (next == 45)) + || (next.clone() == 45)) } } } @@ -813,7 +817,7 @@ pub fn process_escapes(raw: String) -> String { pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc>) -> String { loop { if (pos.clone() >= v1_rt::string_length(&source)) { - break acc.clone().join(&"".to_string()); + break acc.join(&"".to_string()); } else { let ch = v1_rt::char_at(&source, pos.clone()); if ((ch.clone() == "\\".to_string()) @@ -847,7 +851,7 @@ pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc, pos: Rc) -> Rc { } pub fn is_digit(ch: i64) -> bool { - ((ch.clone() >= 48) && (ch <= 57)) + ((ch.clone() >= 48) && (ch.clone() <= 57)) } pub fn is_ident_start(ch: i64) -> bool { @@ -915,7 +919,7 @@ pub fn is_ident_start(ch: i64) -> bool { } pub fn is_ident_char(ch: i64) -> bool { - (v1_rt::is_xid_continue(ch.clone()) || v1_rt::is_emoji_ident(ch)) + (v1_rt::is_xid_continue(ch.clone()) || v1_rt::is_emoji_ident(ch.clone())) } pub fn is_hex_upper_digit(ch: i64) -> bool { @@ -928,7 +932,7 @@ pub fn all_hex_upper_in_range(mut text: String, mut pos: i64, mut end: i64) -> b break true; } else { let ch = v1_rt::code_point(v1_rt::char_at(&text, pos.clone())); - if is_hex_upper_digit(ch.clone()) { + if is_hex_upper_digit(ch) { { let __tco_0 = (pos + 1); pos = __tco_0; @@ -1003,19 +1007,23 @@ pub fn is_reserved_emit_sentinel(text: String) -> bool { if (n.clone() < ((pfx_len.clone() + sfx_len.clone()) + 1)) { false } else { - if !sentinel_prefix_matches(text.clone(), pfx, 0, pfx_len.clone()) { + if !sentinel_prefix_matches(text.clone(), pfx.clone(), 0, pfx_len.clone()) { false } else { if !sentinel_suffix_matches( text.clone(), - sfx, + sfx.clone(), 0, sfx_len.clone(), (n.clone() - sfx_len.clone()), ) { false } else { - all_hex_upper_in_range(text.clone(), pfx_len, (n - sfx_len)) + all_hex_upper_in_range( + text.clone(), + pfx_len.clone(), + (n.clone() - sfx_len.clone()), + ) } } } diff --git a/src/v1/stage0/src/v1_compiler_trace.rs b/src/v1/stage0/src/v1_compiler_trace.rs index 66206e73087..95c4625f716 100644 --- a/src/v1/stage0/src/v1_compiler_trace.rs +++ b/src/v1/stage0/src/v1_compiler_trace.rs @@ -106,7 +106,7 @@ pub fn trace_pop_frame(trace: Rc) -> Rc { .clone() .iter() .cloned() - .take((n - 1) as usize) + .take((n.clone() - 1) as usize) .collect::>(), ), }) @@ -116,17 +116,17 @@ pub fn trace_pop_frame(trace: Rc) -> Rc { pub fn event_span(event: Rc) -> Rc { match (*event).clone() { - TraceEvent::TraceEnter { span: s, .. } => s, - TraceEvent::TraceExit { span: s, .. } => s, - TraceEvent::TraceError { span: s, .. } => s, + TraceEvent::TraceEnter { span: s, .. } => s.clone(), + TraceEvent::TraceExit { span: s, .. } => s.clone(), + TraceEvent::TraceError { span: s, .. } => s.clone(), } } pub fn event_node_id(event: Rc) -> String { match (*event).clone() { - TraceEvent::TraceEnter { node_id: id, .. } => id, - TraceEvent::TraceExit { node_id: id, .. } => id, - TraceEvent::TraceError { node_id: id, .. } => id, + TraceEvent::TraceEnter { node_id: id, .. } => id.clone(), + TraceEvent::TraceExit { node_id: id, .. } => id.clone(), + TraceEvent::TraceError { node_id: id, .. } => id.clone(), } } @@ -204,8 +204,11 @@ pub fn format_trace_event(event: Rc) -> String { span: sp, .. } => v1_rt::concat( - v1_rt::concat(v1_rt::concat("> ".to_string(), id), " at ".to_string()), - format_span(sp), + v1_rt::concat( + v1_rt::concat("> ".to_string(), id.clone()), + " at ".to_string(), + ), + format_span(sp.clone()), ), TraceEvent::TraceExit { node_id: id, @@ -215,12 +218,15 @@ pub fn format_trace_event(event: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat("< ".to_string(), id), " at ".to_string()), - format_span(sp), + v1_rt::concat( + v1_rt::concat("< ".to_string(), id.clone()), + " at ".to_string(), + ), + format_span(sp.clone()), ), ": ".to_string(), ), - out, + out.clone(), ), TraceEvent::TraceError { node_id: id, @@ -230,12 +236,15 @@ pub fn format_trace_event(event: Rc) -> String { } => v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat("! ".to_string(), id), " at ".to_string()), - format_span(sp), + v1_rt::concat( + v1_rt::concat("! ".to_string(), id.clone()), + " at ".to_string(), + ), + format_span(sp.clone()), ), ": ".to_string(), ), - msg, + msg.clone(), ), } } diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 7542619f127..d3042fd1aa4 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -329,39 +329,6 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. -// take_owned_counted: fail-closed replacement for the silent -// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5: -// a failure arm must refuse or be counted, never silently widen). A shared Rc -// at a proof-licensed take-owned site is a proof deficit; the clone arm counts -// per emitted site so the deficit frequency stays observable. -thread_local! { - static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = - std::cell::RefCell::new(HashMap::new()); -} - -pub fn take_owned_counted(x: Rc, site: &'static str) -> T { - Rc::try_unwrap(x).unwrap_or_else(|rc| { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); - (*rc).clone() - }) -} - -pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| { - let mut v: Vec<(String, u64)> = m - .borrow() - .iter() - .map(|(site, n)| (site.to_string(), *n)) - .collect(); - v.sort(); - v - }) -} - -pub fn reset_take_owned_clone_fallbacks() { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); -} - pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From d873f7a31701820bf97cca6e07ed02eb38f9fe39 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:19:19 +0000 Subject: [PATCH 15/27] Drop gen-1/gen-2 adjudication scaffolding from the branch (local probe state auto-WIP'd in; results snapshotted to scratchpad) --- src/v1/dag_collect.dag | 3 + src/v1/dag_collect_support.dag | 3 + src/v1/stage0/src/v1_compiler_compile.rs | 13 +- src/v1/stage0/src/v1_compiler_complexity.rs | 143 +- src/v1/stage0/src/v1_compiler_emit.rs | 71 +- .../src/v1_compiler_emit_core_support.rs | 15 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 34 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 36 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 667 ++- src/v1/stage0/src/v1_compiler_infer.rs | 3910 ++++++++--------- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 9 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 7 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 244 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 43 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 32 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 61 +- .../stage0/src/v1_compiler_infer_patterns.rs | 238 +- .../stage0/src/v1_compiler_infer_resolve.rs | 438 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 3 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 32 +- src/v1/stage0/src/v1_compiler_normalize.rs | 5 +- src/v1/stage0/src/v1_compiler_ownership.rs | 360 +- src/v1/stage0/src/v1_compiler_parse.rs | 216 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 40 + 26 files changed, 2911 insertions(+), 3718 deletions(-) diff --git a/src/v1/dag_collect.dag b/src/v1/dag_collect.dag index a910f018b07..a03495ec298 100644 --- a/src/v1/dag_collect.dag +++ b/src/v1/dag_collect.dag @@ -122,6 +122,7 @@ fn dag_collect_insert_slots(node: Node, slots: Map, coll Present { value: _ } => slots Absent => { let fp = if anchor.span.start == 0 && anchor.span.end == 0 { + // Synthetic keys embed the fingerprint; Absent branch must not re-hash. substring(s: key, start: 6, end: string_length(s: key)) } else { dag_node_fingerprint(node: anchor) @@ -143,6 +144,8 @@ fn dag_collect_from_module(module: TypedModule, slots: Map DagCollectAcc { let _memo_reset = dag_collect_fp_memo_reset() + // Dissolve-on: drop collision_errors threading once synthetic-key construction proof + // is a typed wall (key embeds fp ⇒ key-equal ⇒ fp-equal); kept for emit_dag gate shape. let collision_errors = [] let slots = typed.modules |> fold(init: empty_map(), f: (s, m) => dag_collect_from_module(module: m, slots: s, collision_errors: collision_errors)) diff --git a/src/v1/dag_collect_support.dag b/src/v1/dag_collect_support.dag index b24a83d9fd9..a590dabca84 100644 --- a/src/v1/dag_collect_support.dag +++ b/src/v1/dag_collect_support.dag @@ -118,6 +118,9 @@ fn dag_node_surface_fingerprint(node: Node) -> String { dag_node_surface_fingerprint_rec(node: node) } +// Dissolve-on: ground on std.content_hash + node-keyed memo table once v2 adoption +// clears for this stage. Realization threads a per-collect memo reset at +// collect_dag_nodes entry; Rust seed uses Rc::as_ptr until then. fn dag_collect_fp_memo_reset() -> Bool { true } diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 8f308b2e03b..1c1e8ecd469 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -167,7 +167,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - (*m.type_env).clone().source_indices.clone(), + m.type_env.clone().source_indices.clone(), item.clone(), ), body: item.body.clone().clone().unwrap(), @@ -232,12 +232,12 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) } diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 9cfd9c91d3c..368276eb3bc 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -2207,11 +2207,7 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names( - entry.body.clone(), - entry.params.clone(), - si.clone(), - ), + recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), ), None => acc.clone(), }, @@ -7669,9 +7665,9 @@ pub fn cost_of_method_by_shape( base: 2, argument: size.clone(), }); - let per_comparison = (*key_result.summary.clone().work).clone(); + let per_comparison = key_result.summary.clone().work.clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), + left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, }); let sort_os = seed_cost_map( @@ -8628,13 +8624,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8645,13 +8641,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*args_result.summary.clone().work).clone(), - (*callee_result.summary.clone().work).clone(), + work: cost_seq( + args_result.summary.clone().work.clone(), + callee_result.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*args_result.summary.clone().span).clone(), - (*callee_result.summary.clone().span).clone(), + span: cost_seq( + args_result.summary.clone().span.clone(), + callee_result.summary.clone().span.clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), @@ -8745,13 +8741,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8814,7 +8810,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*acc.result).clone().table.clone(), + acc.result.clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8822,13 +8818,13 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( - (*(*acc.result).clone().summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_par( + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( - (*(*acc.result).clone().summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_par( + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), @@ -8850,24 +8846,18 @@ pub fn cost_of_expr( ), span: cost_conditional( s_r.summary.clone().span.clone(), - Rc::new(vec![ - (*arms_accum.result).clone().summary.clone().span.clone() - ]), + Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), ), - output_size: (*arms_accum.result) + output_size: arms_accum + .result .clone() .summary .clone() .output_size .clone(), - certainty: (*arms_accum.result) - .clone() - .summary - .clone() - .certainty - .clone(), + certainty: arms_accum.result.clone().summary.clone().certainty.clone(), }), - table: (*arms_accum.result).clone().table.clone(), + table: arms_accum.result.clone().table.clone(), }) } ExprData::ExprIf => { @@ -8963,13 +8953,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*v_r.summary.clone().work).clone(), - (*b_r.summary.clone().work).clone(), + work: cost_seq( + v_r.summary.clone().work.clone(), + b_r.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*v_r.summary.clone().span).clone(), - (*b_r.summary.clone().span).clone(), + span: cost_seq( + v_r.summary.clone().span.clone(), + b_r.summary.clone().span.clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), @@ -9002,13 +8992,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().work).clone(), - (*sr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + sr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().span).clone(), - (*sr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + sr.summary.clone().span.clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), @@ -9040,8 +9030,7 @@ pub fn cost_of_expr( ); let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = - cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), @@ -9074,13 +9063,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9111,13 +9100,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9235,11 +9224,8 @@ pub fn get_or_compute_summary( output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = cache_summary( - result.table.clone(), - func_name.clone(), - simplified.clone(), - ); + let final_table = + cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); Rc::new(SummaryResult { summary: simplified.clone(), table: final_table, @@ -9734,8 +9720,7 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) - > 0) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( @@ -9860,7 +9845,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - (*sr.table).clone(), + sr.table.clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), @@ -9880,9 +9865,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) + evict_summary(evicted_table.clone(), func_name.clone()) } else { - Rc::new(evicted_table.clone()) + evicted_table.clone() }; Rc::new(TopoBuildAcc { table: final_table.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 0f289bbabe9..e7c5382b4eb 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -599,7 +599,7 @@ pub fn module_emit_scope(typed_module: Rc) -> Rc { locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), @@ -620,7 +620,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -710,7 +707,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), true, ) @@ -724,7 +721,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -742,7 +739,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -2544,15 +2541,12 @@ pub fn emit_shared_tco_expr( mut emit_default_return: impl Fn(Rc) -> String + Clone, ) -> String { loop { - let si = (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + let si = frame.scope.clone().type_env.clone().source_indices.clone(); + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: (*frame.expr).clone().children.clone(), + args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2627,11 +2621,7 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr( - frame.expr.clone(), - frame.scope.clone(), - frame.depth.clone(), - ); + let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2645,18 +2635,15 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = recurse_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2683,7 +2670,7 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); let t = if_then_branch(frame.expr.clone()); @@ -2808,14 +2795,11 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let v = let_value(frame.expr.clone()); let bd = let_body(frame.expr.clone()); @@ -2848,9 +2832,9 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { @@ -2952,10 +2936,7 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - (*input.scope.clone().type_env) - .clone() - .source_indices - .clone(), + input.scope.clone().type_env.clone().source_indices.clone(), ) }, |frame| { @@ -3130,7 +3111,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3230,7 +3211,7 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); let arm_list = match_arm_nodes(frame.expr.clone()); @@ -3461,7 +3442,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -5264,7 +5245,7 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = (*scope.type_env).clone().source_indices.clone(); + let source_indices = scope.type_env.clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -5752,7 +5733,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5772,7 +5753,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = (*scope.type_env).clone().source_indices.clone(); + let fa_si = scope.type_env.clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index eee7c7acd88..e384a9d4951 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -585,7 +585,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -137,7 +137,7 @@ pub fn emit_go(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -462,10 +462,10 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*typed_module.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); + let si = typed_module.type_env.clone().source_indices.clone(); + let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( v1_rt::concat( @@ -480,7 +480,7 @@ pub fn emit_go_module( ); let imports_str = emit_go_imports( typed_module.items.clone(), - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), si.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -695,10 +695,10 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let env = scope.type_env.clone(); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), Rc::new(env.clone())) + emit_go_type_def_from_connective(item.clone(), env.clone()) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -743,10 +743,10 @@ pub fn emit_go_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, Rc::new(env.clone())) + emit_go_service_def(item.clone(), registry, env.clone()) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), Rc::new(env.clone())) + emit_go_resource_def(item.clone(), env.clone()) } else { v1_rt::concat( v1_rt::concat( @@ -1141,7 +1141,7 @@ pub fn emit_go_fn_def( scope: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1255,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1388,7 +1388,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1800,7 +1800,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 27fd76562e4..ddb3cc3f4a9 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,7 +117,7 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -125,7 +125,7 @@ pub fn emit_python(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -187,7 +187,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); @@ -364,12 +364,12 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); + let si = scope.type_env.clone().source_indices.clone(); + let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(Rc::new(m.clone())), si.clone()); + let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { @@ -582,10 +582,10 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let env = scope.type_env.clone(); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), Rc::new(env.clone())) + emit_py_type_def_from_connective(item.clone(), env.clone()) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -632,10 +632,10 @@ pub fn emit_py_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, Rc::new(env.clone())) + emit_py_service_def(item.clone(), registry, env.clone()) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), Rc::new(env.clone())) + emit_py_resource_def(item.clone(), env.clone()) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 1f1ff4efb8b..b45fa7ffa52 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, - build_read_only_params, collect_callable_refs, move_site_key, + analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, + collect_callable_refs, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,6 +1401,11 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { + if let Some(host) = + rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) + { + return host; + } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2603,7 +2608,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); Rc::new({ @@ -2620,10 +2625,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - item.clone(), - ); + let item_name = + authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2659,7 +2662,7 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ); let local = Rc::new({ @@ -2679,7 +2682,7 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), item.clone(), ), item.clone(), @@ -2693,7 +2696,7 @@ pub fn build_scoped_data_item_index( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2701,7 +2704,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), ) .iter() .cloned() @@ -3248,14 +3251,12 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, - pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, - pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3279,7 +3280,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), - move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3371,7 +3367,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: ownership.move_sites_index.clone(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3448,7 +3437,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); svc_items.clone().iter().cloned().fold( @@ -3457,7 +3446,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3493,7 +3482,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -3501,7 +3490,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -3528,10 +3517,8 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3682,8 +3669,6 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: base_info.move_sites_index.clone(), - move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3712,12 +3697,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); let exported = get_exported_names( tm.module.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3742,26 +3727,26 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(Rc::new(m.clone())).iter().cloned() { + for imp in module_imports(m.clone()).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) .iter() .cloned(), @@ -3778,11 +3763,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __result.push(item); @@ -3798,13 +3783,13 @@ pub fn emit_module_full( __result }); let imports_str = emit_imports( - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), emit_info.clone(), registry.clone(), local_type_names, export_sets.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3813,7 +3798,7 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3921,14 +3906,14 @@ pub fn emit_module_full( } __result }); - let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(m.clone()); + let this_module_name = authored_name(scope.type_env.clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3937,7 +3922,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3945,7 +3930,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3968,10 +3953,8 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - i.clone(), - ) == "wire_contract".to_string())) + && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) + == "wire_contract".to_string())) { __result.push(i); } @@ -3985,7 +3968,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4009,20 +3992,20 @@ pub fn emit_module_full( } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4140,7 +4123,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { @@ -4153,7 +4136,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { @@ -4228,10 +4211,7 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at( - source_indices.clone(), - tm.module.clone(), - )); + __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); } __result }) @@ -4606,8 +4586,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in - module_imports(tm.module.clone()).iter().cloned() + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -7229,18 +7208,18 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - Rc::new(env.clone()), + env.clone(), emit_info.clone(), wire_contract_item, data_items, @@ -7500,12 +7479,12 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco.clone() { + let fn_read_only = if item_is_tco { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7516,17 +7495,6 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco.clone() { - v1_rt::rc_empty_map::() - } else { - match v1_rt::map_get( - &emit_info.move_sites_index.clone(), - qualified_name.clone(), - ) { - Some(m) => m.clone(), - None => v1_rt::rc_empty_map::(), - } - }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7539,15 +7507,13 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), }); let is_effectful = match lookup_item( registry.clone(), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7599,7 +7565,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env.clone(), ) } else { if is_resource_def_item(item.clone()) { @@ -7607,7 +7573,7 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env.clone(), ) } else { v1_rt::concat( @@ -7627,15 +7593,6 @@ pub fn emit_typed_item( } } -pub fn needs_box_wrapping_shared_dominates() -> String { - thread_local! { - static CACHED: String = { - "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7643,32 +7600,35 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { + // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box + // — shared_types dominates the recursive check. Replaced by regen's + // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } else { - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } else { - if ((n.children.clone().len() as i64) == 0) { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } + } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; + } + if ((n.children.clone().len() as i64) == 0) { + { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } - } else { - break false; - } + break v1_rt::set_contains(&recursive_types, name.clone()); } } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } } } } @@ -9601,7 +9561,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9939,7 +9899,7 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), @@ -9948,10 +9908,10 @@ pub fn emit_func_def( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -10021,7 +9981,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12262,28 +12222,10 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } -pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { - if (use_span.clone() == 0) { - false - } else { - match v1_rt::map_get( - &emit_info.move_sites.clone(), - move_site_key(name.clone(), use_span.clone()), - ) { - Some(v) => { - (v.clone() - && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) - } - None => false, - } - } -} - pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, - use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12296,9 +12238,7 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = - (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) - || move_licensed_at_site(emit_info.clone(), name.clone(), use_span)); + let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12407,7 +12347,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12514,12 +12454,12 @@ pub fn field_access_field_is_boxed( match find_child_named( base_struct, field, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12529,23 +12469,18 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - { - let faithful_nat_field = ((emit_info.corpus_repr.clone() - == RustCorpusRepr::FaithfulFreeMonoid) - && ((field_ty_name.clone() == "Nat".to_string()) - || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); - ((faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - (*scope.type_env).clone().source_indices.clone(), - )) - || is_recursive_type_by_name( - scope.type_env.clone(), - field_ty_name.clone(), - )) - } + let faithful_nat_field = + matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) + && (field_ty_name.clone() == "Nat".to_string() + || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); + faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) } } None => false, @@ -12613,7 +12548,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12676,7 +12611,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -13050,7 +12985,6 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), - expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13073,7 +13007,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13082,11 +13016,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13131,10 +13065,7 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_call_expr( f, expr.children.clone(), @@ -13168,10 +13099,8 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = expr_method_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let m = + expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_method_call( expr.clone(), r, @@ -13246,10 +13175,8 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13285,10 +13212,10 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, @@ -13452,7 +13379,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13471,10 +13398,8 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = foreach_variable_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let v = + foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13582,7 +13507,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13601,7 +13526,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, |expr| { @@ -13834,10 +13759,8 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let ty_name = + resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { @@ -13856,7 +13779,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13965,7 +13888,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13990,7 +13913,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14123,7 +14046,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14138,7 +14061,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14267,7 +14190,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14414,7 +14337,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14482,10 +14405,8 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at( - a.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) + { Some(n) => n.clone(), None => "".to_string(), }, @@ -14503,7 +14424,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __found = true; @@ -14529,7 +14450,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14554,7 +14475,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14672,7 +14593,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14729,11 +14650,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14794,7 +14715,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14987,7 +14908,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15005,7 +14926,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -15049,7 +14970,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15096,7 +15017,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15118,19 +15039,6 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); - let site = v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - lambda_expr.span.clone().file.clone(), - ":".to_string(), - ), - (lambda_expr.span.clone().start.clone()).to_string(), - ), - ":".to_string(), - ), - acc_name.clone(), - ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15138,22 +15046,16 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), - ), - acc_ident.clone(), - ), - " = v1_rt::take_owned_counted(".to_string(), + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), ), acc_ident.clone(), ), - ", \"".to_string(), + " = Rc::try_unwrap(".to_string(), ), - site, + acc_ident.clone(), ), - "\"); ".to_string(), + ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), ), body_str, ), @@ -15205,7 +15107,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15246,33 +15148,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15300,7 +15202,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15310,7 +15212,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) .first() .cloned() @@ -15322,7 +15224,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15336,7 +15238,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15354,8 +15256,6 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15371,7 +15271,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15389,8 +15289,6 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15408,7 +15306,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15466,7 +15364,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15478,7 +15376,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15504,7 +15402,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15553,7 +15451,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }; @@ -15625,7 +15523,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15637,7 +15535,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { "_".to_string() @@ -15712,7 +15610,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15777,7 +15675,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15875,7 +15773,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15999,7 +15897,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -16056,7 +15954,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -16074,7 +15972,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16147,7 +16045,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16351,7 +16249,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16480,13 +16378,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -17052,7 +16950,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17122,11 +17020,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17158,7 +17056,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17300,7 +17198,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17399,7 +17297,6 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), - arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17498,7 +17395,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17582,7 +17479,7 @@ pub fn rust_struct_field_type_node( Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17609,10 +17506,8 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - receiver_type, - ); + let receiver_type_name = + authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17629,7 +17524,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, } @@ -17676,7 +17571,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17704,7 +17599,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - ((*binding.resolved).clone().return_cardinality.clone() + (binding.resolved.clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17747,7 +17642,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_base, ), f, @@ -17881,7 +17776,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17889,7 +17784,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17898,7 +17793,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18118,13 +18013,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18145,7 +18040,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18161,7 +18056,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18235,7 +18130,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18245,7 +18140,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18255,7 +18150,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ), @@ -18275,10 +18170,7 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18359,20 +18251,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = (*resolve_node( + let resolved_struct = resolve_node( resolved_type.clone(), scope.type_env.clone(), scope.module_name.clone(), ) - .resolved) - .clone(); + .resolved + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18629,10 +18521,7 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18699,7 +18588,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18918,7 +18807,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -19002,10 +18891,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19321,10 +19210,8 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19340,7 +19227,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19410,18 +19297,15 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = emit_typed_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19448,7 +19332,7 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); let t = if_then_branch(frame.expr.clone()); @@ -19669,7 +19553,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19727,7 +19611,7 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); let arm_list = match_arm_nodes(frame.expr.clone()); @@ -19745,18 +19629,12 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), rt.clone(), ) } @@ -19793,10 +19671,7 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19900,14 +19775,11 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let v = let_value(frame.expr.clone()); let bd = let_body(frame.expr.clone()); @@ -19925,10 +19797,7 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19998,9 +19867,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -20174,7 +20043,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20325,7 +20194,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -23005,8 +22874,7 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) - && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -23038,12 +22906,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -23052,7 +22920,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -23061,11 +22929,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -23096,7 +22964,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ); @@ -23107,16 +22975,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23220,10 +23088,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23232,19 +23100,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23252,14 +23120,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23291,7 +23159,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23307,7 +23175,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23332,7 +23200,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -23340,7 +23208,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23360,13 +23228,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23383,14 +23251,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23413,7 +23281,8 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -23477,14 +23346,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -24012,7 +23881,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ) { __result.push(item); } @@ -24025,12 +23894,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), registry.clone(), tm.items.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -24103,7 +23972,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )), None => "".to_string(), @@ -24140,10 +24009,8 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 546f803d36f..0525069bf0f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,18 +45,20 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, - is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, - lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, - rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, + empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, + inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, + lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + put_inductive_field, put_inductive_field_cross, record_build_type_env_call, + record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; +pub use crate::v1_compiler_infer_items::{ + inferred_to_outputs, item_kind, variant_locals_from_items, +}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -107,11 +109,13 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; +// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. +use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, - VariantCollision, + InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -142,19 +146,18 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, - import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, - is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, - is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, - lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, - make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, - make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, - make_param_node, make_span, make_text_part_node, make_transport_node, map_children, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, - module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, - param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, - return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, - with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, + index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, + is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, + is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, + let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, + make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, + make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, + make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, + method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, + node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, + resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, + string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -248,9 +251,9 @@ pub fn infer_block_stmts( let is_last = (remaining_count.clone() == 1); let stmt_expected = if is_last { expected.clone() } else { None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = (*stmt_result.typed).clone(); + let stmt_typed = stmt_result.typed.clone(); let stmt_diags = stmt_result.diagnostics.clone(); - let stmt_rt = resolved_type(Rc::new(stmt_typed.clone())); + let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = scope_after_stmt_node(stmt.clone(), stmt_rt.clone(), scope.clone()); { @@ -263,7 +266,7 @@ pub fn infer_block_stmts( ); let __tco_1 = (remaining_count - 1); let __tco_2 = next_scope; - let __tco_3 = v1_rt::rc_list_push(typed_stmts, Rc::new(stmt_typed.clone())); + let __tco_3 = v1_rt::rc_list_push(typed_stmts, stmt_typed.clone()); let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; @@ -770,66 +773,53 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - binding.resolved.clone(), - )) - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + Some(authored_name_at( + scope.type_env.clone().source_indices.clone(), + binding.resolved.clone(), + )) } else { None } + } else { + None } - None => None, } - } + None => None, + }, None => None, } } -pub fn variant_owner_node_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup +// via the binding edge — replaced by regen's true emission of variant_owner_node +// in the convergence commit. pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(owner) => { - let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); - if owner_is_coproduct { - if has_child_named( - owner.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(owner.clone()) - } else { - None - } - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(owner) => { + if owner.connective.clone() == Connective::Disj + && has_child_named( + owner.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) + { + Some(owner) + } else { + None } - None => None, } - } + None => None, + }, None => None, } } @@ -852,6 +842,45 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, + name: String, + scope_enum: String, + expected: Option>, +) -> Option { + match expected { + Some(exp_node) => { + let exp_name = authored_name_at( + scope.type_env.clone().source_indices.clone(), + exp_node.clone(), + ); + if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) + && (exp_name.clone() != name.clone())) + { + match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { + Some(exp_type) => { + if ((exp_type.connective.clone() == Connective::Disj) + && has_child_named( + exp_type.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { + Some(exp_name.clone()) + } else { + None + } + } + None => None, + } + } else { + None + } + } + None => None, + } +} + pub fn inference_error( message: String, span: Rc, @@ -882,15 +911,7 @@ pub fn type_mismatch_error( ) } -pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -898,30 +919,32 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { + if (expected.return_cardinality.clone() != Cardinality::CardOptional) { + return false; + } let expected_resolved = - match lookup_type_for(env, with_required_cardinality(expected.clone())) { + match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = ((expected.return_cardinality.clone() - == Cardinality::CardOptional) - && (expected_resolved.connective.clone() == Connective::Disj)); - let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) - == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); + let expected_is_optional_coproduct = + (expected_resolved.connective.clone() == Connective::Disj); + let got_shape = node_type_shape(got.clone(), source_indices.clone()); + let got_is_string = (got_shape == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - { - let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - ((ft.return_cardinality.clone() == Cardinality::CardOptional) - && (inner.connective.clone() == Connective::Disj)) + if (ft.return_cardinality.clone() != Cardinality::CardOptional) { + return false; } + let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { + Some(resolved) => resolved.clone(), + None => with_required_cardinality(ft.clone()), + }; + (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -931,12 +954,15 @@ pub fn record_lit_expected_fields( match type_name { Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { Some(direct) => direct.children.clone(), + // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), + // no name round-trip, no whole-env scan fallback. Regen replaces + // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -958,6 +984,37 @@ pub fn record_lit_expected_fields( } } +pub fn record_lit_variant_fields_from_visible_env( + env: Rc, + variant_name: String, + module_name: String, +) -> Rc>> { + let source_indices = env.source_indices.clone(); + let visible = flatten_visible_bindings(env.clone()); + for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { + let node = expand_type_for_field_access( + binding.resolved.clone(), + env.clone(), + module_name.clone(), + ); + if (node.connective.clone() == Connective::Disj) { + for arm in node.children.clone().iter().cloned() { + let arm_name = authored_name_at(source_indices.clone(), arm.clone()); + if (arm_name == variant_name.clone()) { + let expanded = + expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); + if (expanded.connective.clone() == Connective::Conj) { + return expanded.children.clone(); + } else { + return arm.children.clone(); + } + } + } + } + } + Rc::new(vec![]) +} + pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -967,7 +1024,7 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) @@ -978,7 +1035,7 @@ pub fn record_lit_expanded_from_expected( match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), expanded.clone(), ) == tn.clone()) { @@ -990,7 +1047,7 @@ pub fn record_lit_expanded_from_expected( _ => { let rt = resolved_type(exp.clone()); if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), rt.clone(), ) == tn.clone()) { @@ -1035,10 +1092,8 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - exp.clone(), - ) != tn.clone()) + if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) + != tn.clone()) { None } else { @@ -1054,7 +1109,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1079,7 +1134,8 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -1146,17 +1202,13 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred - .clone() - .as_deref() - .cloned() - { + match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( receiver_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1171,7 +1223,7 @@ pub fn set_union_other_operand_is_resolved_non_set( node: other_type, .. }) => !node_is_set_collection( other_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1383,7 +1435,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1391,19 +1444,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env( - receiver_type.clone(), - scope.type_env.clone(), - ) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) + }) => { + match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type.clone()) + } else { + with_optional_cardinality(value_type.clone()) + } } + None => resolve_builtin_call_type(func_name.clone()), } - None => resolve_builtin_call_type(func_name.clone()), - }, + } _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1413,7 +1465,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1422,8 +1475,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) - { + match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { @@ -1450,7 +1502,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1494,7 +1547,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()).inferred + Some(insert_arg) => match arg_value(insert_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1508,7 +1562,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()).inferred + Some(other_arg) => match arg_value(other_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1545,7 +1600,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1566,7 +1622,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(oe) => set_element_types_mismatch( re.clone(), oe.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }, @@ -1617,7 +1673,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()).inferred + match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1628,11 +1685,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => match recv_elem.clone() { Some(_) => receiver_type.clone(), None => match operand_elem.clone() { - Some(element) => (*set_kernel_ty_from_element( - element.clone(), - ) - .ty) - .clone(), + Some(element) => { + set_kernel_ty_from_element(element.clone()) + .ty + .clone() + } None => { resolve_builtin_call_type(func_name.clone()) } @@ -1884,7 +1941,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1940,16 +1997,16 @@ pub fn annotate_pattern_parent_enums( variant_subject.clone(), field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -1988,11 +2045,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), + param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2115,7 +2172,7 @@ pub fn scope_after_stmt_node( scope.clone(), let_binding_name_at( stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2141,7 +2198,7 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(n.clone()), ), _ => "".to_string(), @@ -2224,13 +2281,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2320,7 +2377,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(a); } @@ -2341,7 +2398,7 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), init_result.typed.clone(), ia.span.clone(), @@ -2370,7 +2427,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2380,7 +2437,7 @@ pub fn derive_element_provenance( let ind_fields = inductive_fields_for( scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2441,10 +2498,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2525,7 +2582,7 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ar.typed.clone(), a.span.clone(), @@ -2616,10 +2673,7 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), + arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), ar.typed.clone(), arg.span.clone(), arg.span.clone(), @@ -2657,15 +2711,16 @@ pub fn infer_expr( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let name = + expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { + // HAND-PATCH (§1c): the expected-type-as-owner-picker + // is deleted; the binding edge alone names the owner. + // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( name.clone(), Rc::new(ExprData::ExprVar { @@ -2766,14 +2821,14 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); - let base_rt = resolved_type(Rc::new(base_typed.clone())); + let base_rt = resolved_type(base_typed.clone()); let resolved_base = if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { base_rt.clone() @@ -2784,16 +2839,26 @@ pub fn infer_expr( scope.module_name.clone(), ) }; - let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { + let resolved_base_is_error = if resolved_base.inferred.clone() != None { is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; if resolved_base_is_error { + // HAND-PATCH (debug instrumentation, removed with regen): + // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - "error type cascade".to_string(), + format!( + "error type cascade (field '{}' on error-typed base '{}' in {})", + field_name, + authored_name_at( + scope.type_env.clone().source_indices.clone(), + base_typed.clone() + ), + scope.module_name + ), span.clone(), ), diagnostics: base_diags, @@ -2803,7 +2868,7 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { @@ -2824,7 +2889,7 @@ pub fn infer_expr( Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: field_type.clone(), })), @@ -2851,7 +2916,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), @@ -2868,7 +2933,7 @@ pub fn infer_expr( base_rt.clone(), field_name.clone(), scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( @@ -2879,7 +2944,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: svc_type.clone(), })), @@ -2902,7 +2967,8 @@ pub fn infer_expr( "' on type '".to_string(), ), authored_name_at( - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -2936,10 +3002,8 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = expr_call_func_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let func_name = + expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); let call_args = texpr.children.clone(); let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); @@ -2989,7 +3053,7 @@ pub fn infer_expr( let first_type = resolved_type(first_result.typed.clone()); let elem_type = for_each_element_type_node( first_type, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( first_result.typed.clone(), @@ -3010,7 +3074,7 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), first_result.typed.clone(), first_arg.span.clone(), @@ -3031,7 +3095,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3045,7 +3109,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3057,7 +3121,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -3093,7 +3157,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3114,7 +3178,7 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), @@ -3128,7 +3192,7 @@ pub fn infer_expr( formal_raw.clone(), resolved_type(ar.typed.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.subst.clone(), ) } @@ -3140,10 +3204,7 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ), ar.typed.clone(), a.span.clone(), @@ -3164,7 +3225,7 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3182,7 +3243,7 @@ pub fn infer_expr( Some(s) => substitute_generics( s.inferred.clone(), call_subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => error_type(), }; @@ -3191,7 +3252,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3202,11 +3263,11 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))( + direct_call_arg_mismatch_diags( value_params_for_check, typed_args.clone(), call_subst.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; @@ -3230,11 +3291,11 @@ pub fn infer_expr( } else { { let first_arg_type = match typed_args.clone().first().cloned() { - Some(ta) => resolved_type(arg_value(Rc::new(ta.clone()))), + Some(ta) => resolved_type(arg_value(ta.clone())), None => unit_type(), }; let method_receiver = match typed_args.clone().first().cloned() { - Some(ta) => arg_value(Rc::new(ta.clone())), + Some(ta) => arg_value(ta.clone()), None => internal_expr_error_node( "method bridge missing receiver".to_string(), span.clone(), @@ -3242,7 +3303,7 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) @@ -3250,7 +3311,7 @@ pub fn infer_expr( match Rc::new({ let mut __result = Vec::new(); for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(Rc::new(a.clone()))) { + if is_lambda_expr(arg_value(a.clone())) { __result.push(a); } } @@ -3259,7 +3320,7 @@ pub fn infer_expr( .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), None => call_fold_acc_type.clone(), } } else { @@ -3278,7 +3339,7 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { @@ -3292,13 +3353,11 @@ pub fn infer_expr( .skip(1 as usize) .collect::>(), ); - let base_result_type = - match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) - { + let base_result_type = match method_resolution.result_type.clone() { + Some(mt) => mt.clone(), + None => error_type(), + }; + let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), @@ -3315,7 +3374,8 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3328,7 +3388,7 @@ pub fn infer_expr( remaining.clone().iter().cloned() { __result.push(resolved_type( - arg_value(Rc::new(a.clone())), + arg_value(a.clone()), )); } __result @@ -3348,7 +3408,8 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3372,10 +3433,9 @@ pub fn infer_expr( }), } }; - let bridge_result_type = (*method_tv.ty).clone(); + let bridge_result_type = method_tv.ty.clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics - .clone() + let returns_receiver_self = if (method_resolution.semantics.clone() == None) { false @@ -3395,12 +3455,12 @@ pub fn infer_expr( }; let final_receiver = if ((returns_receiver_self && is_fully_resolved( - Rc::new(bridge_result_type.clone()), - (*scope.type_env).clone().source_indices.clone(), + bridge_result_type.clone(), + scope.type_env.clone().source_indices.clone(), )) && !is_fully_resolved( first_arg_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3410,7 +3470,7 @@ pub fn infer_expr( connective: receiver.connective.clone(), params: receiver.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bridge_result_type.clone()), + node: bridge_result_type.clone(), })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), @@ -3434,10 +3494,10 @@ pub fn infer_expr( for ta in remaining.clone().iter().cloned() { __result.push(make_arg_node( arg_name_at( - Rc::new(ta.clone()), - (*scope.type_env).clone().source_indices.clone(), + ta.clone(), + scope.type_env.clone().source_indices.clone(), ), - arg_value(Rc::new(ta.clone())), + arg_value(ta.clone()), span.clone(), span.clone(), )); @@ -3448,15 +3508,14 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics - .clone(), + method_semantics: method_resolution.semantics.clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bridge_result_type.clone()), + node: bridge_result_type.clone(), })), span.clone(), node_name_span(texpr.clone()), @@ -3475,7 +3534,7 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3539,7 +3598,7 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3607,7 +3666,7 @@ match bare_s { scope.clone(), span.clone(), ); - let bt = (*tier2b.bt).clone(); + let bt = tier2b.bt.clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3623,7 +3682,7 @@ match bare_s { }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bt), + node: bt, })), span.clone(), node_name_span(texpr.clone()), @@ -3641,7 +3700,8 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if (((*binding.resolved) + if ((binding + .resolved .clone() .params .clone() @@ -3649,7 +3709,7 @@ match bare_s { as i64) > 0) { - Some((*binding.resolved).clone()) + Some(binding.resolved.clone()) } else { None } @@ -3735,21 +3795,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = (*recv_result.typed).clone(); + let recv_typed = recv_result.typed.clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( - resolved_type(Rc::new(recv_typed.clone())), + resolved_type(recv_typed.clone()), scope.type_env.clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3764,7 +3824,7 @@ match bare_s { None => error_type(), }; let mc_elem_provenance = derive_element_provenance( - Rc::new(recv_typed.clone()), + recv_typed.clone(), recv_elem_type.clone(), scope.clone(), ); @@ -3780,7 +3840,7 @@ match bare_s { let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3793,14 +3853,14 @@ match bare_s { }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { match Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(Rc::new(a.clone()))) { + if is_lambda_expr(arg_value(a.clone())) { __result.push(a); } } @@ -3809,14 +3869,14 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), None => fold_acc_type.clone(), } } else { fold_acc_type.clone() }; let method_resolution = resolve_known_method_node( - Rc::new(recv_typed.clone()), + recv_typed.clone(), recv_rt.clone(), method_name.clone(), if (fold_info.clone() != None) { @@ -3825,7 +3885,7 @@ match bare_s { None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { @@ -3839,10 +3899,10 @@ match bare_s { span.clone(), ), }; - let base_result_type = (*pipe_fb.result_ty).clone(); + let base_result_type = pipe_fb.result_ty.clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { @@ -3854,15 +3914,15 @@ match bare_s { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( - Rc::new(base_result_type.clone()), - (*scope.type_env).clone().source_indices.clone(), + base_result_type.clone(), + scope.type_env.clone().source_indices.clone(), )) { { let mc_arg_types = Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - __result.push(resolved_type(arg_value(Rc::new(a.clone())))); + __result.push(resolved_type(arg_value(a.clone()))); } __result }); @@ -3879,28 +3939,28 @@ match bare_s { mc_arg_types, recv_rt.clone(), mc_fold_overrides, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } } else { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), } }; - let result_type = (*method_tv_mc.ty).clone(); + let result_type = method_tv_mc.ty.clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); let method_semantics = if (method_resolution.semantics.clone() != None) { method_resolution.semantics.clone() @@ -3913,8 +3973,8 @@ match bare_s { Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![Rc::new(recv_typed.clone())]), typed_mc_arg_nodes), - Some(Rc::new(InferredNode::Resolved { node: Rc::new(result_type) })), + v1_rt::concat(Rc::new(vec![recv_typed.clone()]), typed_mc_arg_nodes), + Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), node_name_span(texpr.clone()), ); @@ -3934,9 +3994,9 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = (*scrut_result.typed).clone(); + let scrut_typed = scrut_result.typed.clone(); let scrut_diags = scrut_result.diagnostics.clone(); - let scrut_rt = resolved_type(Rc::new(scrut_typed.clone())); + let scrut_rt = resolved_type(scrut_typed.clone()); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ @@ -3966,7 +4026,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -3988,14 +4048,14 @@ match bare_s { } else { None }, - Rc::new(body_typed.clone()), + body_typed.clone(), span.clone(), ), diagnostics: v1_rt::concat( pattern_diags.clone(), v1_rt::concat(guard_diags.clone(), body_diags.clone()), ), - body_type: resolved_type(Rc::new(body_typed.clone())), + body_type: resolved_type(body_typed.clone()), }) }); } @@ -4004,7 +4064,7 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.body_type).clone()); + __result.push(ar.body_type.clone()); } __result }); @@ -4023,14 +4083,14 @@ match bare_s { prefer_specific_type( acc, t.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); @@ -4088,7 +4148,7 @@ match bare_s { }; if !is_fully_resolved( original.body_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4121,7 +4181,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4143,7 +4203,7 @@ match bare_s { } else { None }, - Rc::new(body_typed.clone()), + body_typed.clone(), span.clone(), ), diagnostics: v1_rt::concat( @@ -4153,7 +4213,7 @@ match bare_s { body_diags.clone(), ), ), - body_type: resolved_type(Rc::new(body_typed.clone())), + body_type: resolved_type(body_typed.clone()), }) } } else { @@ -4169,7 +4229,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.typed_arm).clone()); + __result.push(ar.typed_arm.clone()); } __result }); @@ -4199,10 +4259,10 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))( + } => check_match_exhaustiveness( resolved_scrutinee.clone(), typed_arms.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), span.clone(), scope.module_name.clone(), ), @@ -4211,7 +4271,7 @@ match bare_s { }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed.clone())]), typed_arms.clone()), + v1_rt::concat(Rc::new(vec![scrut_typed.clone()]), typed_arms.clone()), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4229,10 +4289,10 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = (*cond_result.typed).clone(); + let cond_typed = cond_result.typed.clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { @@ -4242,10 +4302,10 @@ match bare_s { let else_rt = resolved_type(else_result.typed.clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { @@ -4253,30 +4313,30 @@ match bare_s { }; let else_result = if (!is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = (*else_result.typed).clone(); + let else_typed = else_result.typed.clone(); let else_diags = else_result.diagnostics.clone(); - let then_rt = resolved_type(Rc::new(then_typed.clone())); - let else_rt = resolved_type(Rc::new(else_typed.clone())); + let then_rt = resolved_type(then_typed.clone()); + let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4288,14 +4348,14 @@ match bare_s { .to_string(), node_type_shape( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), span.clone(), @@ -4304,7 +4364,7 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone()), Rc::new(else_typed.clone())]), + Rc::new(vec![cond_typed, then_typed.clone(), else_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: unified })), span.clone(), ); @@ -4319,7 +4379,7 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone())]), + Rc::new(vec![cond_typed, then_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), span.clone(), ); @@ -4333,7 +4393,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4344,7 +4404,7 @@ match bare_s { binding_kind: _, .. } => { (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), bd.clone(), ) == let_name.clone()) } @@ -4358,15 +4418,15 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); - let val_type = resolved_type(Rc::new(val_typed.clone())); + let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed.clone())]), + Rc::new(vec![val_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: val_type })), span.clone(), node_name_span(texpr.clone()), @@ -4382,16 +4442,16 @@ match bare_s { scope.clone(), let_name.clone(), val_type, - classify_binding_provenance(Rc::new(val_typed.clone()), scope.clone()), + classify_binding_provenance(val_typed.clone(), scope.clone()), ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed.clone()), Rc::new(body_typed.clone())]), + Rc::new(vec![val_typed.clone(), body_typed.clone()]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -4409,7 +4469,7 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), field_inits, span.clone(), @@ -4425,7 +4485,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4447,7 +4507,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push((*r.typed).clone()); + __result.push(r.typed.clone()); } __result }); @@ -4468,7 +4528,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => child_type_node(elem.clone()), @@ -4486,7 +4546,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4533,22 +4593,22 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = (*left_result.typed).clone(); + let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = (*right_result.typed).clone(); + let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), - resolved_type(Rc::new(left_typed.clone())), - (*scope.type_env).clone().source_indices.clone(), + resolved_type(left_typed.clone()), + scope.type_env.clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![Rc::new(left_typed.clone()), Rc::new(right_typed)]), + Rc::new(vec![left_typed.clone(), right_typed]), Some(Rc::new(InferredNode::Resolved { node: binop_info.result_type.clone(), })), @@ -4563,15 +4623,15 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = (*operand_result.typed).clone(); + let operand_typed = operand_result.typed.clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), - UnaryOpKind::Neg => resolved_type(Rc::new(operand_typed.clone())), + UnaryOpKind::Neg => resolved_type(operand_typed.clone()), }; let uo_texpr = make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![Rc::new(operand_typed.clone())]), + Rc::new(vec![operand_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4585,7 +4645,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4725,7 +4785,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4781,7 +4841,7 @@ match bare_s { }); let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![Rc::new(body_typed.clone())]), typed_param_nodes), + v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), body_typed.inferred.clone(), span.clone(), ); @@ -4800,10 +4860,7 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node( - r.typed.clone(), - part_node.span.clone(), - ) + make_interp_part_node(r.typed.clone(), part_node.span.clone()) } None => part_node.clone(), }, @@ -4891,9 +4948,9 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = (*inner_result.typed).clone(); + let inner_typed = inner_result.typed.clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( inner_typed.inferred.clone(), @@ -4908,7 +4965,7 @@ match bare_s { }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![Rc::new(inner_typed.clone()), target_type.clone()]), + Rc::new(vec![inner_typed.clone(), target_type.clone()]), Some(Rc::new(InferredNode::Resolved { node: target_type.clone(), })), @@ -4922,20 +4979,20 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = (*coll_result.typed).clone(); + let coll_typed = coll_result.typed.clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( - resolved_type(Rc::new(coll_typed.clone())), - (*scope.type_env).clone().source_indices.clone(), + resolved_type(coll_typed.clone()), + scope.type_env.clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( - Rc::new(coll_typed.clone()), + coll_typed.clone(), elem_type_node.clone(), scope.clone(), ); @@ -4946,12 +5003,12 @@ match bare_s { elem_provenance, ); let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( variable.clone(), Rc::new(ExprData::ExprForEach), - Rc::new(vec![Rc::new(coll_typed.clone()), Rc::new(body_typed.clone())]), + Rc::new(vec![coll_typed.clone(), body_typed.clone()]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -4966,10 +5023,10 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = (*index_result.typed).clone(); + let index_typed = index_result.typed.clone(); let index_diags = index_result.diagnostics.clone(); let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -4982,19 +5039,17 @@ match bare_s { index_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - index_typed.inferred.clone() - } - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), + _ => base_typed.inferred.clone(), + }; let idx_inferred = match index_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5009,7 +5064,7 @@ match bare_s { }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![Rc::new(base_typed.clone()), Rc::new(index_typed.clone())]), + Rc::new(vec![base_typed.clone(), index_typed.clone()]), idx_inferred, span.clone(), ); @@ -5027,13 +5082,13 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = (*start_result.typed).clone(); + let start_typed = start_result.typed.clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = (*end_result.typed).clone(); + let end_typed = end_result.typed.clone(); let end_diags = end_result.diagnostics.clone(); let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -5049,7 +5104,7 @@ match bare_s { end_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) } _ => None, @@ -5058,18 +5113,18 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() - } - _ => start_typed.inferred.clone(), + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => { + match start_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + end_typed.inferred.clone() } + _ => start_typed.inferred.clone(), } - _ => base_typed.inferred.clone(), - }; + } + _ => base_typed.inferred.clone(), + }; let slc_inferred = match slice_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5085,9 +5140,9 @@ match bare_s { let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), Rc::new(vec![ - Rc::new(base_typed.clone()), - Rc::new(start_typed.clone()), - Rc::new(end_typed.clone()), + base_typed.clone(), + start_typed.clone(), + end_typed.clone(), ]), slc_inferred, span.clone(), @@ -5107,7 +5162,7 @@ match bare_s { let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), Rc::new(vec![inner_result.typed.clone()]), - (*inner_result.typed).clone().inferred.clone(), + inner_result.typed.clone().inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -5144,7 +5199,7 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { @@ -5226,8 +5281,7 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) - { + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { if (((n.connective.clone() == Connective::NoConnective) @@ -5300,11 +5354,13 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); + let once = resolve_node(n, env.clone(), module_name.clone()) + .resolved + .clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { - break Rc::new(once.clone()); + break once.clone(); } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) @@ -5312,11 +5368,11 @@ pub fn peel_alias_once_for_field_access( { { let __tco_0 = once.clone(); - n = Rc::new(__tco_0); + n = __tco_0; continue; } } else { - break Rc::new(once.clone()); + break once.clone(); } } } @@ -5589,13 +5645,17 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) } pub fn expand_type_for_field_access_with_seen( @@ -5607,33 +5667,18 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) - } + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) -} - pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, @@ -5673,7 +5718,7 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) @@ -5698,44 +5743,67 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); - match variant_owner_node(scope.clone(), type_name.clone()) { - Some(owner) => { - let mut __found = false; - for arm in owner.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { + let si = scope.type_env.clone().source_indices.clone(); + { + let mut __found = false; + for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( + scope.type_env.clone(), + ))) + .iter() + .cloned() + { + if { + let node = binding.resolved.clone(); + if (node.connective.clone() == Connective::Disj) { { - let ea = expand_type_for_field_access( - arm.clone(), - scope.type_env.clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) == field.clone()) { - __found = true; - break; + let mut __found = false; + for arm in node.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) + == type_name.clone()) + { + { + let ea = expand_type_for_field_access( + arm.clone(), + scope.type_env.clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) + { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) + == field.clone()) + { + __found = true; + break; + } + } + __found + } } + } else { + false + } { + __found = true; + break; } - __found } + __found } } else { false - } { - __found = true; - break; } + } { + __found = true; + break; } - __found } - None => false, + __found } } } @@ -5765,28 +5833,38 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { + // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is + // deleted; the ladder is instantiate -> expected -> declaration/ + // binding-edge only. Regen replaces this with the dag source's true + // emission. let struct_fields = match type_name.clone() { - Some(tn) => match record_lit_instantiated_fields( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( + Some(tn) => { + match record_lit_instantiated_fields( type_name.clone(), expected.clone(), scope.clone(), ) { Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_fields_from_expected( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields.clone(), + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => { + match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields.clone(), + None => { + record_lit_expected_fields(type_name.clone(), scope.clone()) + } + } + } }, }, - }, - }, + } + } None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), @@ -5817,7 +5895,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5853,7 +5931,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5870,8 +5948,8 @@ pub fn infer_record_lit( Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if (((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone())) + if ((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone()) || field_type_is_optional_coproduct( ft.clone(), scope.type_env.clone(), @@ -5889,38 +5967,36 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = (*ar.typed).clone(); + let ar_typed = ar.typed.clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { - let got_node = resolved_type(Rc::new(ar_typed.clone())); + let got_node = resolved_type(ar_typed.clone()); if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), scope.type_env.clone(), ) { - { - let expected_for_shape = match lookup_type_for( - scope.type_env.clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) - } + let expected_for_shape = match lookup_type_for( + scope.type_env.clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape, + scope.type_env.clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + scope.type_env.clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) } else { Rc::new(vec![]) } @@ -5930,7 +6006,7 @@ pub fn infer_record_lit( Rc::new(FieldInferResult { typed_field: make_field_init_node( fi_name.clone(), - Rc::new(ar_typed.clone()), + ar_typed.clone(), fi.span.clone(), node_name_span(fi.clone()), ), @@ -5947,7 +6023,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push((*fir.typed_field).clone()); + __result.push(fir.typed_field.clone()); } __result }); @@ -5966,14 +6042,14 @@ pub fn infer_record_lit( __result.push(Rc::new(Node { name: field_init_node_name_at( fir.typed_field.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), - span: (*fir.typed_field).clone().span.clone(), - ident_span: (*fir.typed_field).clone().ident_span.clone(), + span: fir.typed_field.clone().span.clone(), + ident_span: fir.typed_field.clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), + inferred: fir.infer_result.clone().typed.clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6055,7 +6131,7 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( fir.typed_field.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6075,6 +6151,9 @@ pub fn infer_record_lit( } else { raw_resolved }; + // HAND-PATCH (§1c): unbound constructor literal is the typed + // UnresolvedType diagnostic, not a generic InternalError message. + // Regen replaces this with the dag source's true emission. let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( @@ -6173,7 +6252,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6183,7 +6262,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { Some(_) => Some(Rc::new(SizeExpr::ParamSize { @@ -6211,7 +6290,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() @@ -6260,7 +6339,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6325,7 +6404,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6336,7 +6415,7 @@ pub fn classify_collection_shrink( } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (rname == param_name.clone()) { { @@ -6381,10 +6460,7 @@ Rc::new(SubValueRelation::StrictSubValue { } => { let aname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env) - .clone() - .source_indices - .clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6592,12 +6668,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6617,7 +6693,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6652,12 +6728,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6677,7 +6753,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6721,7 +6797,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6729,7 +6805,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6795,7 +6871,7 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { @@ -6831,10 +6907,8 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = expr_method_name_at( - expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let inner_mname = + expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) @@ -6863,10 +6937,8 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = expr_var_name_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let vname = + expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6874,24 +6946,22 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = field_access_field_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let field = + field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), ); @@ -6928,8 +6998,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = - expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -6941,15 +7010,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), @@ -6961,7 +7028,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), None => match v1_rt::map_get( @@ -7010,7 +7077,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { @@ -7037,7 +7104,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let iname = expr_var_name_at( inner.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -7113,13 +7180,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { if is_container_type(authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), c.clone(), ), None => "".to_string(), @@ -7177,7 +7244,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7224,7 +7291,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7248,7 +7315,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7309,7 +7376,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7367,7 +7434,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env) + ctx.type_env .clone() .source_indices .clone(), @@ -7437,7 +7504,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7484,7 +7551,7 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) @@ -7527,7 +7594,7 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) @@ -7542,7 +7609,7 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7550,7 +7617,7 @@ pub fn classify_argument( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -7609,24 +7676,22 @@ pub fn classify_argument( SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); - let from_provenance = match lookup_func_sig( - ctx.func_env.clone(), - callee.clone(), - ) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, + let from_provenance = + match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map.clone(), + ctx.clone(), + ), + None => None, + } } - } - None => None, - }; + None => None, + }; match from_provenance { Some(prov_rel) => prov_rel.clone(), None => { @@ -7720,13 +7785,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7764,13 +7829,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7782,13 +7847,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7885,7 +7950,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7901,16 +7966,14 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7920,7 +7983,7 @@ pub fn read_arg_provenance( let fields = inductive_fields_for( ctx.type_env.clone(), authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), ); @@ -7992,7 +8055,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8011,7 +8074,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8080,7 +8143,7 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { Some(t) => t.clone(), @@ -8118,7 +8181,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8211,7 +8274,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8225,7 +8288,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8236,7 +8299,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8279,7 +8342,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), @@ -8306,7 +8369,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8314,7 +8377,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -8352,7 +8415,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "first".to_string()) || (mname.clone() == "last".to_string())) @@ -8376,7 +8439,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { @@ -8427,7 +8490,7 @@ let arm_ctx = match variant_arm_ctx.clone() { MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8464,7 +8527,7 @@ match inner_matching.clone() { None => { let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8560,10 +8623,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = let_binding_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let binding_name = + let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { @@ -8681,7 +8742,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8795,10 +8856,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = expr_method_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let mname = + expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { @@ -8810,7 +8869,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) @@ -8825,7 +8884,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let base = field_access_base(receiver.clone()); let fname = field_access_field_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8833,7 +8892,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -8888,7 +8947,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { @@ -8931,7 +8990,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); lparams .clone() @@ -9007,7 +9066,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9020,7 +9079,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9067,10 +9126,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = foreach_variable_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let fe_var = + foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9759,10 +9816,10 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = (*unwrapped.expr).clone(); + let terminal = unwrapped.expr.clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( - Rc::new(terminal), + terminal, param_names, param_types, type_env.clone(), @@ -9805,15 +9862,11 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { + match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*arm_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() + for fi in + arm_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9840,16 +9893,10 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { + let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*then_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { + for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9867,30 +9914,24 @@ pub fn classify_terminal_per_field( Some(else_expr) => { let else_unwrapped = unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = - match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in (*else_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() + { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -10058,13 +10099,13 @@ pub fn arm_ctx_from_variant_provenance( } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); + call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10077,13 +10118,13 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))( + let composed = compose_callee_param_map( param_map.clone(), call_args.clone(), c.param_order.clone(), c.param_names.clone(), - (*c.type_env).clone(), - (*c.func_env).clone(), + c.type_env.clone(), + c.func_env.clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10715,36 +10756,34 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = match item.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { - node: rt, .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, + let variant_prov = + match item.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: rt, + .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, + >, >, >, >, - >, - >( - ), - }; + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10925,7 +10964,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -11044,7 +11083,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); + __result.push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11076,7 +11115,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), @@ -11093,7 +11132,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), fn_return_expected, ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let inferred_ret = if (item.inferred.clone() != None) { item.inferred.clone() @@ -11101,27 +11140,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc body_typed.inferred.clone() }; let is_recursive = expr_has_self_call( - Rc::new(body_typed.clone()), + body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))( + annotate_descent_evidence( body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), item.params.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), fn_scope.locals.clone(), - (*scope.func_env).clone(), + scope.func_env.clone(), ) } else { - Rc::new(body_typed.clone()) + body_typed.clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11132,7 +11171,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push((*infer_item(c.clone(), scope.clone()).item).clone()); + .push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11147,13 +11186,13 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno, is_self_recursive: is_recursive.clone(), has_non_tail_self_call: expr_has_non_tail_self_call( - Rc::new(body_typed.clone()), + body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), true, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11176,7 +11215,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), Some(resolved_type(item.clone())), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11188,7 +11227,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(body_typed.clone())), + body: Some(body_typed.clone()), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11206,8 +11245,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { { let data_expected = if (item.type_annotation.clone() != None) { Some(item.type_annotation.clone().clone().unwrap()) @@ -11219,7 +11257,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc scope.clone(), data_expected, ); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { @@ -11238,7 +11276,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(val_typed.clone())), + body: Some(val_typed.clone()), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11256,8 +11294,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) - && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11268,8 +11305,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11305,8 +11341,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11501,13 +11536,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); + authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11537,7 +11572,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.clone(), ) } @@ -11558,7 +11593,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11575,7 +11610,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } else { @@ -11583,7 +11618,7 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) && (formal_name.clone() == record_type_name.clone())) @@ -11603,7 +11638,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11613,7 +11648,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11623,7 +11658,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11763,9 +11798,9 @@ pub fn deps_excluding_leaf_self( ) -> Rc> { { let deps0 = node_type_deps(b.resolved.clone(), source_indices); - let is_bare_self = (((((*b.resolved).clone().connective.clone() + let is_bare_self = ((((b.resolved.clone().connective.clone() == Connective::NoConnective) - && (((*b.resolved).clone().children.clone().len() as i64) == 0)) + && ((b.resolved.clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11832,6 +11867,14 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { + if resolved_imports.len() == 1 { + if let Some(imp) = resolved_imports.first().cloned() { + if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + return parent.type_env_cache.clone(); + } + } + return empty_type_env_cache(); + } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11844,29 +11887,58 @@ pub fn union_parent_type_env_caches( ) } -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - let is_coproduct = - ((*binding.resolved).clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - (*binding.resolved) +pub fn union_parent_variant_locals( + resolved_imports: Rc>>, + parent_index: Rc>>, +) -> Rc>> { + resolved_imports.iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, imp: Rc| match v1_rt::map_get( + &parent_index, + imp.module_path.clone(), + ) { + Some(parent) => v1_rt::rc_map_merge( + acc.clone(), + parent.type_env_cache.clone().variant_locals.clone(), + ), + None => acc.clone(), + }, + ) +} + +pub fn fold_local_coproduct_variant_locals( + bindings: Rc>>, + imported_variants: Rc>, + source_indices: Rc>>, + init_locals: Rc>>, +) -> Rc { + Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + Rc::new(VariantFoldState { + locals: init_locals, + collision_errors: Rc::new(vec![]), + }), + |acc: Rc, binding: Rc| { + let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + { + let binding_enum_name = + authored_name_at(source_indices.clone(), binding.resolved.clone()); + binding + .resolved .clone() .children .clone() @@ -11874,28 +11946,70 @@ pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>>, child: Rc| { + |vacc: Rc, child: Rc| { let child_name = - authored_name_at(env.source_indices.clone(), child.clone()); - match v1_rt::map_get(&vacc, child_name.clone()) { - Some(_prev) => vacc.clone(), - None => v1_rt::rc_map_insert( - vacc.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), + authored_name_at(source_indices.clone(), child.clone()); + let curr_child_is_imported = is_imported_variant_owned_by( + imported_variants.clone(), + child_name.clone(), + binding_enum_name.clone(), + ); + match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { + Some(_prev) => { + if curr_child_is_imported.clone() { + Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }) + } else { + vacc.clone() + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }), } }, ) - } else { - acc.clone() } - }, - ), + } else { + acc.clone() + } + }, + ) +} + +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => fold_local_coproduct_variant_locals( + kernel.bindings.clone(), + v1_rt::rc_empty_map::(), + env.source_indices.clone(), + v1_rt::rc_empty_map::>(), + ) + .locals + .clone(), None => v1_rt::rc_empty_map::>(), } } @@ -11952,26 +12066,9 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ); - let filtered_ancestry = - Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: Rc::new(v1_rt::map_keys(&parent_env.str_bindings.clone())) .iter() .cloned() .fold( @@ -11980,10 +12077,8 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -11993,11 +12088,30 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get( + &parent_env.ancestry_str_bindings.clone(), + name.clone(), + ) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ), parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12011,257 +12125,270 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, - parent_index: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, intern_table: Rc, -) -> Rc { - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) +) -> Rc { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }) +} + +pub fn build_type_env( + module: Rc, + parent_index: Rc>>, + source_indices: Rc>>, + intern_table: Rc, +) -> Rc { + record_build_type_env_call(); + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), ) }, ); - let kernel = Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let intern_table = seed_kernel_intern_table(intern_table.clone()); + let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); + let kernel_cache = type_env_cache_from_bindings( + kernel.bindings.clone(), + source_indices.clone(), + compiler_recursive_name_set(), + ); let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); @@ -12280,7 +12407,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12531,15 +12658,10 @@ pub fn build_type_env( }, ); let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); - let kernel_cache = type_env_cache_from_bindings( - kernel_bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), - ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12580,25 +12702,22 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { @@ -12609,24 +12728,26 @@ pub fn build_type_env( cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -12650,7 +12771,7 @@ pub fn build_type_env( local_name_set, all_deps_map.clone(), ); - let resolved_env_out = (*resolved.env).clone(); + let resolved_env_out = resolved.env.clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), @@ -12683,6 +12804,7 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { + record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12987,8 +13109,8 @@ pub fn build_type_env_unresolved( ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13029,25 +13151,22 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { @@ -13058,24 +13177,26 @@ pub fn build_type_env_unresolved( cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -13191,7 +13312,7 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = (*resolved.item).clone(); + let ritem = resolved.item.clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) && (ritem.inferred.clone() != None)) @@ -13199,12 +13320,12 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let func_sig = if (is_func || is_zero_arg_func) { { let declared_rt = if (ritem.inferred.clone() != None) { - Some(resolved_type(Rc::new(ritem.clone()))) + Some(resolved_type(ritem.clone())) } else { None }; Some(Rc::new(DeclaredFuncSig { - name: authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), + name: authored_name_at(env.source_indices.clone(), ritem.clone()), params: ritem.params.clone(), inferred: declared_rt, is_async: ((ritem.uses.clone().len() as i64) > 0), @@ -13218,512 +13339,324 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) - } - } else { - None - }; - Rc::new(ItemContribution { - resolved_item: Rc::new(ritem.clone()), - resolve_diagnostics: resolved.diagnostics.clone(), - func_sig: func_sig, - svc_entries: svc_entries, - svc_local: svc_local, - item_info: build_item_info( - Rc::new(ritem.clone()), - env.source_indices.clone(), - module_name.clone(), - ), - }) - } -} - -pub fn fold_module_contributions( - mut remaining: Rc>>, - mut resolved_items: Rc>>, - mut func_sigs: Rc>>, - mut svc_registry: Rc>>>>, - mut svc_locals: Rc>>, - mut item_registry: Rc>>, - mut diag_chunks: Rc>>>>, - mut source_indices: Rc>>, -) -> Rc { - loop { - match remaining.clone().first().cloned() { - None => { - break Rc::new(LocalContributionState { - resolved_items: resolved_items, - func_sigs: func_sigs, - svc_registry: svc_registry, - svc_locals: svc_locals, - item_registry: item_registry, - diag_chunks: diag_chunks, - }); - } - Some(contribution) => { - let next_func_sigs = match contribution.func_sig.clone() { - Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), - None => func_sigs, - }; - let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { - v1_rt::rc_map_insert( - svc_registry, - authored_name_at( - source_indices.clone(), - contribution.resolved_item.clone(), - ), - contribution.svc_entries.clone(), - ) - } else { - svc_registry - }; - let next_svc_locals = match contribution.svc_local.clone() { - Some(binding) => { - v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) - } - None => svc_locals, - }; - { - let __tco_0 = Rc::new( - remaining - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ); - let __tco_1 = - v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); - let __tco_2 = next_func_sigs; - let __tco_3 = next_svc_registry; - let __tco_4 = next_svc_locals; - let __tco_5 = v1_rt::rc_map_insert( - item_registry, - contribution.item_info.clone().name.clone(), - contribution.item_info.clone(), - ); - let __tco_6 = - v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); - remaining = __tco_0; - resolved_items = __tco_1; - func_sigs = __tco_2; - svc_registry = __tco_3; - svc_locals = __tco_4; - item_registry = __tco_5; - diag_chunks = __tco_6; - continue; - } - } - } - } -} - -pub fn constructor_binding_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn insert_variant_owner_checked( - state: Rc, - arm_name: String, - owner: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = authored_name_at(source_indices.clone(), prev.resolved.clone()); - let owner_name = authored_name_at(source_indices.clone(), owner.clone()); - let same_owner = (((prev_name.clone() == owner_name.clone()) - && ((*prev.resolved).clone().span.clone().file.clone() - == owner.span.clone().file.clone())) - && ((*prev.resolved).clone().span.clone().start.clone() - == owner.span.clone().start.clone())); - if same_owner { - state.clone() - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name.clone(), - enum1: prev_name.clone(), - enum2: owner_name.clone(), - span: owner.span.clone(), - }), - module_name, - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name.clone(), - resolved: owner.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } -} - -pub fn bind_coproduct_item_arms( - state: Rc, - item: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - item.children.clone().iter().cloned().fold( - state, - |vacc: Rc, child: Rc| { - insert_variant_owner_checked( - vacc, - authored_name_at(source_indices.clone(), child.clone()), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - }, - ) -} - -pub fn build_local_variants( - items: Rc>>, - source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { - items - .iter() - .cloned() - .fold(init, |acc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - acc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - acc.clone() - } - }) -} - -pub fn reexport_chain_authority() -> String { - thread_local! { - static CACHED: String = { - "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn owner_of_exported_arm( - mut module_path: String, - mut arm_name: String, - mut parent_index: Rc>>, - mut source_indices: Rc>>, -) -> Option> { - loop { - match v1_rt::map_get(&parent_index, module_path) { - None => { - break None; - } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for c in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()) - == arm_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); - } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == arm_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } - } + let svc_entries = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) } - } - } + } else { + None + }; + Rc::new(ItemContribution { + resolved_item: ritem.clone(), + resolve_diagnostics: resolved.diagnostics.clone(), + func_sig: func_sig, + svc_entries: svc_entries, + svc_local: svc_local, + item_info: build_item_info( + ritem.clone(), + env.source_indices.clone(), + module_name.clone(), + ), + }) } } -pub fn exported_coproduct_item( - mut module_path: String, - mut enum_name: String, - mut parent_index: Rc>>, +pub fn fold_module_contributions( + mut remaining: Rc>>, + mut resolved_items: Rc>>, + mut func_sigs: Rc>>, + mut svc_registry: Rc>>>>, + mut svc_locals: Rc>>, + mut item_registry: Rc>>, + mut diag_chunks: Rc>>>>, mut source_indices: Rc>>, -) -> Option> { +) -> Rc { loop { - match v1_rt::map_get(&parent_index, module_path) { + match remaining.clone().first().cloned() { None => { - break None; + break Rc::new(LocalContributionState { + resolved_items: resolved_items, + func_sigs: func_sigs, + svc_registry: svc_registry, + svc_locals: svc_locals, + item_registry: item_registry, + diag_chunks: diag_chunks, + }); } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if (authored_name_at(source_indices.clone(), item.clone()) - == enum_name.clone()) - { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); + Some(contribution) => { + let next_func_sigs = match contribution.func_sig.clone() { + Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), + None => func_sigs, + }; + let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { + v1_rt::rc_map_insert( + svc_registry, + authored_name_at( + source_indices.clone(), + contribution.resolved_item.clone(), + ), + contribution.svc_entries.clone(), + ) + } else { + svc_registry + }; + let next_svc_locals = match contribution.svc_local.clone() { + Some(binding) => { + v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) + None => svc_locals, + }; + { + let __tco_0 = Rc::new( + remaining .iter() .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == enum_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } + .skip(1 as usize) + .collect::>(), + ); + let __tco_1 = + v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); + let __tco_2 = next_func_sigs; + let __tco_3 = next_svc_registry; + let __tco_4 = next_svc_locals; + let __tco_5 = v1_rt::rc_map_insert( + item_registry, + contribution.item_info.clone().name.clone(), + contribution.item_info.clone(), + ); + let __tco_6 = + v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); + remaining = __tco_0; + resolved_items = __tco_1; + func_sigs = __tco_2; + svc_registry = __tco_3; + svc_locals = __tco_4; + item_registry = __tco_5; + diag_chunks = __tco_6; + continue; + } + } + } + } +} + +pub fn enum_parents_for_variant_in_items( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for child in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) + { + __found = true; + break; } } + __found + } { + __result.push(item); } } + __result + }) + .iter() + .cloned() + { + __result.push(authored_name_at(source_indices.clone(), item.clone())); + } + __result + }) +} + +pub fn unique_imported_variant_owner( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Option { + { + let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); + if ((parents.clone().len() as i64) == 1) { + parents.clone().first().cloned() + } else { + None } } } +pub fn is_imported_variant_owned_by( + imported_variants: Rc>, + variant_name: String, + enum_name: String, +) -> bool { + match v1_rt::map_get(&imported_variants, variant_name) { + Some(unique_parent) => (unique_parent.clone() == enum_name), + None => false, + } +} + pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { +) -> Rc> { resolved_imports.iter().cloned().fold( - init, - |acc: Rc, imp: Rc| { - let with_glob = if imp.is_all.clone() { - { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.clone().iter().cloned().fold( - acc.clone(), - |iacc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - iacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - iacc.clone() - } - }, - ) - } - } else { - acc.clone() - }; + v1_rt::rc_empty_map::(), + |acc: Rc>, imp: Rc| { imp.specific_names.clone().iter().cloned().fold( - with_glob.clone(), - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms( - nacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), + acc, + |inner: Rc>, variant_name: String| { + if v1_rt::map_contains_key(&inner, variant_name.clone()) { + inner.clone() + } else { + { + let source_items = + match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + match unique_imported_variant_owner( + variant_name.clone(), + source_items.clone(), + source_indices.clone(), + ) { + Some(parent) => v1_rt::rc_map_insert( + inner.clone(), + variant_name.clone(), + parent.clone(), + ), + None => inner.clone(), + } + } + } + }, + ) + }, + ) +} + +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain +// followers — a module re-exports its specific-name imports, so the binder +// walks the acyclic import chain to the defining module's coproduct. Replaced +// by regen's true emission in the convergence commit. +pub fn owner_of_exported_arm( + module_path: String, + arm_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && item + .children + .iter() + .cloned() + .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == arm_name) + }); + match reexport { + Some(imp) => owner_of_exported_arm( + authored_name_at(source_indices.clone(), imp), + arm_name, + parent_index, + source_indices, ), - None => nacc.clone(), - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked( - after_enum.clone(), - name.clone(), - owner.clone(), - source_indices.clone(), - module_name.clone(), + None => None, + } + } + } + } + } +} + +pub fn exported_coproduct_item( + module_path: String, + enum_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && authored_name_at(source_indices.clone(), item.clone()) == enum_name + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == enum_name) + }); + match reexport { + Some(imp) => exported_coproduct_item( + authored_name_at(source_indices.clone(), imp), + enum_name, + parent_index, + source_indices, ), - None => after_enum.clone(), + None => None, } - }, - ) - }, - ) + } + } + } + } } pub fn build_module_context( @@ -13744,21 +13677,134 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - let local_variant_fold = build_local_variants( - local.resolved_items.clone(), - env.source_indices.clone(), - module_name.clone(), + // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional + // realization of the new v1.compiler.infer dag source — replaced + // wholesale by regen output in the convergence commit. Constructor + // namespace is FLAT: local coproduct arms + direct imports' + // contributions; the binding carries the owner NODE; one arm name + // bound to two different owners = VariantCollision (per-file wall). + let insert_variant_owner_checked = |state: Rc, + arm_name: String, + owner: Rc| + -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = + authored_name_at(env.source_indices.clone(), prev.resolved.clone()); + let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); + let same_owner = prev_name == owner_name + && prev.resolved.span.file == owner.span.file + && prev.resolved.span.start == owner.span.start; + if same_owner { + state + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name, + enum1: prev_name, + enum2: owner_name, + span: owner.span.clone(), + }), + module_name.clone(), + )]), + ), + }) + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name, + resolved: owner, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } + }; + let bind_coproduct_item_arms = + |state: Rc, item: Rc| -> Rc { + item.children + .clone() + .iter() + .cloned() + .fold(state, |vacc, child| { + insert_variant_owner_checked( + vacc, + authored_name_at(env.source_indices.clone(), child.clone()), + item.clone(), + ) + }) + }; + let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), + |acc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(acc, item) + } else { + acc + } + }, ); - let variant_fold = build_imported_variants( - resolved_imports.clone(), - parent_index.clone(), - env.source_indices.clone(), - module_name.clone(), + let variant_fold = resolved_imports.clone().iter().cloned().fold( local_variant_fold, + |acc: Rc, imp: Rc| { + // Glob (is_all) imports bind the target's OWN coproduct arms only. + let with_glob = if imp.is_all { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.iter().cloned().fold( + acc, + |iacc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(iacc, item) + } else { + iacc + } + }, + ) + } else { + acc + }; + // Specific names resolve through the re-export chain to the + // defining module (owner_of_exported_arm / exported_coproduct_item). + imp.specific_names.iter().cloned().fold( + with_glob, + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms(nacc, item), + None => nacc, + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked(after_enum, name, owner), + None => after_enum, + } + }, + ) + }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13775,7 +13821,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), + Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), None => Rc::new(vec![]), }) .iter() @@ -13788,7 +13834,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name.clone(), + module_name, env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13843,7 +13889,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = (*env_result.env).clone(); + let env = env_result.env.clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13861,7 +13907,7 @@ pub fn typecheck_module( typed: Rc::new(TypedModule { module: resolved.module.clone(), items: Rc::new(vec![]), - type_env: Rc::new(env.clone()), + type_env: env.clone(), type_env_cache: env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: v1_rt::rc_empty_map::>(), @@ -13879,7 +13925,7 @@ pub fn typecheck_module( for item in module_items(resolved.module.clone()).iter().cloned() { __result.push(analyze_item( item.clone(), - Rc::new(env.clone()), + env.clone(), resolved_module_name.clone(), )); } @@ -13889,7 +13935,7 @@ pub fn typecheck_module( contributions, parent_index.clone(), resolved.resolved_imports.clone(), - Rc::new(env.clone()), + env.clone(), resolved_module_name.clone(), ); let data_locals = ctx.resolved_items.clone().iter().cloned().fold( @@ -13914,7 +13960,7 @@ pub fn typecheck_module( }, ); let infer_scope = Rc::new(InferScope { - type_env: Rc::new(env.clone()), + type_env: env.clone(), func_env: ctx.func_env.clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), @@ -13927,7 +13973,7 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push((*tir.item).clone()); + __result.push(tir.item.clone()); } __result }); @@ -13938,9 +13984,9 @@ pub fn typecheck_module( } __result }); - let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))( + let updated_func_env = populate_output_provenance( typed_items.clone(), - (*ctx.func_env).clone(), + ctx.func_env.clone(), env.clone(), data_locals.clone(), ); @@ -13960,9 +14006,9 @@ pub fn typecheck_module( uses: item.uses.clone(), body: Some(annotate_descent_evidence( item.body.clone().clone().unwrap(), - authored_name_at(source_indices.clone(), Rc::new(item.clone())), + authored_name_at(source_indices.clone(), item.clone()), item.params.clone(), - Rc::new(env.clone()), + env.clone(), data_locals.clone(), updated_func_env.clone(), )), @@ -13977,7 +14023,7 @@ pub fn typecheck_module( ident: None, }) } else { - Rc::new(item.clone()) + item.clone() }, ); } @@ -13987,17 +14033,17 @@ pub fn typecheck_module( resolved_module_name.clone(), module_imports(resolved.module.clone()), ctx.resolved_items.clone(), - (*resolved.module).clone().span.clone(), + resolved.module.clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: (*resolved.module).clone().ident_span.clone(), + ident_span: resolved.module.clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: Rc::new(env.clone()), + type_env: env.clone(), type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), @@ -14141,12 +14187,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); + let pre = binding.resolved.clone(); let result = - resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( + resolve_node(pre.clone(), env.clone(), module_name.clone()); + let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14164,7 +14210,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14205,11 +14251,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); - let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( + let pre = binding.resolved.clone(); + let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); + let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14227,7 +14273,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14359,7 +14405,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items .clone() .iter() @@ -14424,7 +14470,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14479,11 +14525,9 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().source_indices.clone(), - )) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14522,7 +14566,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().recursive_type_set.clone(), + &m.type_env.clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), + intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14562,8 +14606,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, @@ -14681,490 +14723,192 @@ pub fn typecheck_modules( v1_rt::rc_list_push(diag_chunks, parent_result.diagnostics.clone()), tc_diags, ); - remaining = __tco_0; - modules = __tco_1; - module_index = __tco_2; - item_registry = __tco_3; - diag_chunks = __tco_4; - continue; - } - } - } - } -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct StrBindingsRewireAccum { - pub str_bindings: Rc>>, - pub ancestry_str_bindings: Rc>>, -} - -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn local_authority_binding(owner: Rc, name: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values( - &(*owner.type_env).clone().bindings.clone(), - )) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .first() - .cloned() - { - Some(binding) => Some(binding.clone()), - None => None, - } -} - -pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if module_exports_type_name(m.clone(), name.clone()) { - __result.push(m); - } - } - __result - }) - .len() as i64) -} - -pub fn local_authority_for_name_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn local_authority_for_name( - modules: Rc>>, - name: String, -) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) - { - __result.push(m); - } - } - __result - }) - .last() - .cloned() - { - Some(owner) => Some(owner.clone()), - None => None, - } -} - -pub fn module_exports_type_name(m: Rc, name: String) -> bool { - ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) -} - -pub fn direct_import_exporter_count( - m: Rc, - name: String, - index: Rc>>, - source_indices: Rc>>, -) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { - if { - let path = import_module_path_at(imp.clone(), source_indices.clone()); - match v1_rt::map_get(&index, path.clone()) { - Some(parent) => module_exports_type_name(parent.clone(), name.clone()), - None => false, - } - } { - __result.push(imp); - } - } - __result - }) - .len() as i64) -} - -pub fn rewire_inherited_str_binding( - modules: Rc>>, - module_index: Rc>>, - consumer: Rc, - source_indices: Rc>>, - local_names: Rc>, - str_bindings: Rc>>, - ancestry_str_bindings: Rc>>, - name: String, -) -> Rc { - if ((v1_rt::set_contains(&local_names, name.clone()) - || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) - > 1)) - || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) - { - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } else { - match local_authority_for_name(modules.clone(), name.clone()) { - Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { - Some(canonical) => { - let ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings.clone(), - name.clone(), - canonical.clone(), - ); - let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { - Some(_) => v1_rt::rc_map_insert( - str_bindings.clone(), - name.clone(), - canonical.clone(), - ), - None => str_bindings.clone(), - }; - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - }, - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - } - } -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - { - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), m.module.clone()), - m.clone(), - ) - }, - ); - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - __result.push({ - let local_names = - Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { - v1_rt::rc_set_insert(acc, b.name.clone()) - }); - let ancestry_keys = Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().ancestry_str_bindings.clone(), - )); - let str_keys = - Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); - let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); - let rewired = inherited_keys.clone().iter().cloned().fold( - Rc::new(StrBindingsRewireAccum { - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - }), - |acc: Rc, name: String| { - rewire_inherited_str_binding( - modules.clone(), - index.clone(), - m.clone(), - source_indices.clone(), - local_names.clone(), - acc.str_bindings.clone(), - acc.ancestry_str_bindings.clone(), - name.clone(), - ) - }, - ); - Rc::new(TypedModule { - module: m.module.clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: rewired.str_bindings.clone(), - ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), - parents: (*m.type_env).clone().parents.clone(), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), - item_registry: m.item_registry.clone(), - }) - }); + remaining = __tco_0; + modules = __tco_1; + module_index = __tco_2; + item_registry = __tco_3; + diag_chunks = __tco_4; + continue; + } } - __result - }) + } } } -pub fn compiler_kernel_type_env( +pub fn import_module_path_at( + imp: Rc, source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + record_rewire_type_env_import_str_binding_call(); + fn local_authority_binding(owner: Rc, name: String) -> Option> { + owner + .type_env + .bindings + .values() + .find(|b| b.name.clone() == name) + .cloned() + } + + fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { + modules + .iter() + .filter(|m| module_exports_type_name((**m).clone(), name)) + .count() + } + + fn local_authority_for_name( + modules: Rc>>, + name: String, + ) -> Option> { + // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) + modules .iter() + .rev() + .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + } + + fn module_exports_type_name(m: Rc, name: &str) -> bool { + m.type_env + .bindings + .values() + .any(|b| b.name.as_str() == name) + } + + fn direct_import_exporter_count( + m: Rc, + name: &str, + index: &HashMap>, + source_indices: Rc>>, + ) -> usize { + module_imports(m.module.clone()) + .iter() + .filter(|imp| { + let path = import_module_path_at((*imp).clone(), source_indices.clone()); + index.get(&path).map_or(false, |parent| { + module_exports_type_name(parent.clone(), name) + }) + }) + .count() + } + + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), m.module.clone()), + m.clone(), + ) + }, + ); + + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + let local_names: std::collections::HashSet = m + .type_env + .bindings + .values() + .map(|b| b.name.clone()) + .collect(); + let mut str_bindings = m.type_env.str_bindings.clone(); + let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); + let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) .iter() + .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + .filter(|name| !local_names.contains(name)) + .collect(); + inherited_names.sort(); + for name in inherited_names { + if direct_import_exporter_count( + m.clone(), + name.as_str(), + &index, + source_indices.clone(), + ) > 1 + || global_type_exporter_count(modules.clone(), name.as_str()) > 1 + { + continue; + } + if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { + if let Some(canonical) = local_authority_binding(owner, name.clone()) { + if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { + Some(existing) => { + Rc::ptr_eq(&existing.resolved, &canonical.resolved) + && existing.name == canonical.name + } + None => false, + } { + continue; + } + ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings, + name.clone(), + canonical.clone(), + ); + if v1_rt::map_contains_key(&str_bindings, name.clone()) { + str_bindings = + v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); + } + } + } } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices, - intern_table: intern_table.clone(), - }) - } + __result.push(Rc::new(TypedModule { + module: m.module.clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: m.type_env.bindings.clone(), + str_bindings, + ancestry_str_bindings, + parents: m.type_env.parents.clone(), + recursive_types: m.type_env.recursive_types.clone(), + recursive_type_set: m.type_env.recursive_type_set.clone(), + inductive_fields: m.type_env.inductive_fields.clone(), + source_indices: m.type_env.source_indices.clone(), + intern_table: m.type_env.intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: m.func_env.clone(), + item_registry: m.item_registry.clone(), + })); + } + __result + }) } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { + record_rewire_type_env_parent_links_call(); { + let intern_table = modules + .first() + .map(|m| m.type_env.intern_table.clone()) + .unwrap_or_else(empty_intern_table); + let shared_kernel = modules + .iter() + .find_map(|m| { + m.type_env.parents.last().and_then(|kernel| { + if kernel.bindings.is_empty() { + None + } else { + Some(kernel.clone()) + } + }) + }) + .unwrap_or_else(|| { + compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) + }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { @@ -15175,25 +14919,6 @@ pub fn rewire_type_env_parent_links( ) }, ); - let shared_kernel = match modules.clone().iter().cloned().fold( - None, - |acc, m: Rc| match acc.clone() { - Some(_) => acc.clone(), - None => match (*m.type_env).clone().parents.clone().last().cloned() { - Some(kernel) => Some(kernel.clone()), - None => None, - }, - }, - ) { - Some(kernel) => kernel.clone(), - None => match modules.clone().first().cloned() { - Some(m) => compiler_kernel_type_env( - source_indices.clone(), - (*m.type_env).clone().intern_table.clone(), - ), - None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), - }, - }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { @@ -15219,25 +14944,20 @@ pub fn rewire_type_env_parent_links( } __result }); + let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - parents: v1_rt::concat( - import_parents.clone(), - Rc::new(vec![shared_kernel.clone()]), - ), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), + bindings: m.type_env.clone().bindings.clone(), + str_bindings: m.type_env.clone().str_bindings.clone(), + ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), + parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), + recursive_types: m.type_env.clone().recursive_types.clone(), + recursive_type_set: m.type_env.clone().recursive_type_set.clone(), + inductive_fields: m.type_env.clone().inductive_fields.clone(), + source_indices: m.type_env.clone().source_indices.clone(), + intern_table: m.type_env.clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), func_env: m.func_env.clone(), @@ -15277,7 +14997,7 @@ pub fn rewire_func_env_parent_links( let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), + Some(parent) => Rc::new(vec![parent.func_env.clone()]), None => Rc::new(vec![]), } }) @@ -15293,7 +15013,7 @@ pub fn rewire_func_env_parent_links( type_env: m.type_env.clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: (*m.func_env).clone().local.clone(), + local: m.func_env.clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 80801b55852..0dc55228a93 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -229,10 +229,11 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { - __result.push(b.name.clone()); - } + let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .map(|b| b.name.clone()) + .collect(); + __result.sort(); __result }); let name_set = all_names diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b8089770e47..8dc46a13d29 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,8 +83,6 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, - pub move_sites_index: Rc>>>, - pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -106,8 +104,6 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), @@ -452,7 +448,8 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child.inferred + |acc: Rc>, child: Rc| match child + .inferred .clone() .as_deref() .cloned() diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 77676a00023..dc7b6acbab3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,12 +17,82 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +use std::sync::atomic::{AtomicU64, Ordering}; + +// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). +static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); +static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); +static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); + +pub fn flatten_visible_parent_recurses() -> u64 { + FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) +} + +pub fn build_type_env_calls() -> u64 { + BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) +} + +pub fn merge_type_env_cache_calls() -> u64 { + MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_parent_links_calls() -> u64 { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_import_str_binding_calls() -> u64 { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) +} + +pub fn reset_flatten_visible_profile() { + FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); +} + +pub fn reset_type_env_lookup_profile() { + reset_flatten_visible_profile(); + BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); + MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); +} + +pub fn maybe_print_type_env_lookup_profile() { + if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { + eprintln!( + "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", + flatten_visible_parent_recurses(), + build_type_env_calls(), + merge_type_env_cache_calls(), + rewire_type_env_parent_links_calls(), + rewire_type_env_import_str_binding_calls(), + ); + } +} + +pub fn record_flatten_visible_parent_recurse() { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_build_type_env_call() { + BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_parent_links_call() { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_import_str_binding_call() { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, + #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -31,6 +101,10 @@ pub struct TypeEnv { pub intern_table: Rc, } +fn empty_type_env_parents() -> Rc>> { + Rc::new(vec![]) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -46,60 +120,6 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } -pub fn type_env_compositional_authority_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_work_count_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_key_determinism_authority() -> String { - thread_local! { - static CACHED: String = { - "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn flatten_visible_bindings_invariant() -> String { - thread_local! { - static CACHED: String = { - "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -109,34 +129,16 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn build_type_env_calls() -> i64 { - 0 -} - -pub fn merge_type_env_cache_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_parent_links_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_import_str_binding_calls() -> i64 { - 0 -} - -pub fn type_env_counter_dissolution() -> String { - thread_local! { - static CACHED: String = { - "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn record_merge_type_env_cache_call() { + MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { + record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), + // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at + // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -162,21 +164,42 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( + let mut pairs: Vec<(String, Rc)> = bindings + .values() + .map(|binding| (binding.name.clone(), binding.clone())) + .collect(); + pairs.sort_by(|a, b| a.0.cmp(&b.0)); + pairs.into_iter().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) + |acc: Rc>>, (name, binding)| { + v1_rt::rc_map_insert(acc, name, binding) + }, + ) +} + +// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value +// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). +#[allow(dead_code)] +pub fn deterministic_str_binding_map( + m: Rc>>, +) -> Rc>> { + let mut keys: Vec = m.keys().cloned().collect(); + keys.sort(); + keys.iter().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, key: &String| { + v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { + match v1_rt::map_get(&env.str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { + None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name.clone()) { - Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), + None => match intern_find(env.intern_table.clone(), name) { + Some(id) => v1_rt::map_get(&env.bindings, id), None => None, }, }, @@ -188,7 +211,7 @@ pub fn lookup_binding(env: Rc, ident: i64) -> Option> { Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env.clone(), name) + lookup_binding_by_name(env, name) } } } @@ -201,7 +224,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name) { + match intern_find(env.intern_table.clone(), name.clone()) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } @@ -240,26 +263,18 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) => fields.clone(), - None => Rc::new(vec![]), - }; - if ((local.clone().len() as i64) > 0) { - local.clone() - } else { - env.parents.clone().iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, parent: Rc| { - if ((acc.clone().len() as i64) > 0) { - acc.clone() - } else { - inductive_fields_for(parent.clone(), type_name.clone()) - } - }, - ) + match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) if !fields.is_empty() => fields.clone(), + _ => { + for parent in env.parents.iter() { + let fields = inductive_fields_for(parent.clone(), type_name.clone()); + if !fields.is_empty() { + return fields; + } + } + Rc::new(vec![]) } - }) + } } pub fn is_inductive_field( @@ -385,27 +400,12 @@ pub fn inductive_fields_list_to_map( ) } -pub fn flatten_visible_parent_recurses() -> i64 { - 0 -} - -pub fn reset_flatten_visible_profile() -> () { - {} -} - -pub fn reset_type_env_lookup_profile() -> () { - reset_flatten_visible_profile() -} - -pub fn maybe_print_type_env_lookup_profile() -> () { - {} -} - pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -469,7 +469,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings.clone(), + str_bindings: merged_bindings, ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 95a6d52a3d7..02b08953fa8 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,10 +2,12 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; +pub use crate::std_induction::SubValueRelation; +use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -174,13 +176,10 @@ pub fn item_kind(item: Rc) -> ItemKind { if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { ItemKind::FnItem } else { - if ((item.body.clone() != None) - && (item.type_annotation.clone() != None)) - { + if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { ItemKind::DataItem } else { if (item.body.clone() != None) { @@ -197,6 +196,38 @@ pub fn item_kind(item: Rc) -> ItemKind { } } +pub fn variant_locals_from_items( + items: Rc>>, + init: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + items.iter().cloned().fold( + init, + |acc: Rc>>, item: Rc| { + let is_coproduct = (item.connective.clone() == Connective::Disj); + if is_coproduct.clone() { + item.children.clone().iter().cloned().fold( + acc.clone(), + |vacc: Rc>>, child: Rc| { + let child_name = authored_name_at(source_indices.clone(), child.clone()); + v1_rt::rc_map_insert( + vacc, + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: item.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ) + } else { + acc.clone() + } + }, + ) +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 58133bfe102..ac704dae929 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -126,12 +126,12 @@ pub fn lookup_field_type_node( None => nominal_type_ref("V".to_string()), }; Some( - (*make_container_type( + make_container_type( "Witness".to_string(), value_child, ) - .ty) - .clone(), + .ty + .clone(), ) } } else { @@ -217,14 +217,18 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved.connective.clone() == Connective::Conj) - || ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone()))) - { + if (resolved.connective.clone() == Connective::Conj) { resolved.clone() } else { - receiver_type.clone() + let resolved_name = + authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone())) + { + resolved.clone() + } else { + receiver_type.clone() + } } } } @@ -499,7 +503,11 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some(make_container_type("Witness".to_string(), raw.clone()).ty.clone()) + Some( + make_container_type("Witness".to_string(), raw.clone()) + .ty + .clone(), + ) } } None => None, @@ -579,8 +587,8 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if (((*enriched.ty).clone().connective.clone() == Connective::Conj) - && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) + if ((enriched.ty.clone().connective.clone() == Connective::Conj) + && ((enriched.ty.clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 7e4b3673ab3..96d9884ceb1 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,16 +44,18 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - Rc::new((*make_map_type( + make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty) - .clone()) + .ty + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)).ty.clone() + make_container_type("List".to_string(), type_variable_node(id)) + .ty + .clone() } pub fn list_of_element(element: Rc) -> Rc { @@ -61,7 +63,9 @@ pub fn list_of_element(element: Rc) -> Rc { } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element).ty.clone() + make_container_type("Witness".to_string(), element) + .ty + .clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -123,15 +127,15 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = (*make_container_type( + let set_ty = make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty) - .clone(); - let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), Rc::new(set_ty.clone())); - let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), Rc::new(set_ty.clone())); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty.clone())); + .ty + .clone(); + let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); @@ -250,6 +254,41 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_loc".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_test_fns".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_names".to_string(), + list_of_type_variable("test_migration_debt_module_name_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_known_covered_module_is_not_debt".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_holds".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_uncovered_deletes".to_string(), + list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), + ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 4e0bf90d8ff..1dd9fc95134 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,148 +37,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), - None => acc.clone(), - } - }, - ) - } -} - -pub fn expand_scrut_from_decl( - decl: Rc, - scrut_node: Rc, - name: String, - env: Rc, -) -> Rc { - { - let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = (((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)) - && ((decl.children.clone().len() as i64) == 0)); - if decl_is_disj { - decl.clone() - } else { - if has_inferred_alias { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node, env.clone()); - substitute_type_slots( - target.clone(), - subst, - name, - env.source_indices.clone(), - ) - } - _ => scrut_node, - } - } else { - scrut_node - } - } - } -} - -pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { - { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())); - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if is_generic_use { - expand_scrut_from_decl( - decl.clone(), - scrut_node.clone(), - name.clone(), - env.clone(), - ) - } else { - { - let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = ((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)); - if def_is_disj { - decl.clone() - } else { - if has_inferred_body { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let target_is_disj = - (target.connective.clone() == Connective::Disj); - if target_is_disj { - target.clone() - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - } - } - } - None => scrut_node.clone(), - } - } -} - -pub fn expand_scrut_type_for_variant_lookup( - mut scrut_node: Rc, - mut env: Rc, -) -> Rc { - loop { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_disj = (scrut_node.connective.clone() == Connective::Disj); - let is_witness = is_witness_type_name(name); - if (is_disj || is_witness) { - break scrut_node.clone(); - } else { - match scrut_node.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let __tco_0 = target.clone(); - scrut_node = __tco_0; - continue; - } - _ => { - break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); - } - } - } - } -} - pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -469,6 +327,102 @@ pub fn variant_not_found_result( )])) } +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), + None => acc, + } + }, + ) +} + +pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { + return scrut_node.clone(); + } + if (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())) + { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if (((decl.inferred.clone() != None) + && ((decl.children.clone().len() as i64) == 0)) + && (decl.connective.clone() == Connective::NoConnective)) + { + match decl.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); + let expanded = substitute_type_slots( + target, + subst, + name.clone(), + env.source_indices.clone(), + ); + return expanded; + } + _ => scrut_node.clone(), + } + } else if (decl.connective.clone() == Connective::Disj) { + decl.clone() + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } else { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(def) => { + if (def.connective.clone() == Connective::Disj) { + def.clone() + } else if ((def.inferred.clone() != None) + && (def.connective.clone() == Connective::NoConnective)) + { + match def.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + if (target.connective.clone() == Connective::Disj) { + target + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } +} + pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 8fe704ae16a..84f1b36551f 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, - lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, + is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -117,41 +117,24 @@ pub fn lookup_unit_variant_phantom_type( } } -pub fn phantom_match_flat_scope() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - { - let direct_bindings = env.parents.clone().iter().cloned().fold( - env.str_bindings.clone(), - |acc: Rc>>, parent: Rc| { - v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) + Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), }, - ); - Rc::new(v1_rt::map_values(&direct_bindings)) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), - }, - ) - } + ) } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -196,22 +179,13 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { - thread_local! { - static CACHED: String = { - "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices, structural.clone()))) + && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -220,9 +194,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if ((((brand_name.clone() != "".to_string()) + if (((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone())) + && !is_declared_container_alias_spelling(brand_name.clone()) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -242,40 +216,38 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S && (resolved.inferred.clone() != None)) { match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - (*resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved) - .clone() - } - _ => (*resolve_node_bounded( + Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved + .clone(), + _ => resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(), + .resolved + .clone(), } } else { - (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved) + resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved .clone() }; - if ((((brand.clone() != "".to_string()) + if (((brand.clone() != "".to_string()) && (brand.clone() - != authored_name_at(source_indices.clone(), Rc::new(structural.clone())))) - && !is_declared_container_alias_spelling(brand.clone())) + != authored_name_at(source_indices.clone(), structural.clone()))) + && !is_declared_container_alias_spelling(brand.clone()) && !is_transparent_primitive_alias_rhs( - Rc::new(structural.clone()), + structural.clone(), source_indices.clone(), )) { - with_authored_identity(n.clone(), Rc::new(structural.clone())) + with_authored_identity(n.clone(), structural.clone()) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) @@ -283,15 +255,15 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = (*resolve_node_bounded( + let target_resolved = resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(); - with_authored_identity(n.clone(), Rc::new(target_resolved)) + .resolved + .clone(); + with_authored_identity(n.clone(), target_resolved) } _ => resolved.clone(), } @@ -375,61 +347,6 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { - thread_local! { - static CACHED: String = { - "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for parent in env.parents.clone().iter().cloned() { - if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), - None => false, - } { - __result.push(parent); - } - } - __result - }) - .first() - .cloned() - { - Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => Some(b.resolved.clone()), - None => None, - }, - None => None, - } -} - -pub fn resolve_paramless_generic_use_decl( - env: Rc, - n: Rc, - decl: Rc, - brand: String, -) -> Rc { - match ((n.children.clone().len() as i64) > 0) { - true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { - Some(user_decl) => user_decl.clone(), - None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) - { - true => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl, - }, - false => decl, - }, - }, - false => decl, - } -} - pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); @@ -437,8 +354,45 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { decl.clone() + } else if ((n.children.clone().len() as i64) > 0) { + // HAND-PATCH (parameterized use site prefers parameterized + // decl; replaced at regen): a use site WITH type args whose + // primary lookup lands paramless (kernel prelude shadowing + // an imported user generic, e.g. Optional) retries the + // ancestry binding for a parameterized decl. + let ancestry_generic = env.parents.iter().fold( + None, + |acc: Option>, parent: &Rc| { + if acc.is_some() { + return acc; + } + match v1_rt::map_get(&parent.str_bindings, brand.clone()) { + Some(b) => { + if ((b.resolved.params.clone().len() as i64) > 0) { + Some(b.resolved.clone()) + } else { + acc + } + } + None => acc, + } + }, + ); + match ancestry_generic { + Some(user_decl) => user_decl, + None => { + if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { + match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural.clone(), + None => decl.clone(), + } + } else { + decl.clone() + } + } + } } else { - resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) + decl.clone() } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { @@ -624,8 +578,9 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - Rc::new((*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) - .clone()) + resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) + .resolved + .clone() } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), @@ -670,7 +625,7 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -751,14 +706,14 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let base_resolved = (*base_result.resolved).clone(); + let base_resolved = base_result.resolved.clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: Rc::new(vec![Rc::new(base_resolved)]), + children: Rc::new(vec![base_resolved]), connective: n.connective.clone(), params: n.params.clone(), inferred: n.inferred.clone(), @@ -801,7 +756,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = (*rt_result.resolved).clone(); + let rt_resolved = rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -813,7 +768,7 @@ pub fn resolve_node_bounded( params: child.params.clone(), inferred: Some(Rc::new( InferredNode::Resolved { - node: Rc::new(rt_resolved.clone()), + node: rt_resolved.clone(), }, )), return_cardinality: child @@ -826,8 +781,7 @@ pub fn resolve_node_bounded( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation - .clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -844,7 +798,7 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.resolved).clone()); + __result.push(cr.resolved.clone()); } __result }); @@ -893,10 +847,10 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = (*inner_result.resolved).clone(); + let inner_resolved = inner_result.resolved.clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { - resolved: with_optional_cardinality(Rc::new(inner_resolved)), + resolved: with_optional_cardinality(inner_resolved), diagnostics: inner_diags, }) } @@ -912,8 +866,7 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) - { + if (field_child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -954,7 +907,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - (*rt_result.resolved).clone(); + rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -966,7 +919,7 @@ pub fn resolve_node_bounded( connective: field_child.connective.clone(), params: field_child.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(rt_resolved.clone()), + node: rt_resolved.clone(), })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), @@ -991,7 +944,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.resolved).clone()); + __result.push(fr.resolved.clone()); } __result }); @@ -1038,7 +991,7 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push((*vr.resolved).clone()); + __result.push(vr.resolved.clone()); } __result }); @@ -1114,7 +1067,7 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -1177,7 +1130,7 @@ pub fn resolve_node_bounded( Some(arg) => v1_rt::rc_map_insert( acc.clone(), slot_name.clone(), - Rc::new(arg.clone()), + arg.clone(), ), None => acc.clone(), } @@ -1211,15 +1164,15 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: (*target_result.resolved).clone().children.clone(), - connective: (*target_result.resolved).clone().connective.clone(), + children: target_result.resolved.clone().children.clone(), + connective: target_result.resolved.clone().connective.clone(), params: Rc::new(vec![]), - inferred: (*target_result.resolved).clone().inferred.clone(), + inferred: target_result.resolved.clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1241,7 +1194,7 @@ pub fn resolve_node_bounded( uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1344,7 +1297,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = (*key_result.resolved).clone(); + let key_resolved = key_result.resolved.clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1352,7 +1305,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = (*val_result.resolved).clone(); + let val_resolved = val_result.resolved.clone(); let val_diags = val_result.diagnostics.clone(); let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) @@ -1378,7 +1331,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(key_resolved), + node: key_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1400,7 +1353,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(val_resolved), + node: val_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1451,10 +1404,9 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = (*el_result.resolved).clone(); + let el_resolved = el_result.resolved.clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() - != None) + let el_param_name = if (child_node.inferred.clone() != None) { authored_name(env.clone(), child_node.clone()) } else { @@ -1473,7 +1425,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(el_resolved), + node: el_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1520,26 +1472,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = match n.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { node: target, .. }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = + match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: target, .. + }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) + > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1558,7 +1510,8 @@ pub fn resolve_node_bounded( == 0)) && (resolved.inferred.clone() != None)) { - match resolved.inferred + match resolved + .inferred .clone() .as_deref() .cloned() @@ -1586,14 +1539,14 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - (*resolve_node_bounded( + resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved) - .clone() + .resolved + .clone() } else { target.clone() } @@ -1616,8 +1569,7 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) - { + let n_is_error = if (n.inferred.clone() != None) { is_compiler_error( n.inferred.clone().clone().unwrap(), ) @@ -1626,14 +1578,14 @@ pub fn resolve_node_bounded( }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = - if (n.inferred.clone() != None) { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = if (n.inferred.clone() != None) + { + is_type_variable( + n.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1773,7 +1725,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), missing_generic_args_diagnostics( @@ -1797,7 +1749,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc::new(FieldResult { field: make_field_node( field_node_name_at(field.clone(), env.source_indices.clone()), - Rc::new(type_resolved), + type_resolved, field_node_cardinality(field.clone()), match default_resolved.clone() { Some(result) => Some(result.expr.clone()), @@ -1816,7 +1768,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1826,7 +1778,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> connective: authored_type.connective.clone(), params: authored_type.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(type_resolved.clone()), + node: type_resolved.clone(), })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), @@ -1841,7 +1793,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> ident: None, }) } else { - Rc::new(type_resolved.clone()) + type_resolved.clone() }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), @@ -1864,7 +1816,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> None => Rc::new(vec![]), }; let default_expr = match default_resolved.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }; Rc::new(ParamResult { @@ -1888,12 +1840,12 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( resource_use_name_at(ru.clone(), env.source_indices.clone()), - Rc::new(type_resolved), + type_resolved, ru.span.clone(), node_name_span(ru.clone()), ), @@ -1909,12 +1861,12 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( arg_name_at(arg.clone(), env.source_indices.clone()), - Rc::new(value_expr), + value_expr, arg.span.clone(), node_name_span(arg.clone()), ), @@ -1934,12 +1886,12 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(field_init.clone(), env.source_indices.clone()), - Rc::new(value_expr), + value_expr, field_init.span.clone(), node_name_span(field_init.clone()), ), @@ -1969,7 +1921,7 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = (*body_result.expr).clone(); + let body_expr = body_result.expr.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( @@ -1978,7 +1930,7 @@ pub fn resolve_match_arm( Some(result) => Some(result.expr.clone()), None => None, }, - Rc::new(body_expr), + body_expr, arm.span.clone(), ), diagnostics: v1_rt::concat(guard_diags, body_diags), @@ -2000,11 +1952,11 @@ pub fn resolve_string_part( }), StringPart::Interpolation { expr: expr, .. } => { let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = (*expr_result.expr).clone(); + let resolved_expr = expr_result.expr.clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { - expr: Rc::new(resolved_expr), + expr: resolved_expr, }), diagnostics: expr_diags, }) @@ -2049,7 +2001,7 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -2074,7 +2026,7 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.expr).clone()); + __result.push(cr.expr.clone()); } __result }); @@ -2188,7 +2140,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2284,7 +2236,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2421,7 +2373,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2467,12 +2419,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![ - (*cr.expr).clone(), - (*tr.expr).clone(), - (*r.expr).clone(), - ]), - None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), + Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( @@ -2508,8 +2456,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), - None => Rc::new(vec![(*vr.expr).clone()]), + Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![vr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( @@ -2558,7 +2506,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2598,7 +2546,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2733,7 +2681,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2769,7 +2717,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2908,11 +2856,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![ - br.expr.clone(), - sr.expr.clone(), - er.expr.clone(), - ]), + Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -3084,7 +3028,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding.clone(), + tp_binding, ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3106,7 +3050,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push((*pr.param).clone()); + __result.push(pr.param.clone()); } __result }); @@ -3126,21 +3070,17 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) env.clone(), module_name.clone(), ), - _ => resolve_optional_node( - item.inferred.clone(), - env.clone(), - module_name.clone(), - ), + _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), } } else { resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; - let ret_resolved = (*ret_result.resolved).clone(); + let ret_resolved = ret_result.resolved.clone(); let ret_diags = ret_result.diagnostics.clone(); let resolved_ret = if (item.inferred.clone() == None) { None } else { - Some(Rc::new(InferredNode::Resolved { node: Rc::new(ret_resolved) })) + Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) }; let use_results = Rc::new({ let mut __result = Vec::new(); @@ -3156,7 +3096,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push((*ur.resource_use).clone()); + __result.push(ur.resource_use.clone()); } __result }); @@ -3182,7 +3122,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_body = if (item.body.clone() == None) { None } else { - Some((*body_resolved.expr).clone()) + Some(body_resolved.expr.clone()) }; let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) @@ -3204,7 +3144,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_anno = if (item.type_annotation.clone() == None) { None } else { - Some((*anno_resolved.resolved).clone()) + Some(anno_resolved.resolved.clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); let transport_resolved = if (item.transport.clone() == None) { @@ -3222,7 +3162,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_transport = if (item.transport.clone() == None) { None } else { - Some((*transport_resolved.transport).clone()) + Some(transport_resolved.transport.clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3239,7 +3179,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -3283,7 +3223,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: child.type_annotation.clone(), is_self_recursive: false, @@ -3299,9 +3239,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) - && (item.transport.clone() == None)) - { + if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3341,7 +3279,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: field.type_annotation.clone(), is_self_recursive: false, @@ -3359,7 +3297,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.item).clone()); + __result.push(fr.item.clone()); } __result }); @@ -3414,7 +3352,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.item).clone()); + __result.push(cr.item.clone()); } __result }); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 8d0917f731a..76923b77bc0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,7 +210,7 @@ pub fn expand_transitive_services_once( registry: Rc>>, ) -> Rc>> { modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { let has_no_body = (item.body.clone() == None); @@ -218,7 +218,7 @@ if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 5d4fde8c998..ef23eba9abf 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -498,8 +498,7 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) - { + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index e4524ca2d05..27e0642597b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -928,13 +928,13 @@ pub fn instantiate_algebra_type( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))(param_nodes, (*rb.ty).clone()), + ty: make_callable_type(param_nodes, rb.ty.clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,7 +962,7 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -979,10 +979,10 @@ pub fn instantiate_algebra_field( source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))( + algebra_method_field( template.name.clone(), param_types.clone(), - (*return_b.ty).clone(), + return_b.ty.clone(), ) } else { algebra_value_field(template.name.clone(), return_b.ty.clone()) @@ -1017,7 +1017,7 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1551,7 +1551,7 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1575,7 +1575,7 @@ pub fn apply_type_substitution( for pn in param_nodes.iter().cloned() { __result.push(make_param_node( "_".to_string(), - Rc::new(pn.clone()), + pn.clone(), None, no_span(), no_span(), @@ -2291,7 +2291,8 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left.inferred + match left + .inferred .clone() .as_deref() .cloned() @@ -2299,7 +2300,8 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right.inferred + }) => match right + .inferred .clone() .as_deref() .cloned() @@ -2639,11 +2641,7 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match (*m.field_node).clone().inferred - .clone() - .as_deref() - .cloned() - { + Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { match rt.inferred.clone().as_deref().cloned() { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 5e140789267..0da15e2a8e5 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -194,10 +194,7 @@ pub fn normalize_graph( __result.extend( (*check_bare_containers( item.clone(), - authored_name_at( - source_indices.clone(), - m.module.clone(), - ), + authored_name_at(source_indices.clone(), m.module.clone()), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 0c41f844575..160e9fc850f 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,39 +690,14 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn whole_value_borrow_count(usage: Rc) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for c in usage.consumers.clone().iter().cloned() { - if match c.kind.clone() { - EdgeKind::Read => true, - EdgeKind::Threaded => true, - _ => false, - } { - __result.push(c); - } - } - __result - }) - .len() as i64) -} - -pub fn build_movable_set( - proof: Rc, - param_names: Rc>, -) -> Rc> { +pub fn build_movable_set(proof: Rc) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((match (*make_decision(usage.clone())).clone() { - OwnershipDecision::SoleOwner { .. } => true, - _ => false, - } && (whole_value_borrow_count(usage.clone()) == 0)) - && (is_owned_local(usage.binding_kind.clone()) - || v1_rt::set_contains(¶m_names, usage.name.clone()))) + if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) { __result.push(usage); } @@ -1258,337 +1233,6 @@ pub fn analyze_ownership( } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct LiveState { - pub name: String, - pub whole: bool, - pub any_field: bool, - pub fields: Rc>, -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct MoveLicenseAccum { - pub live: Rc>>, - pub licensed: Rc>, -} - -pub fn move_site_key(name: String, span_start: i64) -> String { - v1_rt::concat( - v1_rt::concat(name, "@".to_string()), - (span_start).to_string(), - ) -} - -pub fn empty_live_state(name: String) -> Rc { - Rc::new(LiveState { - name: name, - whole: false, - any_field: false, - fields: v1_rt::rc_empty_set::(), - }) -} - -pub fn live_state_of(acc: Rc, name: String) -> Rc { - match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st.clone(), - None => empty_live_state(name.clone()), - } -} - -pub fn record_whole_use_site( - acc: Rc, - name: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !st.any_field.clone()); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: true, - any_field: st.any_field.clone(), - fields: st.fields.clone(), - }), - ), - licensed: licensed, - }) - } -} - -pub fn record_field_use_site( - acc: Rc, - name: String, - field: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !v1_rt::set_contains(&st.fields.clone(), field.clone())); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: st.whole.clone(), - any_field: true, - fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), - }), - ), - licensed: licensed, - }) - } -} - -pub fn merge_live_states(a: Rc, b: Rc) -> Rc { - Rc::new(LiveState { - name: a.name.clone(), - whole: (a.whole.clone() || b.whole.clone()), - any_field: (a.any_field.clone() || b.any_field.clone()), - fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), - }) -} - -pub fn merge_branch_licenses(branches: Rc>>) -> Rc { - branches.iter().cloned().fold( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - |acc: Rc, br: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); - { - let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) - .iter() - .cloned() - .fold( - acc.live, - |lm: Rc>>, k: String| { - let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { - Some(s) => s.clone(), - None => empty_live_state(k.clone()), - }; - match v1_rt::map_get(&lm, k.clone()) { - Some(a_st) => v1_rt::rc_map_insert( - lm.clone(), - k.clone(), - merge_live_states(a_st.clone(), b_st.clone()), - ), - None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), - } - }, - ); - let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) - .iter() - .cloned() - .fold(acc.licensed, |l: Rc>, k: String| { - v1_rt::rc_map_insert(l, k.clone(), true) - }); - Rc::new(MoveLicenseAccum { - live: live_merged.clone(), - licensed: lic_merged.clone(), - }) - } - }, - ) -} - -pub fn license_walk( - acc: Rc, - texpr: Rc, - in_capture: bool, - si: Rc>>, -) -> Rc { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*texpr.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_whole_use_site( - acc.clone(), - expr_var_name_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - ExprData::ExprLiteral { value: _, .. } => acc.clone(), - ExprData::ExprFieldAccess { .. } => { - let base_node = field_access_base(texpr.clone()); - match (*base_node.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_field_use_site( - acc.clone(), - expr_var_name_at(base_node.clone(), si.clone()), - field_access_field_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - _ => license_walk( - acc.clone(), - base_node.clone(), - in_capture.clone(), - si.clone(), - ), - } - } - ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }), - ExprData::ExprMethodCall { .. } => { - let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }); - license_walk( - args_acc, - method_receiver(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprIf => { - let t_acc = license_walk( - acc.clone(), - if_then_branch(texpr.clone()), - in_capture.clone(), - si.clone(), - ); - let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => { - license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) - } - None => acc.clone(), - }; - let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); - license_walk( - merged, - if_condition(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprMatch => { - let branch_accs = Rc::new({ - let mut __result = Vec::new(); - for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { - __result.push(license_walk( - acc.clone(), - arm_body(arm_node.clone()), - in_capture.clone(), - si.clone(), - )); - } - __result - }); - let merged = merge_branch_licenses(branch_accs); - license_walk( - merged, - match_scrutinee(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprLet => { - let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), - None => acc.clone(), - }; - license_walk( - body_acc, - let_value(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprLambda => { - license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) - } - ExprData::ExprForEach => { - let body_acc = - license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); - license_walk( - body_acc, - foreach_collection(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, field: Rc| { - license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) - }), - _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - } - }) -} - -pub fn build_move_site_licenses( - body: Rc, - si: Rc>>, -) -> Rc> { - { - let walked = license_walk( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - body, - false, - si, - ); - walked.licensed.clone() - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 0858d6d4efe..b2340d2e960 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; +use crate::v1_std_core::CompilerDiagnostic::ParseError; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,11 +91,7 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream - .all - .clone() - .get((stream.pos.clone()) as usize) - .cloned() + stream.all.clone().get(stream.pos.clone() as usize).cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -3504,11 +3500,11 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = (*r.variant).clone(); + let first_variant = r.variant.clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), - Rc::new(vec![Rc::new(first_variant)]), + Rc::new(vec![first_variant]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -4303,7 +4299,7 @@ pub fn parse_positional_variant_type_fields( Cardinality::Required, None, None, - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4714,8 +4710,8 @@ pub fn parse_callable_param_types( "".to_string(), r.type_expr.clone(), None, - (*r.type_expr).clone().span.clone(), - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), + r.type_expr.clone().span.clone(), ); acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4762,9 +4758,9 @@ pub fn finish_type_expr_from_name( if has_err(r.err.clone()) { return r.clone(); } - let first_arg = (*r.type_expr).clone(); + let first_arg = r.type_expr.clone(); let type_args = - collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![Rc::new(first_arg)])); + collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { return Rc::new(TypeResult { type_expr: dummy_te.clone(), @@ -5094,7 +5090,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let f = make_field_node( name, - Rc::new(te.clone()), + te.clone(), te.return_cardinality.clone(), None, from_key, @@ -5337,7 +5333,7 @@ pub fn parse_fn_after_kw( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5347,7 +5343,7 @@ pub fn parse_fn_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5439,7 +5435,7 @@ pub fn parse_fn_body_from_prefix( err: body_result.err.clone(), }); } - let body = (*body_result.expr).clone(); + let body = body_result.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5449,7 +5445,7 @@ pub fn parse_fn_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5671,7 +5667,7 @@ pub fn parse_block_item_after_kw( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5681,7 +5677,7 @@ pub fn parse_block_item_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5741,7 +5737,7 @@ pub fn parse_block_body_from_prefix( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5751,7 +5747,7 @@ pub fn parse_block_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5936,23 +5932,23 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); retry = __tco_0; continue; } @@ -6879,49 +6875,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), + let h = match (*r3.expr.clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -7060,7 +7056,7 @@ pub fn parse_shell_fields( }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7166,7 +7162,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7670,7 +7666,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some((*r.transport).clone()); + let __tco_2 = Some(r.transport.clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -8136,7 +8132,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = (*r.expr).clone(); + let code = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8164,7 +8160,7 @@ pub fn parse_exit_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(Rc::new(code), ctx.source_indices.clone()); + let code_str = status_expr_to_str(code, ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( @@ -8174,10 +8170,10 @@ pub fn parse_exit_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8463,7 +8459,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8482,7 +8478,7 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let status_str = status_expr_to_str(status, ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( @@ -8492,10 +8488,10 @@ pub fn parse_response_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8612,7 +8608,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8631,7 +8627,7 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = (*r3.expr).clone(); + let body = r3.expr.clone(); let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), @@ -8641,9 +8637,9 @@ pub fn parse_mock_response_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let status_str = status_expr_to_str(status, ctx.source_indices.clone()); let prop_name = v1_rt::concat("mock_".to_string(), status_str); - let entry = make_field_init_node(prop_name, Rc::new(body), make_span(0, 0), make_span(0, 0)); + let entry = make_field_init_node(prop_name, body, make_span(0, 0), make_span(0, 0)); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), @@ -8862,8 +8858,7 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = - v1_rt::rc_list_push(capabilities, r.capability.clone()); + let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -9479,7 +9474,7 @@ pub fn parse_data_after_kw( err: r.err.clone(), }); } - let te = (*r.type_expr).clone(); + let te = r.type_expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r.err.clone()) { return Rc::new(ItemResult { @@ -9511,7 +9506,7 @@ pub fn parse_data_after_kw( connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), - type_annotation: Some(Rc::new(te)), + type_annotation: Some(te), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -9676,7 +9671,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, Rc::new(type_expr), None, start_span.clone(), name_span); + let p = make_param_node(name, type_expr, None, start_span.clone(), name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -10038,7 +10033,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc Some((*r3.expr).clone()), + EatResult::EatConsumed { .. } => Some(r3.expr.clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { @@ -10169,8 +10164,8 @@ pub fn parse_expr_bp( if has_err(r.err.clone()) { return r.clone(); } - let lhs = (*r.expr).clone(); - parse_expr_loop(r.tokens.clone(), r.ctx.clone(), Rc::new(lhs), min_bp) + let lhs = r.expr.clone(); + parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10204,10 +10199,10 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = (*post.expr).clone(); + let __tco_2 = post.expr.clone(); tokens = __tco_0; ctx = __tco_1; - lhs = Rc::new(__tco_2); + lhs = __tco_2; continue; } } else { @@ -10275,10 +10270,10 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = (*r.expr).clone(); + let __tco_2 = r.expr.clone(); tokens = __tco_0; ctx = __tco_1; - lhs = Rc::new(__tco_2); + lhs = __tco_2; continue; } } else { @@ -11396,7 +11391,7 @@ pub fn parse_index_or_slice( err: r.err.clone(), }); } - let first_expr = (*r.expr).clone(); + let first_expr = r.expr.clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11410,7 +11405,7 @@ pub fn parse_index_or_slice( err: r.err.clone(), }); } - let end_expr = (*r.expr).clone(); + let end_expr = r.expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11423,7 +11418,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![base, Rc::new(first_expr), Rc::new(end_expr)]), + Rc::new(vec![base, first_expr, end_expr]), None, span, ), @@ -11446,7 +11441,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base, Rc::new(first_expr)]), + Rc::new(vec![base, first_expr]), None, span, ), @@ -11581,8 +11576,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(condition), Rc::new(then_branch)]), + Rc::new(vec![condition, then_branch]), None, span, ), @@ -12869,7 +12863,7 @@ pub fn parse_for(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index d3042fd1aa4..a0826e3e1bf 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -229,6 +229,12 @@ pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() } +pub fn sorted_map_keys(m: &HashMap) -> Vec { + let mut keys = map_keys(m); + keys.sort(); + keys +} + pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -329,6 +335,40 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. +// take_owned_counted: the fail-closed replacement for the silent +// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: +// a failure arm must refuse or be counted, never silently widen). The ownership +// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose +// per-site frequency must stay observable, so the clone arm counts per emitted +// site (site = ":" of the use-site the emitter rewrote). +thread_local! { + static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = + std::cell::RefCell::new(HashMap::new()); +} + +pub fn take_owned_counted(x: Rc, site: &'static str) -> T { + Rc::try_unwrap(x).unwrap_or_else(|rc| { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); + (*rc).clone() + }) +} + +pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| { + let mut v: Vec<(String, u64)> = m + .borrow() + .iter() + .map(|(site, n)| (site.to_string(), *n)) + .collect(); + v.sort(); + v + }) +} + +pub fn reset_take_owned_clone_fallbacks() { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); +} + pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From eb6214e54af64646e1381d71c5458f998811aed2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:20:18 +0000 Subject: [PATCH 16/27] Wall from gen-2 adjudication: per-site moves refuse match-bound / function / variant bindings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Differential gen-1 vs gen-2 (identical scope + debt patches): zero E0382 across the corpus, ~10% emitted-clone reduction, silent fold fallback replaced by located take_owned_counted — and exactly one defect class of mine: a match-bound reference binding (borrow-pattern &T) licensed at last use emitted the bare ident, losing the deref its .clone() used to perform. emit_var_ref now refuses per-site moves for MatchBoundBinding/FunctionValueBinding/ VariantValueBinding (per-name movable already excluded them). Verdict and RED control recorded in the design doc. Co-Authored-By: Claude Fable 5 --- docs/plans/emitter-ownership-defork.md | 23 +++++++++++++++++++++++ src/v1/05_emit_rust.dag | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md index 0d2833ca258..4c73f718544 100644 --- a/docs/plans/emitter-ownership-defork.md +++ b/docs/plans/emitter-ownership-defork.md @@ -124,6 +124,29 @@ Emitter changes (all *readers* of the proof): (`analyze_single_fold` stops being consulted at emit time — the proof rows in `OwnershipProof.fold_acc_unwrap` already exist and become the only surface). +## Gen-2 adjudication verdict (2026-07-05, pre-restoration seed, differential) + +Method: gen-1 (old binary emitting this corpus) vs gen-2 (gen-1 binary — which runs this +branch's emit logic — re-emitting the corpus), both installed at identical compiler-file +scope over the committed std/extdeps periphery, with identical mechanical debt patches +(the deref-boxing and Rc-shape classes tracked by the restoration lane). Receipts in the +session scratchpad (`gen1-errors.txt`, `gen2-errors.txt`, `gen2-final-state`). + +- **Zero E0382** (use-after-move / borrow-of-moved) in gen-2 — the per-site last-use + licenses moved thousands of sites without a single ownership violation. +- Emitted-clone counts drop ~10%: `infer.rs` 4768→4294, `emit_rust.rs` 6543→5805, + `ownership.rs` 407→361, `resolve.rs` 157→145. +- The silent fold fallback is **gone from emitted output**: `unwrap_or_else(|rc| + (*rc).clone())` 2→0 in `ownership.rs`, replaced by located `take_owned_counted` calls; + gen-2's `v1_rt.rs` carries the counted helper from the template. +- Exactly one defect class was mine (+20 errors over the 112-error pre-existing-drift + control, all one shape): a **match-bound reference binding** (`&i64`/`&String` from + borrow patterns) licensed at its last use emitted the bare ident, but the `.clone()` it + replaced was doubling as the deref. Wall (landed here): `emit_var_ref` refuses per-site + moves for `MatchBoundBinding` / `FunctionValueBinding` / `VariantValueBinding` — + per-name `movable` already excluded them via `is_owned_local`. RED control at next + regen: the `(n > 0)` sites in `complexity.rs` (gen-1: 0, gen-2: 3) must disappear. + ## §5 conversion of the fallback [lands with increment 2, first in sequence] Replace the emitted `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` with a runtime diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 02a319a5151..83be92ebb25 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4656,7 +4656,13 @@ fn emit_var_ref(name: String, binding_kind: VarBindingKind?, resolved_type: Infe else if name == "true" || name == "false" { emit_keyword(key: name, target: Rust) } else { - let moves_by_value = set_contains(emit_info.movable, name) || move_licensed_at_site(emit_info: emit_info, name: name, use_span: use_span) + let site_move_kind_allowed = match binding_kind { + Present { value: MatchBoundBinding } => false + Present { value: FunctionValueBinding } => false + Present { value: VariantValueBinding { parent_enum: _ } } => false + _ => true + } + let moves_by_value = set_contains(emit_info.movable, name) || (site_move_kind_allowed && move_licensed_at_site(emit_info: emit_info, name: name, use_span: use_span)) let sharing = language_spec(target: Rust).sharing let variant_parent = effective_variant_parent(name: name, binding_kind: binding_kind, resolved_type: resolved_type, emit_info: emit_info, source_indices: source_indices) let ref_str = match variant_parent { From f0311665c08c302e7481a2777195cd685e59973b Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:25:44 +0000 Subject: [PATCH 17/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_compile.rs | 17 +- src/v1/stage0/src/v1_compiler_complexity.rs | 307 +- src/v1/stage0/src/v1_compiler_emit.rs | 101 +- .../src/v1_compiler_emit_core_support.rs | 17 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 28 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 32 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 758 ++-- src/v1/stage0/src/v1_compiler_infer.rs | 3868 +++++++++-------- src/v1/stage0/src/v1_compiler_infer_access.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 9 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 7 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 248 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 43 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 46 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 57 +- .../stage0/src/v1_compiler_infer_patterns.rs | 238 +- .../stage0/src/v1_compiler_infer_resolve.rs | 434 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 3 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 60 +- src/v1/stage0/src/v1_compiler_normalize.rs | 7 +- src/v1/stage0/src/v1_compiler_ownership.rs | 360 +- src/v1/stage0/src/v1_compiler_parse.rs | 340 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 40 - 25 files changed, 3925 insertions(+), 3105 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 1c1e8ecd469..bd68c32eb6e 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -167,7 +167,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - m.type_env.clone().source_indices.clone(), + (*m.type_env).clone().source_indices.clone(), item.clone(), ), body: item.body.clone().clone().unwrap(), @@ -232,12 +232,12 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) }, ) } @@ -1891,7 +1894,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref(module.module.clone(), key_to_id.clone()), + serialize_node_ref((*module.module).clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2428,7 +2431,7 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - m.module.clone(), + (*m.module).clone(), )); } __result diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 368276eb3bc..182e9e48cc2 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -1372,7 +1372,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1393,7 +1393,7 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), empty_parser_progress_env(), proven.clone(), @@ -1671,7 +1671,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - entry.body.clone(), + (*entry.body).clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -2207,7 +2207,11 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), + recursive_measure_param_names( + (*entry.body).clone(), + entry.params.clone(), + si.clone(), + ), ), None => acc.clone(), }, @@ -5753,7 +5757,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), local_func_set.clone(), si.clone(), )) @@ -6474,7 +6478,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - entry.body.clone(), + (*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6482,7 +6486,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - entry.body.clone(), + (*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6575,8 +6579,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6650,15 +6654,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6732,8 +6736,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6781,7 +6785,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6836,7 +6840,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6875,7 +6879,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - entry.body.clone(), + (*entry.body).clone(), name.clone(), si.clone(), ); @@ -7212,12 +7216,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - entry.body.clone(), + (*entry.body).clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7546,7 +7550,7 @@ pub fn resolve_callback_cost( fn_ref.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7555,7 +7559,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7566,7 +7570,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7579,7 +7583,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -7612,7 +7616,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - body_result.summary.clone().work.clone(), + (*body_result.summary.clone().work).clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7631,12 +7635,12 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: body_result.table.clone(), + table: (*body_result.table).clone(), }) } CostShape::ShapeSortBody => { @@ -7646,7 +7650,7 @@ pub fn cost_of_method_by_shape( la.clone(), func_index, scc_index, - recv_r.table.clone(), + (*recv_r.table).clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7658,14 +7662,14 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { base: 2, argument: size.clone(), }); - let per_comparison = key_result.summary.clone().work.clone(); + let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, @@ -7680,12 +7684,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: key_result.table.clone(), + table: (*key_result.table).clone(), }) } CostShape::ShapeLinearScan => { @@ -7708,28 +7712,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), } } @@ -8553,7 +8557,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - lr.table.clone(), + (*lr.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8561,23 +8565,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - lr.summary.clone().work.clone(), + (*lr.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().work.clone(), + (*rr.summary.clone().work).clone(), ), ), span: cost_seq( - lr.summary.clone().span.clone(), + (*lr.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - rr.summary.clone().span.clone(), + (*rr.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: rr.table.clone(), + table: (*rr.table).clone(), }) } ExprData::ExprCall { .. } => { @@ -8610,14 +8614,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: callee_result.table.clone(), + table: (*callee_result.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8625,34 +8629,34 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - args_result.summary.clone().work.clone(), - callee_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), + (*callee_result.summary.clone().work).clone(), ), span: cost_seq( - args_result.summary.clone().span.clone(), - callee_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), + (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } ExprData::ExprMethodCall { @@ -8699,17 +8703,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), })), } } @@ -8727,14 +8731,14 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: recv_r.table.clone(), + table: (*recv_r.table).clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8742,40 +8746,40 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: (*ar.table).clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - recv_r.summary.clone().work.clone(), + (*recv_r.summary.clone().work).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().work.clone(), + (*args_result.summary.clone().work).clone(), ), ), span: cost_seq( - recv_r.summary.clone().span.clone(), + (*recv_r.summary.clone().span).clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - args_result.summary.clone().span.clone(), + (*args_result.summary.clone().span).clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: args_result.table.clone(), + table: (*args_result.table).clone(), }) } } @@ -8801,7 +8805,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: s_r.table.clone(), + table: (*s_r.table).clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8810,7 +8814,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - acc.result.clone().table.clone(), + (*(*acc.result).clone().table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8819,21 +8823,21 @@ pub fn cost_of_expr( result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), + (*(*acc.result).clone().summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), + (*(*acc.result).clone().summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: ar.table.clone(), + table: (*ar.table).clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![ar.summary.clone().work.clone()]), + Rc::new(vec![(*ar.summary.clone().work).clone()]), ), }) }, @@ -8841,23 +8845,29 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - s_r.summary.clone().work.clone(), + (*s_r.summary.clone().work).clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - s_r.summary.clone().span.clone(), - Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), + (*s_r.summary.clone().span).clone(), + Rc::new(vec![ + (*(*arms_accum.result).clone().summary.clone().span).clone() + ]), ), - output_size: arms_accum - .result + output_size: (*arms_accum.result) .clone() .summary .clone() .output_size .clone(), - certainty: arms_accum.result.clone().summary.clone().certainty.clone(), + certainty: (*arms_accum.result) + .clone() + .summary + .clone() + .certainty + .clone(), }), - table: arms_accum.result.clone().table.clone(), + table: (*(*arms_accum.result).clone().table).clone(), }) } ExprData::ExprIf => { @@ -8876,7 +8886,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8887,14 +8897,14 @@ pub fn cost_of_expr( eb.clone(), func_index.clone(), scc_index.clone(), - t_r.table.clone(), + (*t_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: er.table.clone(), + table: (*er.table).clone(), }) } None => Rc::new(SummaryResult { @@ -8904,29 +8914,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: t_r.table.clone(), + table: (*t_r.table).clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - c_r.summary.clone().work.clone(), + (*c_r.summary.clone().work).clone(), Rc::new(vec![ - t_r.summary.clone().work.clone(), - e_result.summary.clone().work.clone(), + (*t_r.summary.clone().work).clone(), + (*e_result.summary.clone().work).clone(), ]), ), span: cost_conditional( - c_r.summary.clone().span.clone(), + (*c_r.summary.clone().span).clone(), Rc::new(vec![ - t_r.summary.clone().span.clone(), - e_result.summary.clone().span.clone(), + (*t_r.summary.clone().span).clone(), + (*e_result.summary.clone().span).clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: e_result.table.clone(), + table: (*e_result.table).clone(), }) } ExprData::ExprLet => { @@ -8946,7 +8956,7 @@ pub fn cost_of_expr( b.clone(), func_index.clone(), scc_index.clone(), - v_r.table.clone(), + (*v_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8954,17 +8964,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - v_r.summary.clone().work.clone(), - b_r.summary.clone().work.clone(), + (*v_r.summary.clone().work).clone(), + (*b_r.summary.clone().work).clone(), ), span: cost_seq( - v_r.summary.clone().span.clone(), - b_r.summary.clone().span.clone(), + (*v_r.summary.clone().span).clone(), + (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: b_r.table.clone(), + table: (*b_r.table).clone(), }) } None => v_r.clone(), @@ -8985,7 +8995,7 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8993,17 +9003,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - sr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*sr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - sr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: sr.table.clone(), + table: (*sr.table).clone(), }) }, ), @@ -9023,22 +9033,23 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - c_r.table.clone(), + (*c_r.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = + cost_loop(binder, size.clone(), (*bd_r.summary.clone().work).clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), + work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), + span: cost_seq((*c_r.summary.clone().span).clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: bd_r.table.clone(), + table: (*bd_r.table).clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9056,7 +9067,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9064,17 +9075,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9093,7 +9104,7 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9101,17 +9112,17 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: cr.table.clone(), + table: (*cr.table).clone(), }) }, ), @@ -9169,7 +9180,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - entry.body.clone(), + (*entry.body).clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9188,12 +9199,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), scc_members.clone(), ), span: bounded_scc_cost( t.clone(), - result.summary.clone().span.clone(), + (*result.summary.clone().span).clone(), scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9203,12 +9214,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - result.summary.clone().work.clone(), + (*result.summary.clone().work).clone(), func_name.clone(), ), span: bounded_recursive_cost( t.clone(), - result.summary.clone().span.clone(), + (*result.summary.clone().span).clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9219,13 +9230,16 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost(bounded.work.clone()), - span: simplify_cost(bounded.span.clone()), + work: simplify_cost((*bounded.work).clone()), + span: simplify_cost((*bounded.span).clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = - cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); + let final_table = cache_summary( + (*result.table).clone(), + func_name.clone(), + simplified.clone(), + ); Rc::new(SummaryResult { summary: simplified.clone(), table: final_table, @@ -9591,7 +9605,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9620,7 +9634,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - entry.body.clone(), + (*entry.body).clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9720,12 +9734,13 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) + if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) + > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - entry.body.clone(), + (*entry.body).clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9798,12 +9813,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - acc.table.clone(), + (*acc.table).clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity(sr.summary.clone().work.clone()); + let class_str = classify_complexity((*sr.summary.clone().work).clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9811,12 +9826,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { + let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason(sr.summary.clone().work.clone()), + reason: extract_unknown_reason((*sr.summary.clone().work).clone()), span: entry.span.clone(), })]), ) @@ -9845,7 +9860,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - sr.table.clone(), + (*sr.table).clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index e7c5382b4eb..b79a0b20400 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -594,13 +594,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: typed_module.type_env.clone(), - func_env: typed_module.func_env.clone(), + type_env: (*typed_module.type_env).clone(), + func_env: (*typed_module.func_env).clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -620,7 +620,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc, name: String, ) -> Option> { - lookup_func_sig(scope.func_env.clone(), name) + lookup_func_sig((*scope.func_env).clone(), name) } pub fn typed_named_arg_matches( @@ -672,7 +672,10 @@ pub fn order_typed_call_args( let has_unnamed = { let mut __found = false; for arg in args.clone().iter().cloned() { - if (arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()) == None) + if (arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) == None) { __found = true; break; @@ -691,7 +694,7 @@ pub fn order_typed_call_args( |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -707,7 +710,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), true, ) @@ -721,7 +724,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -739,7 +742,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -2541,12 +2544,15 @@ pub fn emit_shared_tco_expr( mut emit_default_return: impl Fn(Rc) -> String + Clone, ) -> String { loop { - let si = frame.scope.clone().type_env.clone().source_indices.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + let si = (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(); + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { + if (expr_call_func_at((*frame.expr).clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: frame.expr.clone().children.clone(), + args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2555,7 +2561,7 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value(frame.expr.clone()); + let inner = return_value((*frame.expr).clone()); { let __tco_0 = Rc::new(TcoFrame { expr: inner, @@ -2621,7 +2627,11 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); + let val_str = recurse_expr( + (*frame.expr).clone(), + frame.scope.clone(), + frame.depth.clone(), + ); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2635,15 +2645,18 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = recurse_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2670,11 +2683,11 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2795,14 +2808,17 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( @@ -2832,9 +2848,9 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { @@ -2936,7 +2952,10 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - input.scope.clone().type_env.clone().source_indices.clone(), + (*input.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) }, |frame| { @@ -3111,7 +3130,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3211,10 +3230,10 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), @@ -3442,7 +3461,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -5245,7 +5264,7 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = scope.type_env.clone().source_indices.clone(); + let source_indices = (*scope.type_env).clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -5733,7 +5752,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5753,7 +5772,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = scope.type_env.clone().source_indices.clone(); + let fa_si = (*scope.type_env).clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index e384a9d4951..39ad3967ac0 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -585,7 +585,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -462,9 +462,9 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = typed_module.type_env.clone().source_indices.clone(); + let si = (*typed_module.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( @@ -695,7 +695,7 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_go_type_def_from_connective(item.clone(), env.clone()) @@ -1141,7 +1141,7 @@ pub fn emit_go_fn_def( scope: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1255,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1388,7 +1388,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1800,7 +1800,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index ddb3cc3f4a9..af3d0bda615 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,16 +117,16 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -187,8 +187,8 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -364,9 +364,9 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); @@ -582,7 +582,7 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_py_type_def_from_connective(item.clone(), env.clone()) @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, ) @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b45fa7ffa52..393558247b1 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, - collect_callable_refs, + analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, + build_read_only_params, collect_callable_refs, move_site_key, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,11 +1401,6 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { - if let Some(host) = - rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) - { - return host; - } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2608,8 +2603,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2625,8 +2620,10 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = - authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at( + (*tm.type_env).clone().source_indices.clone(), + item.clone(), + ); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2662,8 +2659,8 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2682,21 +2679,21 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), item.clone(), ), item.clone(), ) }, ); - module_imports(typed_module.module.clone()) + module_imports((*typed_module.module).clone()) .iter() .cloned() .fold( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2704,7 +2701,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), ) .iter() .cloned() @@ -3251,12 +3248,14 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, + pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, + pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3280,7 +3279,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), + move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3367,7 +3371,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: ownership.move_sites_index.clone(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3437,8 +3448,8 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3446,7 +3457,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3482,16 +3493,16 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -3517,8 +3528,10 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3669,6 +3682,8 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: base_info.move_sites_index.clone(), + move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3697,12 +3712,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); let exported = get_exported_names( - tm.module.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.module).clone(), + (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3727,17 +3742,17 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ @@ -3746,7 +3761,7 @@ pub fn emit_module_full( __result.extend( (*import_specific_names_at( imp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) .iter() .cloned(), @@ -3763,11 +3778,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __result.push(item); @@ -3778,7 +3793,7 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); @@ -3789,7 +3804,7 @@ pub fn emit_module_full( local_type_names, export_sets.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3798,14 +3813,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3866,7 +3881,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3881,7 +3896,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name(scope.type_env.clone(), item.clone()), + authored_name((*scope.type_env).clone(), item.clone()), ), "::*;".to_string(), )); @@ -3902,18 +3917,18 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name(scope.type_env.clone(), item.clone())); + __result.push(authored_name((*scope.type_env).clone(), item.clone())); } __result }); let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name(scope.type_env.clone(), m.clone()); + let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3922,7 +3937,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3930,7 +3945,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3953,8 +3968,10 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) - == "wire_contract".to_string())) + && (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + i.clone(), + ) == "wire_contract".to_string())) { __result.push(i); } @@ -3968,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name(scope.type_env.clone(), m.clone()), + authored_name((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3986,26 +4003,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) + let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4123,8 +4140,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4136,8 +4153,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4196,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports(tm.module.clone()), + Some(tm) => module_imports((*tm.module).clone()), None => Rc::new(vec![]), } } @@ -4211,7 +4228,10 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); + __result.push(authored_name_at( + source_indices.clone(), + (*tm.module).clone(), + )); } __result }) @@ -4384,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4476,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4586,7 +4606,8 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() + for imp in + module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4637,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) + for imp in module_imports((*tm.module).clone()) .iter() .cloned() { @@ -4905,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5162,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5198,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5658,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5687,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5826,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - scope.type_env.clone(), + (*scope.type_env).clone(), name.clone(), ) { true @@ -7208,7 +7229,7 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), authored_name(env.clone(), item.clone()), @@ -7484,7 +7505,7 @@ pub fn emit_typed_item( registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco { + let fn_read_only = if item_is_tco.clone() { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7495,6 +7516,17 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; + let fn_move_sites = if item_is_tco.clone() { + v1_rt::rc_empty_map::() + } else { + match v1_rt::map_get( + &emit_info.move_sites_index.clone(), + qualified_name.clone(), + ) { + Some(m) => m.clone(), + None => v1_rt::rc_empty_map::(), + } + }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7507,6 +7539,8 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), @@ -7593,6 +7627,15 @@ pub fn emit_typed_item( } } +pub fn needs_box_wrapping_shared_dominates() -> String { + thread_local! { + static CACHED: String = { + "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7600,34 +7643,31 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { - // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box - // — shared_types dominates the recursive check. Replaced by regen's - // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } - if ((n.children.clone().len() as i64) == 0) { - { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } - } } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; } else { - break false; + if ((n.children.clone().len() as i64) == 0) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; + } else { + break v1_rt::set_contains(&recursive_types, name.clone()); + } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } + } } } } @@ -9561,7 +9601,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9642,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9651,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9669,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9899,19 +9939,19 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_func_inferred( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -9981,7 +10021,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12222,10 +12262,28 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } +pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { + if (use_span.clone() == 0) { + false + } else { + match v1_rt::map_get( + &emit_info.move_sites.clone(), + move_site_key(name.clone(), use_span.clone()), + ) { + Some(v) => { + (v.clone() + && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + } + None => false, + } + } +} + pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, + use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12238,7 +12296,16 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); + let site_move_kind_allowed = match binding_kind.clone().as_deref().cloned() { + Some(VarBindingKind::MatchBoundBinding) => false, + Some(VarBindingKind::FunctionValueBinding) => false, + Some(VarBindingKind::VariantValueBinding { parent_enum: _, .. }) => false, + _ => true, + }; + let moves_by_value = + (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) + || (site_move_kind_allowed + && move_licensed_at_site(emit_info.clone(), name.clone(), use_span))); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12347,7 +12414,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12448,18 +12515,18 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); match find_child_named( base_struct, field, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12469,18 +12536,23 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - let faithful_nat_field = - matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) - && (field_ty_name.clone() == "Nat".to_string() - || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); - faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) + { + let faithful_nat_field = ((emit_info.corpus_repr.clone() + == RustCorpusRepr::FaithfulFreeMonoid) + && ((field_ty_name.clone() == "Nat".to_string()) + || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); + ((faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + (*scope.type_env).clone().source_indices.clone(), + )) + || is_recursive_type_by_name( + (*scope.type_env).clone(), + field_ty_name.clone(), + )) + } } } None => false, @@ -12548,7 +12620,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12611,7 +12683,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -12985,6 +13057,7 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), + expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13007,7 +13080,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13016,11 +13089,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13065,7 +13138,10 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let f = expr_call_func_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_call_expr( f, expr.children.clone(), @@ -13099,8 +13175,10 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = - expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let m = expr_method_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_method_call( expr.clone(), r, @@ -13175,8 +13253,10 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13212,14 +13292,14 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13379,7 +13459,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13398,8 +13478,10 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = - foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let v = foreach_variable_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13507,7 +13589,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13526,7 +13608,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, |expr| { @@ -13759,9 +13841,11 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = - resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); - match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { + let ty_name = resolved_type_name( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); + match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13770,7 +13854,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name(scope.type_env.clone(), child.clone()); + authored_name((*scope.type_env).clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -13779,7 +13863,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13888,7 +13972,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13913,7 +13997,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14046,7 +14130,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14061,7 +14145,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14190,7 +14274,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14337,7 +14421,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14405,8 +14489,10 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) - { + match arg_name_at( + a.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { Some(n) => n.clone(), None => "".to_string(), }, @@ -14424,7 +14510,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __found = true; @@ -14450,7 +14536,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14475,7 +14561,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14593,7 +14679,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14650,11 +14736,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14715,7 +14801,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14908,7 +14994,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14926,7 +15012,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -14970,7 +15056,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15017,7 +15103,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15039,6 +15125,19 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); + let site = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + lambda_expr.span.clone().file.clone(), + ":".to_string(), + ), + (lambda_expr.span.clone().start.clone()).to_string(), + ), + ":".to_string(), + ), + acc_name.clone(), + ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15046,16 +15145,22 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), + ), + acc_ident.clone(), + ), + " = v1_rt::take_owned_counted(".to_string(), ), acc_ident.clone(), ), - " = Rc::try_unwrap(".to_string(), + ", \"".to_string(), ), - acc_ident.clone(), + site, ), - ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), + "\"); ".to_string(), ), body_str, ), @@ -15107,7 +15212,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15148,33 +15253,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15202,7 +15307,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15212,7 +15317,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) .first() .cloned() @@ -15224,7 +15329,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15238,7 +15343,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15256,6 +15361,8 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15271,7 +15378,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15289,6 +15396,8 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15306,7 +15415,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15364,7 +15473,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15376,7 +15485,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15402,7 +15511,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15451,7 +15560,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }; @@ -15523,7 +15632,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15535,7 +15644,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { "_".to_string() @@ -15610,7 +15719,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15675,7 +15784,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15773,7 +15882,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15897,7 +16006,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -15954,7 +16063,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15972,7 +16081,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16045,7 +16154,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16249,7 +16358,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16378,13 +16487,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -16950,7 +17059,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17020,11 +17129,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17056,7 +17165,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17198,7 +17307,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17297,6 +17406,7 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), + arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17395,7 +17505,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17475,11 +17585,11 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name(scope.type_env.clone(), struct_name) { + match lookup_type_by_name((*scope.type_env).clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17506,8 +17616,10 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); + let receiver_type_name = authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + receiver_type, + ); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17524,7 +17636,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, } @@ -17571,7 +17683,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17599,7 +17711,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - (binding.resolved.clone().return_cardinality.clone() + ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17642,7 +17754,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_base, ), f, @@ -17776,7 +17888,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17784,7 +17896,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17793,7 +17905,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18013,13 +18125,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18040,7 +18152,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18056,7 +18168,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18130,7 +18242,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18140,7 +18252,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18150,7 +18262,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ), @@ -18170,7 +18282,10 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18251,20 +18366,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = resolve_node( + let resolved_struct = (*resolve_node( resolved_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) - .resolved - .clone(); + .resolved) + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18521,7 +18636,10 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18588,7 +18706,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18676,7 +18794,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18807,7 +18925,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -18891,10 +19009,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19210,8 +19328,10 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + stmt.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19227,7 +19347,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19297,15 +19417,18 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = emit_typed_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19332,11 +19455,11 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19553,7 +19676,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19611,10 +19734,10 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19629,12 +19752,18 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), rt.clone(), ) } @@ -19671,7 +19800,10 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19775,14 +19907,17 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19797,7 +19932,10 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) == n.clone()) { __found = true; @@ -19867,9 +20005,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -19926,7 +20064,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - frame.expr.clone(), + (*frame.expr).clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20043,7 +20181,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20194,7 +20332,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -22874,7 +23012,8 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) + && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -22906,12 +23045,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -22920,7 +23059,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -22929,11 +23068,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -22964,7 +23103,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ); @@ -22975,16 +23114,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23088,10 +23227,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23100,19 +23239,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23120,14 +23259,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23159,7 +23298,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23175,7 +23314,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23191,7 +23330,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23200,7 +23339,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -23208,7 +23347,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23228,13 +23367,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23251,14 +23390,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23281,8 +23420,7 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -23346,14 +23484,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -23515,7 +23653,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23881,7 +24019,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), ) { __result.push(item); } @@ -23894,12 +24032,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), registry.clone(), tm.items.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -23972,7 +24110,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )), None => "".to_string(), }; @@ -24009,8 +24147,10 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 0525069bf0f..635072e7f2f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,20 +45,18 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, - inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, - lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - put_inductive_field, put_inductive_field_cross, record_build_type_env_call, - record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, + build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, + is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, + lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, + rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{ - inferred_to_outputs, item_kind, variant_locals_from_items, -}; +pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -109,13 +107,11 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; -// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. -use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, + FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, + VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -146,18 +142,19 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, - index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, - is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, - is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, - let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, - make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, - make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, - make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, - method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, - node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, - resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, - string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, + is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, + is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, + lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, + make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, + make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, + make_param_node, make_span, make_text_part_node, make_transport_node, map_children, + match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, + param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, + return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, + with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -251,7 +248,7 @@ pub fn infer_block_stmts( let is_last = (remaining_count.clone() == 1); let stmt_expected = if is_last { expected.clone() } else { None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = stmt_result.typed.clone(); + let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = @@ -773,53 +770,66 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) { - Some(authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), - )) + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent.clone(), + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), + )) + } else { + None + } } else { None } - } else { - None } + None => None, } - None => None, - }, + } None => None, } } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup -// via the binding edge — replaced by regen's true emission of variant_owner_node -// in the convergence commit. +pub fn variant_owner_node_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { - Some(owner) => { - if owner.connective.clone() == Connective::Disj - && has_child_named( - owner.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - ) - { - Some(owner) - } else { - None + Some(binding) => { + match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + Some(owner) => { + let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); + if owner_is_coproduct { + if has_child_named( + owner.clone(), + name.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { + Some(owner.clone()) + } else { + None + } + } else { + None + } } + None => None, } - None => None, - }, + } None => None, } } @@ -842,45 +852,6 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, - name: String, - scope_enum: String, - expected: Option>, -) -> Option { - match expected { - Some(exp_node) => { - let exp_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), - exp_node.clone(), - ); - if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) - && (exp_name.clone() != name.clone())) - { - match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { - Some(exp_type) => { - if ((exp_type.connective.clone() == Connective::Disj) - && has_child_named( - exp_type.clone(), - name.clone(), - scope.type_env.clone().source_indices.clone(), - )) - { - Some(exp_name.clone()) - } else { - None - } - } - None => None, - } - } else { - None - } - } - None => None, - } -} - pub fn inference_error( message: String, span: Rc, @@ -911,7 +882,15 @@ pub fn type_mismatch_error( ) } -// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) +pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -919,32 +898,30 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { - if (expected.return_cardinality.clone() != Cardinality::CardOptional) { - return false; - } let expected_resolved = - match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { + match lookup_type_for(env, with_required_cardinality(expected.clone())) { Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = - (expected_resolved.connective.clone() == Connective::Disj); - let got_shape = node_type_shape(got.clone(), source_indices.clone()); - let got_is_string = (got_shape == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); + let expected_is_optional_coproduct = ((expected.return_cardinality.clone() + == Cardinality::CardOptional) + && (expected_resolved.connective.clone() == Connective::Disj)); + let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) + == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - if (ft.return_cardinality.clone() != Cardinality::CardOptional) { - return false; + { + let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { + Some(resolved) => resolved.clone(), + None => with_required_cardinality(ft.clone()), + }; + ((ft.return_cardinality.clone() == Cardinality::CardOptional) + && (inner.connective.clone() == Connective::Disj)) } - let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -952,17 +929,14 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { Some(direct) => direct.children.clone(), - // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), - // no name round-trip, no whole-env scan fallback. Regen replaces - // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -984,37 +958,6 @@ pub fn record_lit_expected_fields( } } -pub fn record_lit_variant_fields_from_visible_env( - env: Rc, - variant_name: String, - module_name: String, -) -> Rc>> { - let source_indices = env.source_indices.clone(); - let visible = flatten_visible_bindings(env.clone()); - for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { - let node = expand_type_for_field_access( - binding.resolved.clone(), - env.clone(), - module_name.clone(), - ); - if (node.connective.clone() == Connective::Disj) { - for arm in node.children.clone().iter().cloned() { - let arm_name = authored_name_at(source_indices.clone(), arm.clone()); - if (arm_name == variant_name.clone()) { - let expanded = - expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); - if (expanded.connective.clone() == Connective::Conj) { - return expanded.children.clone(); - } else { - return arm.children.clone(); - } - } - } - } - } - Rc::new(vec![]) -} - pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -1024,7 +967,7 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) @@ -1035,7 +978,7 @@ pub fn record_lit_expanded_from_expected( match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), expanded.clone(), ) == tn.clone()) { @@ -1047,7 +990,7 @@ pub fn record_lit_expanded_from_expected( _ => { let rt = resolved_type(exp.clone()); if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), rt.clone(), ) == tn.clone()) { @@ -1092,15 +1035,17 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - != tn.clone()) + if (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + exp.clone(), + ) != tn.clone()) { None } else { if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for(scope.type_env.clone(), exp.clone()) { + match lookup_type_for((*scope.type_env).clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1109,7 +1054,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1134,8 +1079,7 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -1185,7 +1129,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1195,20 +1139,24 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: b.ty.clone(), + ty: (*b.ty).clone(), miss_diags: b.diagnostics.clone(), }) } } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { + match arg_value(receiver_arg).inferred + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( receiver_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => false, } @@ -1223,7 +1171,7 @@ pub fn set_union_other_operand_is_resolved_non_set( node: other_type, .. }) => !node_is_set_collection( other_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => false, } @@ -1233,7 +1181,7 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, scope.type_env.clone()) { + match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, } @@ -1435,8 +1383,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1444,18 +1391,19 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => { - match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) - } + }) => match map_value_type_in_env( + receiver_type.clone(), + (*scope.type_env).clone(), + ) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type.clone()) + } else { + with_optional_cardinality(value_type.clone()) } - None => resolve_builtin_call_type(func_name.clone()), } - } + None => resolve_builtin_call_type(func_name.clone()), + }, _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1465,8 +1413,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1475,11 +1422,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { + match map_key_type_in_env(receiver_type.clone(), (*scope.type_env).clone()) + { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { - bt: lk.ty.clone(), + bt: (*lk.ty).clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1502,8 +1450,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1513,12 +1460,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( .. }) => match map_value_type_in_env( receiver_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(Tier2bBt { - bt: lv.ty.clone(), + bt: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1547,8 +1494,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()) - .inferred + Some(insert_arg) => match arg_value(insert_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1562,8 +1508,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()) - .inferred + Some(other_arg) => match arg_value(other_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1572,7 +1517,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: other_type, .. }) => match set_element_type_in_env( other_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, @@ -1600,8 +1545,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()) - .inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1622,7 +1566,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(oe) => set_element_types_mismatch( re.clone(), oe.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }, @@ -1673,8 +1617,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()) - .inferred + match arg_value(receiver_arg.clone()).inferred .clone() .as_deref() .cloned() @@ -1685,11 +1628,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => match recv_elem.clone() { Some(_) => receiver_type.clone(), None => match operand_elem.clone() { - Some(element) => { - set_kernel_ty_from_element(element.clone()) - .ty - .clone() - } + Some(element) => (*set_kernel_ty_from_element( + element.clone(), + ) + .ty) + .clone(), None => { resolve_builtin_call_type(func_name.clone()) } @@ -1757,11 +1700,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(MethodPipeFallback { - result_ty: lk.ty.clone(), + result_ty: (*lk.ty).clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1772,11 +1715,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { + match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(MethodPipeFallback { - result_ty: lv.ty.clone(), + result_ty: (*lv.ty).clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1910,7 +1853,7 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - scope.type_env.clone(), + (*scope.type_env).clone(), scrutinee_type.clone(), )), PatternSubject::PatternDynamic { @@ -1941,7 +1884,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1985,7 +1928,7 @@ pub fn annotate_pattern_parent_enums( resolved_scrut.clone(), variant_name.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); @@ -1997,16 +1940,16 @@ pub fn annotate_pattern_parent_enums( variant_subject.clone(), field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -2045,11 +1988,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), + param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2058,8 +2001,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2077,8 +2020,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2103,8 +2046,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2143,8 +2086,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2172,7 +2115,7 @@ pub fn scope_after_stmt_node( scope.clone(), let_binding_name_at( stmt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2198,7 +2141,7 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(n.clone()), ), _ => "".to_string(), @@ -2208,7 +2151,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); + inductive_fields_for((*scope.type_env).clone(), scrut_type_name.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2268,7 +2211,7 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); @@ -2281,13 +2224,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2377,7 +2320,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(a); } @@ -2398,9 +2341,9 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - init_result.typed.clone(), + (*init_result.typed).clone(), ia.span.clone(), ia.span.clone(), ), @@ -2427,7 +2370,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2435,9 +2378,9 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2498,10 +2441,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2564,8 +2507,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2582,9 +2525,9 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -2606,8 +2549,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: scope.type_env.clone(), - func_env: scope.func_env.clone(), + type_env: (*scope.type_env).clone(), + func_env: (*scope.func_env).clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2673,8 +2616,11 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), - ar.typed.clone(), + arg_name_at( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + (*ar.typed).clone(), arg.span.clone(), arg.span.clone(), ), @@ -2711,16 +2657,15 @@ pub fn infer_expr( ExprData::ExprVar { binding_kind: _, .. } => { - let name = - expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let name = expr_var_name_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { - // HAND-PATCH (§1c): the expected-type-as-owner-picker - // is deleted; the binding edge alone names the owner. - // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( name.clone(), Rc::new(ExprData::ExprVar { @@ -2732,7 +2677,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), span.clone(), @@ -2747,7 +2692,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), span.clone(), span.clone(), @@ -2755,7 +2700,7 @@ pub fn infer_expr( } } } - None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { + None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( @@ -2766,7 +2711,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: fsig.inferred.clone(), + node: (*fsig.inferred).clone(), })), span.clone(), span.clone(), @@ -2783,7 +2728,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - fsig.inferred.clone(), + (*fsig.inferred).clone(), ), })), span.clone(), @@ -2821,44 +2766,34 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let base_rt = resolved_type(base_typed.clone()); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { + if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) }; - let resolved_base_is_error = if resolved_base.inferred.clone() != None { + let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; if resolved_base_is_error { - // HAND-PATCH (debug instrumentation, removed with regen): - // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - format!( - "error type cascade (field '{}' on error-typed base '{}' in {})", - field_name, - authored_name_at( - scope.type_env.clone().source_indices.clone(), - base_typed.clone() - ), - scope.module_name - ), + "error type cascade".to_string(), span.clone(), ), diagnostics: base_diags, @@ -2868,19 +2803,19 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { let field_summary = match field_summary_for_type( base_rt.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), field_name.clone(), ) { Some(s) => Some(s.clone()), None => field_summary_for_type( resolved_base.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), field_name.clone(), ), }; @@ -2904,7 +2839,7 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); if base_is_type_var { { @@ -2933,7 +2868,7 @@ pub fn infer_expr( base_rt.clone(), field_name.clone(), scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( @@ -2967,8 +2902,7 @@ pub fn infer_expr( "' on type '".to_string(), ), authored_name_at( - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3002,11 +2936,13 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = - expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); + let func_name = expr_call_func_at( + texpr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); + let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -3038,7 +2974,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -3050,13 +2986,13 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type(first_result.typed.clone()); + let first_type = resolved_type((*first_result.typed).clone()); let elem_type = for_each_element_type_node( first_type, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - first_result.typed.clone(), + (*first_result.typed).clone(), elem_type.clone(), scope.clone(), ); @@ -3074,9 +3010,9 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), - first_result.typed.clone(), + (*first_result.typed).clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3095,7 +3031,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3109,7 +3045,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3121,7 +3057,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -3157,7 +3093,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3178,11 +3114,11 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), - ar.typed.clone(), + (*ar.typed).clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3190,9 +3126,9 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type(ar.typed.clone()), + resolved_type((*ar.typed).clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.subst.clone(), ) } @@ -3204,9 +3140,12 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ), - ar.typed.clone(), + (*ar.typed).clone(), a.span.clone(), a.span.clone(), ), @@ -3225,7 +3164,7 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); @@ -3241,9 +3180,9 @@ pub fn infer_expr( { let resolved_type = match sig.clone() { Some(s) => substitute_generics( - s.inferred.clone(), + (*s.inferred).clone(), call_subst.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => error_type(), }; @@ -3252,7 +3191,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { __result.push(p); } @@ -3267,7 +3206,7 @@ pub fn infer_expr( value_params_for_check, typed_args.clone(), call_subst.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) }; @@ -3303,7 +3242,7 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) @@ -3330,7 +3269,7 @@ pub fn infer_expr( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3339,7 +3278,7 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { @@ -3353,11 +3292,13 @@ pub fn infer_expr( .skip(1 as usize) .collect::>(), ); - let base_result_type = match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) { + let base_result_type = + match method_resolution.result_type.clone() { + Some(mt) => mt.clone(), + None => error_type(), + }; + let method_tv = if (method_resolution.semantics.clone() == None) + { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), @@ -3374,8 +3315,7 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3408,8 +3348,7 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -3433,9 +3372,10 @@ pub fn infer_expr( }), } }; - let bridge_result_type = method_tv.ty.clone(); + let bridge_result_type = (*method_tv.ty).clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics.clone() + let returns_receiver_self = if (method_resolution.semantics + .clone() == None) { false @@ -3456,11 +3396,11 @@ pub fn infer_expr( let final_receiver = if ((returns_receiver_self && is_fully_resolved( bridge_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( first_arg_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3495,7 +3435,7 @@ pub fn infer_expr( __result.push(make_arg_node( arg_name_at( ta.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), arg_value(ta.clone()), span.clone(), @@ -3508,7 +3448,8 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics.clone(), + method_semantics: method_resolution.semantics + .clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), @@ -3534,7 +3475,7 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3598,7 +3539,7 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3666,7 +3607,7 @@ match bare_s { scope.clone(), span.clone(), ); - let bt = tier2b.bt.clone(); + let bt = (*tier2b.bt).clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3700,8 +3641,7 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if ((binding - .resolved + if (((*binding.resolved) .clone() .params .clone() @@ -3709,7 +3649,7 @@ match bare_s { as i64) > 0) { - Some(binding.resolved.clone()) + Some((*binding.resolved).clone()) } else { None } @@ -3746,7 +3686,7 @@ match bare_s { Some(ctor_result) => ctor_result.clone(), None => { let type_match = lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), func_name.clone(), ); let resolved_type = match type_match.clone() @@ -3795,21 +3735,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = recv_result.typed.clone(); + let recv_typed = (*recv_result.typed).clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( resolved_type(recv_typed.clone()), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3820,7 +3760,7 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), + Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( @@ -3840,7 +3780,7 @@ match bare_s { let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push(air.typed_arg.clone()); + __result.push((*air.typed_arg).clone()); } __result }); @@ -3853,7 +3793,7 @@ match bare_s { }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { @@ -3885,7 +3825,7 @@ match bare_s { None }, scope.service_registry.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { @@ -3899,7 +3839,7 @@ match bare_s { span.clone(), ), }; - let base_result_type = pipe_fb.result_ty.clone(); + let base_result_type = (*pipe_fb.result_ty).clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), @@ -3915,7 +3855,7 @@ match bare_s { if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { { @@ -3939,7 +3879,7 @@ match bare_s { mc_arg_types, recv_rt.clone(), mc_fold_overrides, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } } else { @@ -3960,7 +3900,7 @@ match bare_s { }), } }; - let result_type = method_tv_mc.ty.clone(); + let result_type = (*method_tv_mc.ty).clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); let method_semantics = if (method_resolution.semantics.clone() != None) { method_resolution.semantics.clone() @@ -3994,7 +3934,7 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = scrut_result.typed.clone(); + let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = resolved_type(scrut_typed.clone()); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); @@ -4026,7 +3966,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4044,7 +3984,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4064,7 +4004,7 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.body_type.clone()); + __result.push((*ar.body_type).clone()); } __result }); @@ -4083,14 +4023,14 @@ match bare_s { prefer_specific_type( acc, t.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); @@ -4147,8 +4087,8 @@ match bare_s { }), }; if !is_fully_resolved( - original.body_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*original.body_type).clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4181,7 +4121,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4199,7 +4139,7 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some(guard_unwrapped.typed.clone()) + Some((*guard_unwrapped.typed).clone()) } else { None }, @@ -4229,7 +4169,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push(ar.typed_arm.clone()); + __result.push((*ar.typed_arm).clone()); } __result }); @@ -4262,7 +4202,7 @@ match bare_s { } => check_match_exhaustiveness( resolved_scrutinee.clone(), typed_arms.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), span.clone(), scope.module_name.clone(), ), @@ -4289,23 +4229,23 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = cond_result.typed.clone(); + let cond_typed = (*cond_result.typed).clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type(then_result.typed.clone()); - let else_rt = resolved_type(else_result.typed.clone()); + let then_rt = resolved_type((*then_result.typed).clone()); + let else_rt = resolved_type((*else_result.typed).clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { @@ -4313,30 +4253,30 @@ match bare_s { }; let else_result = if (!is_fully_resolved( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = then_result.typed.clone(); + let then_typed = (*then_result.typed).clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = else_result.typed.clone(); + let else_typed = (*else_result.typed).clone(); let else_diags = else_result.diagnostics.clone(); let then_rt = resolved_type(then_typed.clone()); let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4348,14 +4288,14 @@ match bare_s { .to_string(), node_type_shape( then_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( else_rt.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), ), span.clone(), @@ -4393,7 +4333,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4404,7 +4344,7 @@ match bare_s { binding_kind: _, .. } => { (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), bd.clone(), ) == let_name.clone()) } @@ -4418,7 +4358,7 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { @@ -4446,7 +4386,7 @@ match bare_s { ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( let_name.clone(), @@ -4469,7 +4409,7 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), field_inits, span.clone(), @@ -4485,7 +4425,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4507,7 +4447,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push(r.typed.clone()); + __result.push((*r.typed).clone()); } __result }); @@ -4520,7 +4460,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type(r.typed.clone()), + Some(r) => resolved_type((*r.typed).clone()), None => unit_type(), } } else { @@ -4528,7 +4468,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => child_type_node(elem.clone()), @@ -4546,7 +4486,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4576,7 +4516,7 @@ match bare_s { Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: list_k.ty.clone(), + node: (*list_k.ty).clone(), })), span.clone(), ); @@ -4593,15 +4533,15 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = left_result.typed.clone(); + let left_typed = (*left_result.typed).clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = right_result.typed.clone(); + let right_typed = (*right_result.typed).clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), resolved_type(left_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { @@ -4610,7 +4550,7 @@ match bare_s { }), Rc::new(vec![left_typed.clone(), right_typed]), Some(Rc::new(InferredNode::Resolved { - node: binop_info.result_type.clone(), + node: (*binop_info.result_type).clone(), })), span.clone(), ); @@ -4623,7 +4563,7 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = operand_result.typed.clone(); + let operand_typed = (*operand_result.typed).clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), @@ -4645,7 +4585,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4775,8 +4715,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: lam_scope.type_env.clone(), - func_env: lam_scope.func_env.clone(), + type_env: (*lam_scope.type_env).clone(), + func_env: (*lam_scope.func_env).clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4785,7 +4725,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4811,7 +4751,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: binding.resolved.clone(), + node: (*binding.resolved).clone(), })), None => None, }; @@ -4860,7 +4800,10 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node(r.typed.clone(), part_node.span.clone()) + make_interp_part_node( + (*r.typed).clone(), + part_node.span.clone(), + ) } None => part_node.clone(), }, @@ -4919,7 +4862,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: state.last_type.clone(), + node: (*state.last_type).clone(), })), span.clone(), ); @@ -4948,9 +4891,9 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = inner_result.typed.clone(); + let inner_typed = (*inner_result.typed).clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( inner_typed.inferred.clone(), @@ -4979,17 +4922,17 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = coll_result.typed.clone(); + let coll_typed = (*coll_result.typed).clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( resolved_type(coll_typed.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( coll_typed.clone(), @@ -5003,7 +4946,7 @@ match bare_s { elem_provenance, ); let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( variable.clone(), @@ -5023,10 +4966,10 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = index_result.typed.clone(); + let index_typed = (*index_result.typed).clone(); let index_diags = index_result.diagnostics.clone(); let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -5039,17 +4982,19 @@ match bare_s { index_type.clone(), span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = + match base_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + index_typed.inferred.clone() + } + _ => base_typed.inferred.clone(), + }; let idx_inferred = match index_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5082,13 +5027,13 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = base_result.typed.clone(); + let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = start_result.typed.clone(); + let start_typed = (*start_result.typed).clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = end_result.typed.clone(); + let end_typed = (*end_result.typed).clone(); let end_diags = end_result.diagnostics.clone(); let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -5104,7 +5049,7 @@ match bare_s { end_type.clone(), span.clone(), scope.module_name.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) } _ => None, @@ -5113,18 +5058,18 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() + let access_failure_inferred = + match base_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + match start_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + end_typed.inferred.clone() + } + _ => start_typed.inferred.clone(), } - _ => start_typed.inferred.clone(), } - } - _ => base_typed.inferred.clone(), - }; + _ => base_typed.inferred.clone(), + }; let slc_inferred = match slice_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5161,8 +5106,8 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![inner_result.typed.clone()]), - inner_result.typed.clone().inferred.clone(), + Rc::new(vec![(*inner_result.typed).clone()]), + (*inner_result.typed).clone().inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -5199,8 +5144,8 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { Some(variant_node) => { @@ -5281,7 +5226,8 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) + { true } else { if (((n.connective.clone() == Connective::NoConnective) @@ -5354,9 +5300,7 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = resolve_node(n, env.clone(), module_name.clone()) - .resolved - .clone(); + let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { @@ -5645,17 +5589,13 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) +pub fn expand_type_for_field_access_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn expand_type_for_field_access_with_seen( @@ -5667,23 +5607,38 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) + { + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) + } } } +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) +} + pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) @@ -5698,7 +5653,7 @@ pub fn record_lit_alias_struct_fields( }; let expanded = expand_type_for_field_access( to_expand, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5718,8 +5673,8 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = scope.type_env.clone().source_indices.clone(); - match lookup_type_by_name(scope.type_env.clone(), type_name) { + let si = (*scope.type_env).clone().source_indices.clone(); + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5743,73 +5698,50 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); - { - let mut __found = false; - for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( - scope.type_env.clone(), - ))) - .iter() - .cloned() - { - if { - let node = binding.resolved.clone(); - if (node.connective.clone() == Connective::Disj) { + let si = (*scope.type_env).clone().source_indices.clone(); + match variant_owner_node(scope.clone(), type_name.clone()) { + Some(owner) => { + let mut __found = false; + for arm in owner.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { { - let mut __found = false; - for arm in node.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) - == type_name.clone()) - { - { - let ea = expand_type_for_field_access( - arm.clone(), - scope.type_env.clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) - { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) - == field.clone()) - { - __found = true; - break; - } - } - __found - } + let ea = expand_type_for_field_access( + arm.clone(), + (*scope.type_env).clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) == field.clone()) { + __found = true; + break; } - } else { - false - } { - __found = true; - break; } + __found } - __found } } else { false + } { + __found = true; + break; } - } { - __found = true; - break; } + __found } - __found + None => false, } } } pub fn type_has_sole_constructor(type_name: String, scope: Rc) -> bool { - match lookup_type_by_name(scope.type_env.clone(), type_name) { + match lookup_type_by_name((*scope.type_env).clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5833,38 +5765,28 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { - // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is - // deleted; the ladder is instantiate -> expected -> declaration/ - // binding-edge only. Regen replaces this with the dag source's true - // emission. let struct_fields = match type_name.clone() { - Some(tn) => { - match record_lit_instantiated_fields( + Some(tn) => match record_lit_instantiated_fields( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields.clone(), + None => match record_lit_fields_from_expected( type_name.clone(), expected.clone(), scope.clone(), ) { Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => { - match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => { - record_lit_expected_fields(type_name.clone(), scope.clone()) - } - } - } + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields.clone(), + None => record_lit_expected_fields(type_name.clone(), scope.clone()), }, }, - } - } + }, + }, None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), @@ -5895,7 +5817,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5931,7 +5853,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5948,11 +5870,11 @@ pub fn infer_record_lit( Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if ((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone()) + if (((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone())) || field_type_is_optional_coproduct( ft.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), )) { Some(ft.clone()) @@ -5967,7 +5889,7 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = ar.typed.clone(); + let ar_typed = (*ar.typed).clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { @@ -5975,28 +5897,30 @@ pub fn infer_record_lit( if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - scope.type_env.clone().source_indices.clone(), - scope.type_env.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*scope.type_env).clone(), ) { - let expected_for_shape = match lookup_type_for( - scope.type_env.clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape, - scope.type_env.clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - scope.type_env.clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) + { + let expected_for_shape = match lookup_type_for( + (*scope.type_env).clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + (*scope.type_env).clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) + } } else { Rc::new(vec![]) } @@ -6023,7 +5947,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push(fir.typed_field.clone()); + __result.push((*fir.typed_field).clone()); } __result }); @@ -6041,15 +5965,15 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ), - span: fir.typed_field.clone().span.clone(), - ident_span: fir.typed_field.clone().ident_span.clone(), + span: (*fir.typed_field).clone().span.clone(), + ident_span: (*fir.typed_field).clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: fir.infer_result.clone().typed.clone().inferred.clone(), + inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6100,7 +6024,7 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); + lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { @@ -6110,7 +6034,7 @@ pub fn infer_record_lit( lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for(scope.type_env.clone(), local_node.clone()) + lookup_type_for((*scope.type_env).clone(), local_node.clone()) } None => None, } @@ -6130,8 +6054,8 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), + (*fir.typed_field).clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6143,7 +6067,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - val_fir.infer_result.clone().typed.clone(), + (*val_fir.infer_result.clone().typed).clone(), )), None => raw_resolved, } @@ -6151,9 +6075,6 @@ pub fn infer_record_lit( } else { raw_resolved }; - // HAND-PATCH (§1c): unbound constructor literal is the typed - // UnresolvedType diagnostic, not a generic InternalError message. - // Regen replaces this with the dag source's true emission. let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( @@ -6167,7 +6088,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6252,7 +6173,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6262,7 +6183,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { Some(_) => Some(Rc::new(SizeExpr::ParamSize { @@ -6290,7 +6211,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() @@ -6339,7 +6260,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6404,7 +6325,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6415,7 +6336,7 @@ pub fn classify_collection_shrink( } => { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (rname == param_name.clone()) { { @@ -6460,7 +6381,10 @@ Rc::new(SubValueRelation::StrictSubValue { } => { let aname = expr_var_name_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env) + .clone() + .source_indices + .clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6668,12 +6592,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6693,7 +6617,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6728,12 +6652,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - match lookup_func_sig(ctx.func_env.clone(), callee) { + expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = sig.inferred.clone(); + let return_type = (*sig.inferred).clone(); let field_map = Rc::new( return_type .children @@ -6753,7 +6677,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6797,7 +6721,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6805,7 +6729,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6832,7 +6756,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ) .iter() @@ -6871,7 +6795,7 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); + expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { @@ -6907,8 +6831,10 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = - expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_mname = expr_method_name_at( + expr.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) @@ -6937,8 +6863,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = - expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let vname = expr_var_name_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6946,23 +6874,25 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = - field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); + let field = field_access_field_at( + val.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( - scope.type_env.clone(), + (*scope.type_env).clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*scope.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -6998,7 +6928,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + let vname = + expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -7010,13 +6941,15 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); + field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), @@ -7028,8 +6961,8 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), None => match v1_rt::map_get( &ctx.param_names.clone(), @@ -7042,7 +6975,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) @@ -7104,7 +7037,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let iname = expr_var_name_at( inner.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -7132,7 +7065,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { if is_container_type(authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), c.clone(), ), None => "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) + && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) { { let fields = - inductive_fields_for(ctx.type_env.clone(), elem.clone()); + inductive_fields_for((*ctx.type_env).clone(), elem.clone()); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7244,7 +7177,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7291,7 +7224,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7315,7 +7248,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7376,7 +7309,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7434,7 +7367,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env + (*ctx.type_env) .clone() .source_indices .clone(), @@ -7504,7 +7437,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7551,7 +7484,7 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) @@ -7594,7 +7527,7 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) @@ -7609,7 +7542,7 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7617,7 +7550,7 @@ pub fn classify_argument( } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -7638,7 +7571,7 @@ pub fn classify_argument( } } }; - let fields = inductive_fields_for(ctx.type_env.clone(), type_name); + let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7676,22 +7609,24 @@ pub fn classify_argument( SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - let from_provenance = - match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, - } + let from_provenance = match lookup_func_sig( + (*ctx.func_env).clone(), + callee.clone(), + ) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map.clone(), + ctx.clone(), + ), + None => None, } - None => None, - }; + } + None => None, + }; match from_provenance { Some(prov_rel) => prov_rel.clone(), None => { @@ -7707,7 +7642,7 @@ pub fn classify_argument( None => "".to_string(), }; let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), type_name, ); let cf = Rc::new({ @@ -7785,13 +7720,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7829,13 +7764,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7847,13 +7782,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), ) != None)) } @@ -7950,7 +7885,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7966,14 +7901,16 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = - expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); + let bname = expr_var_name_at( + base.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7981,10 +7918,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), + (*ctx.type_env).clone().source_indices.clone(), + (*binding.resolved).clone(), ), ); let matching = Rc::new({ @@ -8055,7 +7992,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8074,7 +8011,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8143,7 +8080,7 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { Some(t) => t.clone(), @@ -8181,7 +8118,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8216,11 +8153,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8268,13 +8205,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8288,7 +8225,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8299,7 +8236,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8342,7 +8279,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), @@ -8369,7 +8306,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8377,7 +8314,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -8387,7 +8324,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ); Rc::new({ @@ -8415,7 +8352,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if ((mname.clone() == "first".to_string()) || (mname.clone() == "last".to_string())) @@ -8431,7 +8368,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() + && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8439,9 +8376,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); - match lookup_func_sig(ctx.func_env.clone(), callee) { + match lookup_func_sig((*ctx.func_env).clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8477,20 +8414,20 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8502,14 +8439,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: ic.type_env.clone(), + type_env: (*ic.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: ic.func_env.clone(), + func_env: (*ic.func_env).clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8525,9 +8462,9 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8539,14 +8476,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8562,11 +8499,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8575,14 +8512,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8623,8 +8560,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = - let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let binding_name = let_binding_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { @@ -8660,7 +8599,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8676,7 +8615,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }) } @@ -8684,7 +8623,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( @@ -8696,7 +8635,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: inner_per_field, }), }; @@ -8742,7 +8681,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8777,7 +8716,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8793,7 +8732,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8801,7 +8740,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), + type_env: (*acc.ctx.clone().type_env).clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8815,7 +8754,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: acc.ctx.clone().func_env.clone(), + func_env: (*acc.ctx.clone().func_env).clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8856,8 +8795,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = - expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let mname = expr_method_name_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { @@ -8869,7 +8810,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) @@ -8884,7 +8825,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let base = field_access_base(receiver.clone()); let fname = field_access_field_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8892,7 +8833,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let bname = expr_var_name_at( base.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -8921,7 +8862,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - ctx.type_env.clone(), + (*ctx.type_env).clone(), base_type.clone(), ) .iter() @@ -8947,7 +8888,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let rname = expr_var_name_at( receiver.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { @@ -8990,7 +8931,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); lparams .clone() @@ -9010,7 +8951,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), @@ -9030,14 +8971,14 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -9045,7 +8986,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -9066,7 +9007,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9079,7 +9020,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9126,8 +9067,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = - foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); + let fe_var = foreach_variable_at( + body.clone(), + (*ctx.type_env).clone().source_indices.clone(), + ); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9138,7 +9081,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), fe_var.clone(), @@ -9148,18 +9091,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), + type_env: (*ctx.type_env).clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; @@ -9816,7 +9759,7 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = unwrapped.expr.clone(); + let terminal = (*unwrapped.expr).clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( terminal, @@ -9862,11 +9805,15 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { + match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in - arm_unwrapped.expr.clone().children.clone().iter().cloned() + for fi in (*arm_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9893,10 +9840,16 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { + let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { + for fi in (*then_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9914,24 +9867,30 @@ pub fn classify_terminal_per_field( Some(else_expr) => { let else_unwrapped = unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() - { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + let else_result = + match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in (*else_unwrapped.expr) + .clone() + .children + .clone() + .iter() + .cloned() + { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -10099,13 +10058,13 @@ pub fn arm_ctx_from_variant_provenance( } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); + call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - ctx.type_env.clone().source_indices.clone(), + (*ctx.type_env).clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10123,8 +10082,8 @@ pub fn arm_ctx_from_variant_provenance( call_args.clone(), c.param_order.clone(), c.param_names.clone(), - c.type_env.clone(), - c.func_env.clone(), + (*c.type_env).clone(), + (*c.func_env).clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10152,7 +10111,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: c.type_env.clone(), + type_env: (*c.type_env).clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10160,7 +10119,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: c.func_env.clone(), + func_env: (*c.func_env).clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10382,7 +10341,7 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - sig.inferred.clone(), + (*sig.inferred).clone(), ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -10715,7 +10674,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10756,34 +10715,36 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = - match item.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: rt, - .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, - >, + let variant_prov = match item.inferred + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { + node: rt, .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, >, >, >, - >( - ), - }; + >, + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10798,7 +10759,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: sig.inferred.clone(), + inferred: (*sig.inferred).clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10912,7 +10873,7 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -10964,7 +10925,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -10975,7 +10936,7 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![val_result.typed.clone()]), + children: Rc::new(vec![(*val_result.typed).clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -11083,7 +11044,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push(infer_item(c.clone(), scope.clone()).item.clone()); + __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11115,7 +11076,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), @@ -11132,7 +11093,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), fn_return_expected, ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); let inferred_ret = if (item.inferred.clone() != None) { item.inferred.clone() @@ -11142,22 +11103,22 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let is_recursive = expr_has_self_call( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { annotate_descent_evidence( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), item.params.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), fn_scope.locals.clone(), - scope.func_env.clone(), + (*scope.func_env).clone(), ) } else { body_typed.clone() @@ -11171,7 +11132,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push(infer_item(c.clone(), scope.clone()).item.clone()); + .push((*infer_item(c.clone(), scope.clone()).item).clone()); } __result }), @@ -11188,11 +11149,11 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc has_non_tail_self_call: expr_has_non_tail_self_call( body_typed.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), item.clone(), ), true, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11215,7 +11176,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), Some(resolved_type(item.clone())), ); - let body_typed = body_result.typed.clone(); + let body_typed = (*body_result.typed).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11245,7 +11206,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) + { { let data_expected = if (item.type_annotation.clone() != None) { Some(item.type_annotation.clone().clone().unwrap()) @@ -11257,7 +11219,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc scope.clone(), data_expected, ); - let val_typed = val_result.typed.clone(); + let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { @@ -11294,7 +11256,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) + && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11305,7 +11268,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result @@ -11341,7 +11305,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - infer_item(c.clone(), scope.clone()).item.clone(), + (*infer_item(c.clone(), scope.clone()).item) + .clone(), ); } __result @@ -11536,13 +11501,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); + authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11572,7 +11537,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), st.clone(), ) } @@ -11593,7 +11558,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11610,7 +11575,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } else { @@ -11618,7 +11583,7 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) && (formal_name.clone() == record_type_name.clone())) @@ -11638,7 +11603,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11648,7 +11613,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc, ) } @@ -11658,7 +11623,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11797,10 +11762,10 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps(b.resolved.clone(), source_indices); - let is_bare_self = ((((b.resolved.clone().connective.clone() + let deps0 = node_type_deps((*b.resolved).clone(), source_indices); + let is_bare_self = (((((*b.resolved).clone().connective.clone() == Connective::NoConnective) - && ((b.resolved.clone().children.clone().len() as i64) == 0)) + && (((*b.resolved).clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11867,14 +11832,6 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { - if resolved_imports.len() == 1 { - if let Some(imp) = resolved_imports.first().cloned() { - if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - return parent.type_env_cache.clone(); - } - } - return empty_type_env_cache(); - } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11887,58 +11844,29 @@ pub fn union_parent_type_env_caches( ) } -pub fn union_parent_variant_locals( - resolved_imports: Rc>>, - parent_index: Rc>>, -) -> Rc>> { - resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, imp: Rc| match v1_rt::map_get( - &parent_index, - imp.module_path.clone(), - ) { - Some(parent) => v1_rt::rc_map_merge( - acc.clone(), - parent.type_env_cache.clone().variant_locals.clone(), - ), - None => acc.clone(), - }, - ) -} - -pub fn fold_local_coproduct_variant_locals( - bindings: Rc>>, - imported_variants: Rc>, - source_indices: Rc>>, - init_locals: Rc>>, -) -> Rc { - Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - Rc::new(VariantFoldState { - locals: init_locals, - collision_errors: Rc::new(vec![]), - }), - |acc: Rc, binding: Rc| { - let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - { - let binding_enum_name = - authored_name_at(source_indices.clone(), binding.resolved.clone()); - binding - .resolved +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, binding: Rc| { + let is_coproduct = + ((*binding.resolved).clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + (*binding.resolved) .clone() .children .clone() @@ -11946,70 +11874,28 @@ pub fn fold_local_coproduct_variant_locals( .cloned() .fold( acc.clone(), - |vacc: Rc, child: Rc| { + |vacc: Rc>>, child: Rc| { let child_name = - authored_name_at(source_indices.clone(), child.clone()); - let curr_child_is_imported = is_imported_variant_owned_by( - imported_variants.clone(), - child_name.clone(), - binding_enum_name.clone(), - ); - match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { - Some(_prev) => { - if curr_child_is_imported.clone() { - Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }) - } else { - vacc.clone() - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - vacc.locals.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - collision_errors: vacc.collision_errors.clone(), - }), + authored_name_at(env.source_indices.clone(), child.clone()); + match v1_rt::map_get(&vacc, child_name.clone()) { + Some(_prev) => vacc.clone(), + None => v1_rt::rc_map_insert( + vacc.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: (*binding.resolved).clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), } }, ) + } else { + acc.clone() } - } else { - acc.clone() - } - }, - ) -} - -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => fold_local_coproduct_variant_locals( - kernel.bindings.clone(), - v1_rt::rc_empty_map::(), - env.source_indices.clone(), - v1_rt::rc_empty_map::>(), - ) - .locals - .clone(), + }, + ), None => v1_rt::rc_empty_map::>(), } } @@ -12066,9 +11952,26 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ); + let filtered_ancestry = + Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) .iter() .cloned() .fold( @@ -12077,8 +11980,10 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -12088,30 +11993,11 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get( - &parent_env.ancestry_str_bindings.clone(), - name.clone(), - ) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ), + ); + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: filtered_str, + ancestry_str_bindings: filtered_ancestry, parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12125,271 +12011,258 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, + parent_index: Rc>>, source_indices: Rc>>, intern_table: Rc, -) -> Rc { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> Rc { + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let intern_table = seed_kernel_intern_table(intern_table.clone()); + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }) -} - -pub fn build_type_env( - module: Rc, - parent_index: Rc>>, - source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - record_build_type_env_call(); - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() .cloned() .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert( acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), + intern(intern_table.clone(), name.clone()).id.clone(), + true, ) }, ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); - let kernel_cache = type_env_cache_from_bindings( - kernel.bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), - ); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let kernel = Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12397,7 +12270,7 @@ pub fn build_type_env( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12407,7 +12280,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12441,7 +12314,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12606,7 +12479,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items(module.module.clone()).iter().cloned().fold( + let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12658,10 +12531,15 @@ pub fn build_type_env( }, ); let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); + let kernel_cache = type_env_cache_from_bindings( + kernel_bindings.clone(), + source_indices.clone(), + compiler_recursive_name_set(), + ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12702,52 +12580,53 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -12771,7 +12650,7 @@ pub fn build_type_env( local_name_set, all_deps_map.clone(), ); - let resolved_env_out = resolved.env.clone(); + let resolved_env_out = (*resolved.env).clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), @@ -12804,7 +12683,6 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { - record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12959,7 +12837,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); + let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12967,7 +12845,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - typed_parent.type_env.clone(), + (*typed_parent.type_env).clone(), )]), None => Rc::new(vec![]), }) @@ -12978,7 +12856,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items(module.module.clone()).iter().cloned().fold( + let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -13109,8 +12987,8 @@ pub fn build_type_env_unresolved( ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if module.resolved_imports.clone().len() == 1 { - import_cache.clone() + let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { + import_cache } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13151,52 +13029,53 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) + let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items(module.module.clone()), + module_items((*module.module).clone()), cycle_set_for_inductive, source_indices.clone(), ); - let import_inductive_fields = scope_parents.clone().iter().cloned().fold( + let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(import_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { - if let Some(imp) = module.resolved_imports.clone().first().cloned() { - if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { - v1_rt::rc_map_merge( - parent_mod.type_env.ancestry_str_bindings.clone(), - parent_mod.type_env.str_bindings.clone(), - ) - } else { - ancestry_cache.str_bindings.clone() - } - } else { - ancestry_cache.str_bindings.clone() + merge_inductive_fields(parent_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { + match module.resolved_imports.clone().first().cloned() { + Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_mod) => v1_rt::rc_map_merge( + (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), + (*parent_mod.type_env).clone().str_bindings.clone(), + ), + None => ancestry_cache.str_bindings.clone(), + }, + None => ancestry_cache.str_bindings.clone(), } } else { ancestry_cache.str_bindings.clone() @@ -13312,7 +13191,7 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = resolved.item.clone(); + let ritem = (*resolved.item).clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) && (ritem.inferred.clone() != None)) @@ -13339,31 +13218,33 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) + let svc_entries = if ((ritem.transport.clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } - } else { - None - }; + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = if ((ritem.transport.clone() != None) + && ((ritem.children.clone().len() as i64) > 0)) + { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) + } + } else { + None + }; Rc::new(ItemContribution { resolved_item: ritem.clone(), resolve_diagnostics: resolved.diagnostics.clone(), @@ -13411,7 +13292,7 @@ pub fn fold_module_contributions( svc_registry, authored_name_at( source_indices.clone(), - contribution.resolved_item.clone(), + (*contribution.resolved_item).clone(), ), contribution.svc_entries.clone(), ) @@ -13433,7 +13314,7 @@ pub fn fold_module_contributions( .collect::>(), ); let __tco_1 = - v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); + v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); let __tco_2 = next_func_sigs; let __tco_3 = next_svc_registry; let __tco_4 = next_svc_locals; @@ -13458,76 +13339,315 @@ pub fn fold_module_contributions( } } -pub fn enum_parents_for_variant_in_items( - variant_name: String, - items: Rc>>, +pub fn constructor_binding_authority() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn insert_variant_owner_checked( + state: Rc, + arm_name: String, + owner: Rc, source_indices: Rc>>, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()) - == variant_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } + module_name: String, +) -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); + let owner_name = authored_name_at(source_indices.clone(), owner.clone()); + let same_owner = (((prev_name.clone() == owner_name.clone()) + && ((*prev.resolved).clone().span.clone().file.clone() + == owner.span.clone().file.clone())) + && ((*prev.resolved).clone().span.clone().start.clone() + == owner.span.clone().start.clone())); + if same_owner { + state.clone() + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name.clone(), + enum1: prev_name.clone(), + enum2: owner_name.clone(), + span: owner.span.clone(), + }), + module_name, + )]), + ), + }) } - __result - }) - .iter() - .cloned() - { - __result.push(authored_name_at(source_indices.clone(), item.clone())); } - __result - }) + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name.clone(), + resolved: owner.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } } -pub fn unique_imported_variant_owner( - variant_name: String, +pub fn bind_coproduct_item_arms( + state: Rc, + item: Rc, + source_indices: Rc>>, + module_name: String, +) -> Rc { + item.children.clone().iter().cloned().fold( + state, + |vacc: Rc, child: Rc| { + insert_variant_owner_checked( + vacc, + authored_name_at(source_indices.clone(), child.clone()), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + }, + ) +} + +pub fn build_local_variants( items: Rc>>, source_indices: Rc>>, -) -> Option { - { - let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); - if ((parents.clone().len() as i64) == 1) { - parents.clone().first().cloned() - } else { - None + module_name: String, + init: Rc, +) -> Rc { + items + .iter() + .cloned() + .fold(init, |acc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + acc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + acc.clone() + } + }) +} + +pub fn reexport_chain_authority() -> String { + thread_local! { + static CACHED: String = { + "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn owner_of_exported_arm( + mut module_path: String, + mut arm_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for c in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), c.clone()) + == arm_name.clone()) + { + __found = true; + break; + } + } + __found + } { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == arm_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } } } } -pub fn is_imported_variant_owned_by( - imported_variants: Rc>, - variant_name: String, - enum_name: String, -) -> bool { - match v1_rt::map_get(&imported_variants, variant_name) { - Some(unique_parent) => (unique_parent.clone() == enum_name), - None => false, +pub fn exported_coproduct_item( + mut module_path: String, + mut enum_name: String, + mut parent_index: Rc>>, + mut source_indices: Rc>>, +) -> Option> { + loop { + match v1_rt::map_get(&parent_index, module_path) { + None => { + break None; + } + Some(tm) => { + let own = Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in tm.items.clone().iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if (authored_name_at(source_indices.clone(), item.clone()) + == enum_name.clone()) + { + __result.push(item); + } + } + __result + }) + .first() + .cloned(); + match own { + Some(item) => { + break Some(item.clone()); + } + None => { + let reexport = Rc::new({ + let mut __result = Vec::new(); + for imp in Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*tm.module).clone()).iter().cloned() { + if !import_is_all(imp.clone()) { + __result.push(imp); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for n in import_specific_names_at( + imp.clone(), + source_indices.clone(), + ) + .iter() + .cloned() + { + if (n.clone() == enum_name.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(imp); + } + } + __result + }) + .first() + .cloned(); + match reexport { + Some(imp) => { + let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); + module_path = __tco_0; + continue; + } + None => { + break None; + } + } + } + } + } + } } } @@ -13535,35 +13655,70 @@ pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, -) -> Rc> { + module_name: String, + init: Rc, +) -> Rc { resolved_imports.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, imp: Rc| { - imp.specific_names.clone().iter().cloned().fold( - acc, - |inner: Rc>, variant_name: String| { - if v1_rt::map_contains_key(&inner, variant_name.clone()) { - inner.clone() - } else { - { - let source_items = - match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - match unique_imported_variant_owner( - variant_name.clone(), - source_items.clone(), - source_indices.clone(), - ) { - Some(parent) => v1_rt::rc_map_insert( - inner.clone(), - variant_name.clone(), - parent.clone(), - ), - None => inner.clone(), + init, + |acc: Rc, imp: Rc| { + let with_glob = if imp.is_all.clone() { + { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.clone().iter().cloned().fold( + acc.clone(), + |iacc: Rc, item: Rc| { + let item_is_coproduct = (item.connective.clone() == Connective::Disj); + if item_is_coproduct.clone() { + bind_coproduct_item_arms( + iacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ) + } else { + iacc.clone() } - } + }, + ) + } + } else { + acc.clone() + }; + imp.specific_names.clone().iter().cloned().fold( + with_glob.clone(), + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms( + nacc.clone(), + item.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => nacc.clone(), + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked( + after_enum.clone(), + name.clone(), + owner.clone(), + source_indices.clone(), + module_name.clone(), + ), + None => after_enum.clone(), } }, ) @@ -13571,94 +13726,6 @@ pub fn build_imported_variants( ) } -// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain -// followers — a module re-exports its specific-name imports, so the binder -// walks the acyclic import chain to the defining module's coproduct. Replaced -// by regen's true emission in the convergence commit. -pub fn owner_of_exported_arm( - module_path: String, - arm_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && item - .children - .iter() - .cloned() - .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == arm_name) - }); - match reexport { - Some(imp) => owner_of_exported_arm( - authored_name_at(source_indices.clone(), imp), - arm_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - -pub fn exported_coproduct_item( - module_path: String, - enum_name: String, - parent_index: Rc>>, - source_indices: Rc>>, -) -> Option> { - match v1_rt::map_get(&parent_index, module_path) { - None => None, - Some(tm) => { - let own = tm.items.iter().cloned().find(|item| { - item.connective.clone() == Connective::Disj - && authored_name_at(source_indices.clone(), item.clone()) == enum_name - }); - match own { - Some(item) => Some(item), - None => { - let reexport = module_imports(tm.module.clone()) - .iter() - .cloned() - .find(|imp| { - !import_is_all(imp.clone()) - && import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .any(|n| *n == enum_name) - }); - match reexport { - Some(imp) => exported_coproduct_item( - authored_name_at(source_indices.clone(), imp), - enum_name, - parent_index, - source_indices, - ), - None => None, - } - } - } - } - } -} - pub fn build_module_context( contributions: Rc>>, parent_index: Rc>>, @@ -13677,134 +13744,21 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional - // realization of the new v1.compiler.infer dag source — replaced - // wholesale by regen output in the convergence commit. Constructor - // namespace is FLAT: local coproduct arms + direct imports' - // contributions; the binding carries the owner NODE; one arm name - // bound to two different owners = VariantCollision (per-file wall). - let insert_variant_owner_checked = |state: Rc, - arm_name: String, - owner: Rc| - -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = - authored_name_at(env.source_indices.clone(), prev.resolved.clone()); - let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); - let same_owner = prev_name == owner_name - && prev.resolved.span.file == owner.span.file - && prev.resolved.span.start == owner.span.start; - if same_owner { - state - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name, - enum1: prev_name, - enum2: owner_name, - span: owner.span.clone(), - }), - module_name.clone(), - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name, - resolved: owner, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } - }; - let bind_coproduct_item_arms = - |state: Rc, item: Rc| -> Rc { - item.children - .clone() - .iter() - .cloned() - .fold(state, |vacc, child| { - insert_variant_owner_checked( - vacc, - authored_name_at(env.source_indices.clone(), child.clone()), - item.clone(), - ) - }) - }; - let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( + let local_variant_fold = build_local_variants( + local.resolved_items.clone(), + env.source_indices.clone(), + module_name.clone(), Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), - |acc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(acc, item) - } else { - acc - } - }, ); - let variant_fold = resolved_imports.clone().iter().cloned().fold( + let variant_fold = build_imported_variants( + resolved_imports.clone(), + parent_index.clone(), + env.source_indices.clone(), + module_name.clone(), local_variant_fold, - |acc: Rc, imp: Rc| { - // Glob (is_all) imports bind the target's OWN coproduct arms only. - let with_glob = if imp.is_all { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.iter().cloned().fold( - acc, - |iacc: Rc, item: Rc| { - if item.connective.clone() == Connective::Disj { - bind_coproduct_item_arms(iacc, item) - } else { - iacc - } - }, - ) - } else { - acc - }; - // Specific names resolve through the re-export chain to the - // defining module (owner_of_exported_arm / exported_coproduct_item). - imp.specific_names.iter().cloned().fold( - with_glob, - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms(nacc, item), - None => nacc, - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - env.source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked(after_enum, name, owner), - None => after_enum, - } - }, - ) - }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13821,7 +13775,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), + Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), None => Rc::new(vec![]), }) .iter() @@ -13834,7 +13788,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name, + module_name.clone(), env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13848,7 +13802,7 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: resolve_result.func_env.clone(), + func_env: (*resolve_result.func_env).clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, variant_locals: env_variant_locals.clone(), @@ -13889,7 +13843,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = env_result.env.clone(); + let env = (*env_result.env).clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13905,7 +13859,7 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: resolved.module.clone(), + module: (*resolved.module).clone(), items: Rc::new(vec![]), type_env: env.clone(), type_env_cache: env_cache.clone(), @@ -13919,10 +13873,10 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), resolved.module.clone()); + authored_name_at(source_indices.clone(), (*resolved.module).clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items(resolved.module.clone()).iter().cloned() { + for item in module_items((*resolved.module).clone()).iter().cloned() { __result.push(analyze_item( item.clone(), env.clone(), @@ -13961,7 +13915,7 @@ pub fn typecheck_module( ); let infer_scope = Rc::new(InferScope { type_env: env.clone(), - func_env: ctx.func_env.clone(), + func_env: (*ctx.func_env).clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13973,7 +13927,7 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push(tir.item.clone()); + __result.push((*tir.item).clone()); } __result }); @@ -13986,7 +13940,7 @@ pub fn typecheck_module( }); let updated_func_env = populate_output_provenance( typed_items.clone(), - ctx.func_env.clone(), + (*ctx.func_env).clone(), env.clone(), data_locals.clone(), ); @@ -14031,12 +13985,12 @@ pub fn typecheck_module( }); let typed_base = module_node( resolved_module_name.clone(), - module_imports(resolved.module.clone()), + module_imports((*resolved.module).clone()), ctx.resolved_items.clone(), - resolved.module.clone().span.clone(), + (*resolved.module).clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: resolved.module.clone().ident_span.clone(), + ident_span: (*resolved.module).clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { @@ -14187,12 +14141,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14210,7 +14164,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14251,11 +14205,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = binding.resolved.clone(); + let pre = (*binding.resolved).clone(); let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - result.resolved.clone(), + (*result.resolved).clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14273,7 +14227,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding, + updated_binding.clone(), ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14344,7 +14298,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); + let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14405,7 +14359,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items .clone() .iter() @@ -14470,7 +14424,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = m.type_env.clone().source_indices.clone(); + let si = (*m.type_env).clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14525,9 +14479,11 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().source_indices.clone(), + )) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14566,7 +14522,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &m.type_env.clone().recursive_type_set.clone(), + &(*m.type_env).clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), + intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14606,6 +14562,8 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, @@ -14715,7 +14673,7 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), typed.module.clone()), + authored_name_at(source_indices.clone(), (*typed.module).clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); @@ -14731,201 +14689,518 @@ pub fn typecheck_modules( continue; } } - } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct StrBindingsRewireAccum { + pub str_bindings: Rc>>, + pub ancestry_str_bindings: Rc>>, +} + +pub fn import_module_path_at( + imp: Rc, + source_indices: Rc>>, +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn local_authority_binding(owner: Rc, name: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values( + &(*owner.type_env).clone().bindings.clone(), + )) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .first() + .cloned() + { + Some(binding) => Some(binding.clone()), + None => None, + } +} + +pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if module_exports_type_name(m.clone(), name.clone()) { + __result.push(m); + } + } + __result + }) + .len() as i64) +} + +pub fn local_authority_for_name_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn local_authority_for_name( + modules: Rc>>, + name: String, +) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for m in modules.iter().cloned() { + if ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) + { + __result.push(m); + } + } + __result + }) + .last() + .cloned() + { + Some(owner) => Some(owner.clone()), + None => None, + } +} + +pub fn module_exports_type_name(m: Rc, name: String) -> bool { + ((Rc::new({ + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + { + if (b.name.clone() == name.clone()) { + __result.push(b); + } + } + __result + }) + .len() as i64) + > 0) +} + +pub fn direct_import_exporter_count( + m: Rc, + name: String, + index: Rc>>, + source_indices: Rc>>, +) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for imp in module_imports((*m.module).clone()).iter().cloned() { + if { + let path = import_module_path_at(imp.clone(), source_indices.clone()); + match v1_rt::map_get(&index, path.clone()) { + Some(parent) => module_exports_type_name(parent.clone(), name.clone()), + None => false, + } + } { + __result.push(imp); + } + } + __result + }) + .len() as i64) +} + +pub fn rewire_inherited_str_binding( + modules: Rc>>, + module_index: Rc>>, + consumer: Rc, + source_indices: Rc>>, + local_names: Rc>, + str_bindings: Rc>>, + ancestry_str_bindings: Rc>>, + name: String, +) -> Rc { + if ((v1_rt::set_contains(&local_names, name.clone()) + || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) + > 1)) + || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) + { + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } else { + match local_authority_for_name(modules.clone(), name.clone()) { + Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { + Some(canonical) => { + let ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings.clone(), + name.clone(), + canonical.clone(), + ); + let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { + Some(_) => v1_rt::rc_map_insert( + str_bindings.clone(), + name.clone(), + canonical.clone(), + ), + None => str_bindings.clone(), + }; + Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }) + } + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + }, + None => Rc::new(StrBindingsRewireAccum { + str_bindings: str_bindings.clone(), + ancestry_str_bindings: ancestry_str_bindings.clone(), + }), + } + } +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + { + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), (*m.module).clone()), + m.clone(), + ) + }, + ); + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + __result.push({ + let local_names = + Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { + v1_rt::rc_set_insert(acc, b.name.clone()) + }); + let ancestry_keys = Rc::new(v1_rt::map_keys( + &(*m.type_env).clone().ancestry_str_bindings.clone(), + )); + let str_keys = + Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); + let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); + let rewired = inherited_keys.clone().iter().cloned().fold( + Rc::new(StrBindingsRewireAccum { + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + }), + |acc: Rc, name: String| { + rewire_inherited_str_binding( + modules.clone(), + index.clone(), + m.clone(), + source_indices.clone(), + local_names.clone(), + acc.str_bindings.clone(), + acc.ancestry_str_bindings.clone(), + name.clone(), + ) + }, + ); + Rc::new(TypedModule { + module: (*m.module).clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: rewired.str_bindings.clone(), + ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), + parents: (*m.type_env).clone().parents.clone(), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: (*m.func_env).clone(), + item_registry: m.item_registry.clone(), + }) + }); + } + __result + }) } } -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, -) -> Rc>> { - record_rewire_type_env_import_str_binding_call(); - fn local_authority_binding(owner: Rc, name: String) -> Option> { - owner - .type_env - .bindings - .values() - .find(|b| b.name.clone() == name) - .cloned() - } - - fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { - modules - .iter() - .filter(|m| module_exports_type_name((**m).clone(), name)) - .count() - } - - fn local_authority_for_name( - modules: Rc>>, - name: String, - ) -> Option> { - // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) - modules + intern_table: Rc, +) -> Rc { + { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() - .rev() - .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - } - - fn module_exports_type_name(m: Rc, name: &str) -> bool { - m.type_env - .bindings - .values() - .any(|b| b.name.as_str() == name) - } - - fn direct_import_exporter_count( - m: Rc, - name: &str, - index: &HashMap>, - source_indices: Rc>>, - ) -> usize { - module_imports(m.module.clone()) - .iter() - .filter(|imp| { - let path = import_module_path_at((*imp).clone(), source_indices.clone()); - index.get(&path).map_or(false, |parent| { - module_exports_type_name(parent.clone(), name) - }) - }) - .count() - } - - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), m.module.clone()), - m.clone(), - ) - }, - ); - - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - let local_names: std::collections::HashSet = m - .type_env - .bindings - .values() - .map(|b| b.name.clone()) - .collect(); - let mut str_bindings = m.type_env.str_bindings.clone(); - let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); - let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { + name: name.clone(), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { + name: "Unit".to_string(), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Optional".to_string(), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() - .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - .filter(|name| !local_names.contains(name)) - .collect(); - inherited_names.sort(); - for name in inherited_names { - if direct_import_exporter_count( - m.clone(), - name.as_str(), - &index, - source_indices.clone(), - ) > 1 - || global_type_exporter_count(modules.clone(), name.as_str()) > 1 - { - continue; - } - if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { - if let Some(canonical) = local_authority_binding(owner, name.clone()) { - if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { - Some(existing) => { - Rc::ptr_eq(&existing.resolved, &canonical.resolved) - && existing.name == canonical.name - } - None => false, - } { - continue; - } - ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings, - name.clone(), - canonical.clone(), - ); - if v1_rt::map_contains_key(&str_bindings, name.clone()) { - str_bindings = - v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); - } - } - } + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } - __result.push(Rc::new(TypedModule { - module: m.module.clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: m.type_env.bindings.clone(), - str_bindings, - ancestry_str_bindings, - parents: m.type_env.parents.clone(), - recursive_types: m.type_env.recursive_types.clone(), - recursive_type_set: m.type_env.recursive_type_set.clone(), - inductive_fields: m.type_env.inductive_fields.clone(), - source_indices: m.type_env.source_indices.clone(), - intern_table: m.type_env.intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), - item_registry: m.item_registry.clone(), - })); - } - __result - }) + __result + }); + let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices, + intern_table: intern_table.clone(), + }) + } } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { - record_rewire_type_env_parent_links_call(); { - let intern_table = modules - .first() - .map(|m| m.type_env.intern_table.clone()) - .unwrap_or_else(empty_intern_table); - let shared_kernel = modules - .iter() - .find_map(|m| { - m.type_env.parents.last().and_then(|kernel| { - if kernel.bindings.is_empty() { - None - } else { - Some(kernel.clone()) - } - }) - }) - .unwrap_or_else(|| { - compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) - }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, ); + let shared_kernel = match modules.clone().iter().cloned().fold( + None, + |acc, m: Rc| match acc.clone() { + Some(_) => acc.clone(), + None => match (*m.type_env).clone().parents.clone().last().cloned() { + Some(kernel) => Some(kernel.clone()), + None => None, + }, + }, + ) { + Some(kernel) => kernel.clone(), + None => match modules.clone().first().cloned() { + Some(m) => compiler_kernel_type_env( + source_indices.clone(), + (*m.type_env).clone().intern_table.clone(), + ), + None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), + }, + }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = @@ -14933,7 +15208,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - parent.type_env.clone(), + (*parent.type_env).clone(), )]), None => Rc::new(vec![]), } @@ -14944,23 +15219,28 @@ pub fn rewire_type_env_parent_links( } __result }); - let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: m.type_env.clone().bindings.clone(), - str_bindings: m.type_env.clone().str_bindings.clone(), - ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), - parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), - recursive_types: m.type_env.clone().recursive_types.clone(), - recursive_type_set: m.type_env.clone().recursive_type_set.clone(), - inductive_fields: m.type_env.clone().inductive_fields.clone(), - source_indices: m.type_env.clone().source_indices.clone(), - intern_table: m.type_env.clone().intern_table.clone(), + bindings: (*m.type_env).clone().bindings.clone(), + str_bindings: (*m.type_env).clone().str_bindings.clone(), + ancestry_str_bindings: (*m.type_env) + .clone() + .ancestry_str_bindings + .clone(), + parents: v1_rt::concat( + import_parents.clone(), + Rc::new(vec![shared_kernel.clone()]), + ), + recursive_types: (*m.type_env).clone().recursive_types.clone(), + recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), + inductive_fields: (*m.type_env).clone().inductive_fields.clone(), + source_indices: (*m.type_env).clone().source_indices.clone(), + intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), + func_env: (*m.func_env).clone(), item_registry: m.item_registry.clone(), }) }); @@ -14980,7 +15260,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at(source_indices.clone(), (*m.module).clone()), m.clone(), ) }, @@ -14991,13 +15271,13 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { + for imp in module_imports((*m.module).clone()).iter().cloned() { __result.extend( (*{ let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![parent.func_env.clone()]), + Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), None => Rc::new(vec![]), } }) @@ -15008,12 +15288,12 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: m.module.clone(), + module: (*m.module).clone(), items: m.items.clone(), - type_env: m.type_env.clone(), + type_env: (*m.type_env).clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: m.func_env.clone().local.clone(), + local: (*m.func_env).clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index c3d02096a6e..0ca86943c45 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -131,7 +131,7 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - parts.key_type.clone(), + (*parts.key_type).clone(), normed_index.clone(), source_indices.clone(), ) { @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality(parts.value_type.clone()), + with_optional_cardinality((*parts.value_type).clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 0dc55228a93..80801b55852 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -229,11 +229,10 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) - .iter() - .map(|b| b.name.clone()) - .collect(); - __result.sort(); + let mut __result = Vec::new(); + for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { + __result.push(b.name.clone()); + } __result }); let name_set = all_names diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 8dc46a13d29..b8089770e47 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,6 +83,8 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, + pub move_sites_index: Rc>>>, + pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -104,6 +106,8 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), @@ -448,8 +452,7 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child - .inferred + |acc: Rc>, child: Rc| match child.inferred .clone() .as_deref() .cloned() diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index dc7b6acbab3..daa958bdc8e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,82 +17,12 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -use std::sync::atomic::{AtomicU64, Ordering}; - -// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). -static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); -static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); -static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); -static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); - -pub fn flatten_visible_parent_recurses() -> u64 { - FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) -} - -pub fn build_type_env_calls() -> u64 { - BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) -} - -pub fn merge_type_env_cache_calls() -> u64 { - MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_parent_links_calls() -> u64 { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) -} - -pub fn rewire_type_env_import_str_binding_calls() -> u64 { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) -} - -pub fn reset_flatten_visible_profile() { - FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); -} - -pub fn reset_type_env_lookup_profile() { - reset_flatten_visible_profile(); - BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); - MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); -} - -pub fn maybe_print_type_env_lookup_profile() { - if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { - eprintln!( - "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", - flatten_visible_parent_recurses(), - build_type_env_calls(), - merge_type_env_cache_calls(), - rewire_type_env_parent_links_calls(), - rewire_type_env_import_str_binding_calls(), - ); - } -} - -pub fn record_flatten_visible_parent_recurse() { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_build_type_env_call() { - BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_parent_links_call() { - REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); -} - -pub fn record_rewire_type_env_import_str_binding_call() { - REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); -} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, - #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -101,10 +31,6 @@ pub struct TypeEnv { pub intern_table: Rc, } -fn empty_type_env_parents() -> Rc>> { - Rc::new(vec![]) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -120,6 +46,60 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } +pub fn type_env_compositional_authority_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_work_count_profiling_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { + thread_local! { + static CACHED: String = { + "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn type_env_cache_key_determinism_authority() -> String { + thread_local! { + static CACHED: String = { + "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn flatten_visible_bindings_invariant() -> String { + thread_local! { + static CACHED: String = { + "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -129,16 +109,34 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn record_merge_type_env_cache_call() { - MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); +pub fn build_type_env_calls() -> i64 { + 0 +} + +pub fn merge_type_env_cache_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_parent_links_calls() -> i64 { + 0 +} + +pub fn rewire_type_env_import_str_binding_calls() -> i64 { + 0 +} + +pub fn type_env_counter_dissolution() -> String { + thread_local! { + static CACHED: String = { + "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { - record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), - // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at - // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -164,42 +162,21 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - let mut pairs: Vec<(String, Rc)> = bindings - .values() - .map(|binding| (binding.name.clone(), binding.clone())) - .collect(); - pairs.sort_by(|a, b| a.0.cmp(&b.0)); - pairs.into_iter().fold( + Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, (name, binding)| { - v1_rt::rc_map_insert(acc, name, binding) - }, - ) -} - -// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value -// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). -#[allow(dead_code)] -pub fn deterministic_str_binding_map( - m: Rc>>, -) -> Rc>> { - let mut keys: Vec = m.keys().cloned().collect(); - keys.sort(); - keys.iter().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, key: &String| { - v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) + |acc: Rc>>, binding: Rc| { + v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings, name.clone()) { + match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { + None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name) { - Some(id) => v1_rt::map_get(&env.bindings, id), + None => match intern_find(env.intern_table.clone(), name.clone()) { + Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), None => None, }, }, @@ -211,7 +188,7 @@ pub fn lookup_binding(env: Rc, ident: i64) -> Option> { Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env, name) + lookup_binding_by_name(env.clone(), name) } } } @@ -224,7 +201,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name.clone()) { + match intern_find(env.intern_table.clone(), name) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } @@ -232,14 +209,14 @@ pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -263,18 +240,26 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) if !fields.is_empty() => fields.clone(), - _ => { - for parent in env.parents.iter() { - let fields = inductive_fields_for(parent.clone(), type_name.clone()); - if !fields.is_empty() { - return fields; - } - } - Rc::new(vec![]) + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) => fields.clone(), + None => Rc::new(vec![]), + }; + if ((local.clone().len() as i64) > 0) { + local.clone() + } else { + env.parents.clone().iter().cloned().fold( + Rc::new(vec![]), + |acc: Rc>>, parent: Rc| { + if ((acc.clone().len() as i64) > 0) { + acc.clone() + } else { + inductive_fields_for(parent.clone(), type_name.clone()) + } + }, + ) } - } + }) } pub fn is_inductive_field( @@ -400,12 +385,27 @@ pub fn inductive_fields_list_to_map( ) } +pub fn flatten_visible_parent_recurses() -> i64 { + 0 +} + +pub fn reset_flatten_visible_profile() -> () { + {} +} + +pub fn reset_type_env_lookup_profile() -> () { + reset_flatten_visible_profile() +} + +pub fn maybe_print_type_env_lookup_profile() -> () { + {} +} + pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { - FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -469,7 +469,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings, + str_bindings: merged_bindings.clone(), ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 02b08953fa8..95a6d52a3d7 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,12 +2,10 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; -pub use crate::std_induction::SubValueRelation; -use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -176,10 +174,13 @@ pub fn item_kind(item: Rc) -> ItemKind { if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) + { ItemKind::FnItem } else { - if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { + if ((item.body.clone() != None) + && (item.type_annotation.clone() != None)) + { ItemKind::DataItem } else { if (item.body.clone() != None) { @@ -196,38 +197,6 @@ pub fn item_kind(item: Rc) -> ItemKind { } } -pub fn variant_locals_from_items( - items: Rc>>, - init: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - items.iter().cloned().fold( - init, - |acc: Rc>>, item: Rc| { - let is_coproduct = (item.connective.clone() == Connective::Disj); - if is_coproduct.clone() { - item.children.clone().iter().cloned().fold( - acc.clone(), - |vacc: Rc>>, child: Rc| { - let child_name = authored_name_at(source_indices.clone(), child.clone()); - v1_rt::rc_map_insert( - vacc, - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: item.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ) - } else { - acc.clone() - } - }, - ) -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index ac704dae929..63743b2107e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some(binding.resolved.clone()), + Some(binding) => Some((*binding.resolved).clone()), None => None, } } @@ -126,12 +126,12 @@ pub fn lookup_field_type_node( None => nominal_type_ref("V".to_string()), }; Some( - make_container_type( + (*make_container_type( "Witness".to_string(), value_child, ) - .ty - .clone(), + .ty) + .clone(), ) } } else { @@ -217,18 +217,14 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - if (resolved.connective.clone() == Connective::Conj) { + let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved.connective.clone() == Connective::Conj) + || ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone()))) + { resolved.clone() } else { - let resolved_name = - authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone())) - { - resolved.clone() - } else { - receiver_type.clone() - } + receiver_type.clone() } } } @@ -503,11 +499,7 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some( - make_container_type("Witness".to_string(), raw.clone()) - .ty - .clone(), - ) + Some((*make_container_type("Witness".to_string(), raw.clone()).ty).clone()) } } None => None, @@ -587,12 +579,12 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if ((enriched.ty.clone().connective.clone() == Connective::Conj) - && ((enriched.ty.clone().children.clone().len() as i64) > 0)) + if (((*enriched.ty).clone().connective.clone() == Connective::Conj) + && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( - enriched.ty.clone(), + (*enriched.ty).clone(), method_name.clone(), source_indices.clone(), ); @@ -621,8 +613,8 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: mfr.field_node.clone(), - result_type: mfr.result_type.clone(), + field_node: (*mfr.field_node).clone(), + result_type: (*mfr.result_type).clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), algebra_template: Some(t.clone()), @@ -668,7 +660,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: mfr.field_node.clone(), + method_def: (*mfr.field_node).clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -676,7 +668,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some(mfr.result_type.clone()), + result_type: Some((*mfr.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -694,7 +686,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some(svc_result.result_type.clone()), + result_type: Some((*svc_result.result_type).clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 96d9884ceb1..12c6fb18bc5 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,28 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - make_map_type( + (*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty - .clone() + .ty) + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)) - .ty - .clone() + (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() } pub fn list_of_element(element: Rc) -> Rc { - make_container_type("List".to_string(), element).ty.clone() + (*make_container_type("List".to_string(), element).ty).clone() } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element) - .ty - .clone() + (*make_container_type("Witness".to_string(), element).ty).clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -127,12 +123,12 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = make_container_type( + let set_ty = (*make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty - .clone(); + .ty) + .clone(); let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); @@ -254,41 +250,6 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_loc".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_total_test_fns".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_module_names".to_string(), - list_of_type_variable("test_migration_debt_module_name_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_debt_known_covered_module_is_not_debt".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_holds".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "test_migration_delete_guard_uncovered_deletes".to_string(), - list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), - ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 1dd9fc95134..4e0bf90d8ff 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,6 +37,148 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), + None => acc.clone(), + } + }, + ) + } +} + +pub fn expand_scrut_from_decl( + decl: Rc, + scrut_node: Rc, + name: String, + env: Rc, +) -> Rc { + { + let decl_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_alias = (((decl.inferred.clone() != None) + && (decl.connective.clone() == Connective::NoConnective)) + && ((decl.children.clone().len() as i64) == 0)); + if decl_is_disj { + decl.clone() + } else { + if has_inferred_alias { + match decl.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node, env.clone()); + substitute_type_slots( + target.clone(), + subst, + name, + env.source_indices.clone(), + ) + } + _ => scrut_node, + } + } else { + scrut_node + } + } + } +} + +pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { + { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())); + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if is_generic_use { + expand_scrut_from_decl( + decl.clone(), + scrut_node.clone(), + name.clone(), + env.clone(), + ) + } else { + { + let def_is_disj = (decl.connective.clone() == Connective::Disj); + let has_inferred_body = ((decl.inferred.clone() != None) + && (decl.connective.clone() == Connective::NoConnective)); + if def_is_disj { + decl.clone() + } else { + if has_inferred_body { + match decl.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let target_is_disj = + (target.connective.clone() == Connective::Disj); + if target_is_disj { + target.clone() + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + } + } + } + None => scrut_node.clone(), + } + } +} + +pub fn expand_scrut_type_for_variant_lookup( + mut scrut_node: Rc, + mut env: Rc, +) -> Rc { + loop { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + let is_disj = (scrut_node.connective.clone() == Connective::Disj); + let is_witness = is_witness_type_name(name); + if (is_disj || is_witness) { + break scrut_node.clone(); + } else { + match scrut_node.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let __tco_0 = target.clone(); + scrut_node = __tco_0; + continue; + } + _ => { + break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); + } + } + } + } +} + pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -327,102 +469,6 @@ pub fn variant_not_found_result( )])) } -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), - None => acc, - } - }, - ) -} - -pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { - return scrut_node.clone(); - } - if (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())) - { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if (((decl.inferred.clone() != None) - && ((decl.children.clone().len() as i64) == 0)) - && (decl.connective.clone() == Connective::NoConnective)) - { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); - let expanded = substitute_type_slots( - target, - subst, - name.clone(), - env.source_indices.clone(), - ); - return expanded; - } - _ => scrut_node.clone(), - } - } else if (decl.connective.clone() == Connective::Disj) { - decl.clone() - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } else { - match lookup_type_by_name(env.clone(), name.clone()) { - Some(def) => { - if (def.connective.clone() == Connective::Disj) { - def.clone() - } else if ((def.inferred.clone() != None) - && (def.connective.clone() == Connective::NoConnective)) - { - match def.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - if (target.connective.clone() == Connective::Disj) { - target - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - None => scrut_node.clone(), - } - } -} - pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 84f1b36551f..93bb2d20793 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, - is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, + lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -117,24 +117,41 @@ pub fn lookup_unit_variant_phantom_type( } } +pub fn phantom_match_flat_scope() -> String { + thread_local! { + static CACHED: String = { + "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), + { + let direct_bindings = env.parents.clone().iter().cloned().fold( + env.str_bindings.clone(), + |acc: Rc>>, parent: Rc| { + v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) }, - ) + ); + Rc::new(v1_rt::map_values(&direct_bindings)) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), + }, + ) + } } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -179,13 +196,22 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { + thread_local! { + static CACHED: String = { + "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) + && is_kernel_type(authored_name_at(source_indices, structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -194,9 +220,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone() != "".to_string()) + if ((((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone()) + && !is_declared_container_alias_spelling(brand_name.clone())) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -216,32 +242,34 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S && (resolved.inferred.clone() != None)) { match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved - .clone(), - _ => resolve_node_bounded( + Some(InferredNode::Resolved { node: target, .. }) => { + (*resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved) + .clone() + } + _ => (*resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved - .clone(), + .resolved) + .clone(), } } else { - resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved + (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved) .clone() }; - if (((brand.clone() != "".to_string()) + if ((((brand.clone() != "".to_string()) && (brand.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand.clone()) + && !is_declared_container_alias_spelling(brand.clone())) && !is_transparent_primitive_alias_rhs( structural.clone(), source_indices.clone(), @@ -255,14 +283,14 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = resolve_node_bounded( + let target_resolved = (*resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), 0, ) - .resolved - .clone(); + .resolved) + .clone(); with_authored_identity(n.clone(), target_resolved) } _ => resolved.clone(), @@ -347,6 +375,61 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { + thread_local! { + static CACHED: String = { + "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + +pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { + match Rc::new({ + let mut __result = Vec::new(); + for parent in env.parents.clone().iter().cloned() { + if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), + None => false, + } { + __result.push(parent); + } + } + __result + }) + .first() + .cloned() + { + Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { + Some(b) => Some((*b.resolved).clone()), + None => None, + }, + None => None, + } +} + +pub fn resolve_paramless_generic_use_decl( + env: Rc, + n: Rc, + decl: Rc, + brand: String, +) -> Rc { + match ((n.children.clone().len() as i64) > 0) { + true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { + Some(user_decl) => user_decl.clone(), + None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) + { + true => match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural.clone(), + None => decl, + }, + false => decl, + }, + }, + false => decl, + } +} + pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); @@ -354,45 +437,8 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { decl.clone() - } else if ((n.children.clone().len() as i64) > 0) { - // HAND-PATCH (parameterized use site prefers parameterized - // decl; replaced at regen): a use site WITH type args whose - // primary lookup lands paramless (kernel prelude shadowing - // an imported user generic, e.g. Optional) retries the - // ancestry binding for a parameterized decl. - let ancestry_generic = env.parents.iter().fold( - None, - |acc: Option>, parent: &Rc| { - if acc.is_some() { - return acc; - } - match v1_rt::map_get(&parent.str_bindings, brand.clone()) { - Some(b) => { - if ((b.resolved.params.clone().len() as i64) > 0) { - Some(b.resolved.clone()) - } else { - acc - } - } - None => acc, - } - }, - ); - match ancestry_generic { - Some(user_decl) => user_decl, - None => { - if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { - match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl.clone(), - } - } else { - decl.clone() - } - } - } } else { - decl.clone() + resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { @@ -578,8 +624,7 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) - .resolved + (*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) .clone() } AliasKind::AliasLeaf => match lookup_type_by_name( @@ -625,7 +670,7 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); @@ -706,7 +751,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let base_resolved = base_result.resolved.clone(); + let base_resolved = (*base_result.resolved).clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -756,7 +801,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = rt_result.resolved.clone(); + let rt_resolved = (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -781,7 +826,8 @@ pub fn resolve_node_bounded( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation.clone(), + type_annotation: child.type_annotation + .clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -798,7 +844,7 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.resolved.clone()); + __result.push((*cr.resolved).clone()); } __result }); @@ -847,7 +893,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = inner_result.resolved.clone(); + let inner_resolved = (*inner_result.resolved).clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: with_optional_cardinality(inner_resolved), @@ -866,7 +912,8 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) { + if (field_child.inferred.clone() == None) + { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -907,7 +954,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - rt_result.resolved.clone(); + (*rt_result.resolved).clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -944,7 +991,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.resolved.clone()); + __result.push((*fr.resolved).clone()); } __result }); @@ -991,7 +1038,7 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push(vr.resolved.clone()); + __result.push((*vr.resolved).clone()); } __result }); @@ -1067,7 +1114,7 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push(ar.resolved.clone()); + __result.push((*ar.resolved).clone()); } __result }); @@ -1164,15 +1211,15 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: target_result.resolved.clone().children.clone(), - connective: target_result.resolved.clone().connective.clone(), + children: (*target_result.resolved).clone().children.clone(), + connective: (*target_result.resolved).clone().connective.clone(), params: Rc::new(vec![]), - inferred: target_result.resolved.clone().inferred.clone(), + inferred: (*target_result.resolved).clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), + properties: (*target_result.resolved).clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1194,7 +1241,7 @@ pub fn resolve_node_bounded( uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: target_result.resolved.clone().properties.clone(), + properties: (*target_result.resolved).clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1297,7 +1344,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = key_result.resolved.clone(); + let key_resolved = (*key_result.resolved).clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1305,7 +1352,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = val_result.resolved.clone(); + let val_resolved = (*val_result.resolved).clone(); let val_diags = val_result.diagnostics.clone(); let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) @@ -1404,9 +1451,10 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = el_result.resolved.clone(); + let el_resolved = (*el_result.resolved).clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() != None) + let el_param_name = if (child_node.inferred.clone() + != None) { authored_name(env.clone(), child_node.clone()) } else { @@ -1472,26 +1520,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = - match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: target, .. - }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) - > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = match n.inferred + .clone() + .as_deref() + .cloned() + { + Some(InferredNode::Resolved { node: target, .. }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1510,8 +1558,7 @@ pub fn resolve_node_bounded( == 0)) && (resolved.inferred.clone() != None)) { - match resolved - .inferred + match resolved.inferred .clone() .as_deref() .cloned() @@ -1539,14 +1586,14 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - resolve_node_bounded( + (*resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved - .clone() + .resolved) + .clone() } else { target.clone() } @@ -1569,7 +1616,8 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) { + let n_is_error = if (n.inferred.clone() != None) + { is_compiler_error( n.inferred.clone().clone().unwrap(), ) @@ -1578,14 +1626,14 @@ pub fn resolve_node_bounded( }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = if (n.inferred.clone() != None) - { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = + if (n.inferred.clone() != None) { + is_type_variable( + n.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1725,7 +1773,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), missing_generic_args_diagnostics( @@ -1752,7 +1800,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> type_resolved, field_node_cardinality(field.clone()), match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1768,7 +1816,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1816,7 +1864,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> None => Rc::new(vec![]), }; let default_expr = match default_resolved.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }; Rc::new(ParamResult { @@ -1840,7 +1888,7 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = type_result.resolved.clone(); + let type_resolved = (*type_result.resolved).clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( @@ -1861,7 +1909,7 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( @@ -1886,7 +1934,7 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = value_result.expr.clone(); + let value_expr = (*value_result.expr).clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( @@ -1921,13 +1969,13 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = body_result.expr.clone(); + let body_expr = (*body_result.expr).clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( arm_pattern(arm.clone()), match guard_result.clone() { - Some(result) => Some(result.expr.clone()), + Some(result) => Some((*result.expr).clone()), None => None, }, body_expr, @@ -1952,7 +2000,7 @@ pub fn resolve_string_part( }), StringPart::Interpolation { expr: expr, .. } => { let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = expr_result.expr.clone(); + let resolved_expr = (*expr_result.expr).clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { @@ -1988,7 +2036,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - val_result.expr.clone(), + (*val_result.expr).clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2001,7 +2049,7 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); @@ -2026,7 +2074,7 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.expr.clone()); + __result.push((*cr.expr).clone()); } __result }); @@ -2101,7 +2149,7 @@ pub fn resolve_expr_types( }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| r.expr.clone()), + expr: map_children(texpr.clone(), |child| (*r.expr).clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2127,7 +2175,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - vr.expr.clone(), + (*vr.expr).clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2140,7 +2188,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2196,7 +2244,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: rr.expr.clone(), + expr: (*rr.expr).clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2221,7 +2269,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - vr.expr.clone(), + (*vr.expr).clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2236,7 +2284,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2288,7 +2336,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: sr.expr.clone(), + expr: (*sr.expr).clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2327,8 +2375,8 @@ pub fn resolve_expr_types( Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some(guard_r.expr.clone()), - body_r.expr.clone(), + Some((*guard_r.expr).clone()), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2357,7 +2405,7 @@ pub fn resolve_expr_types( None => Rc::new(MatchPattern::Wildcard), }, None, - body_r.expr.clone(), + (*body_r.expr).clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2373,7 +2421,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2419,8 +2467,12 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), + Some(r) => Rc::new(vec![ + (*cr.expr).clone(), + (*tr.expr).clone(), + (*r.expr).clone(), + ]), + None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( @@ -2456,8 +2508,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), - None => Rc::new(vec![vr.expr.clone()]), + Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), + None => Rc::new(vec![(*vr.expr).clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( @@ -2493,7 +2545,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - vr.expr.clone(), + (*vr.expr).clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2506,7 +2558,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2546,7 +2598,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2593,7 +2645,7 @@ pub fn resolve_expr_types( op: op.clone(), algebra_field: af.clone(), }), - Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), + Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2611,7 +2663,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![r.expr.clone()]), + Rc::new(vec![(*r.expr).clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2638,7 +2690,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), + v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2663,7 +2715,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - r.expr.clone(), + (*r.expr).clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2681,7 +2733,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2717,7 +2769,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push(r.expr.clone()); + __result.push((*r.expr).clone()); } __result }); @@ -2759,7 +2811,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), + Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2786,7 +2838,7 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![cr.expr.clone(), br.expr.clone()]), + Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), @@ -2817,7 +2869,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![br.expr.clone(), ir.expr.clone()]), + Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2856,7 +2908,11 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), + Rc::new(vec![ + (*br.expr).clone(), + (*sr.expr).clone(), + (*er.expr).clone(), + ]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2879,7 +2935,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![r.expr.clone()]), + Rc::new(vec![(*r.expr).clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -3028,7 +3084,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding, + tp_binding.clone(), ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3050,7 +3106,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push(pr.param.clone()); + __result.push((*pr.param).clone()); } __result }); @@ -3070,12 +3126,16 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) env.clone(), module_name.clone(), ), - _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), + _ => resolve_optional_node( + item.inferred.clone(), + env.clone(), + module_name.clone(), + ), } } else { resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; - let ret_resolved = ret_result.resolved.clone(); + let ret_resolved = (*ret_result.resolved).clone(); let ret_diags = ret_result.diagnostics.clone(); let resolved_ret = if (item.inferred.clone() == None) { None @@ -3096,7 +3156,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push(ur.resource_use.clone()); + __result.push((*ur.resource_use).clone()); } __result }); @@ -3122,7 +3182,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_body = if (item.body.clone() == None) { None } else { - Some(body_resolved.expr.clone()) + Some((*body_resolved.expr).clone()) }; let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) @@ -3144,7 +3204,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_anno = if (item.type_annotation.clone() == None) { None } else { - Some(anno_resolved.resolved.clone()) + Some((*anno_resolved.resolved).clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); let transport_resolved = if (item.transport.clone() == None) { @@ -3162,7 +3222,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_transport = if (item.transport.clone() == None) { None } else { - Some(transport_resolved.transport.clone()) + Some((*transport_resolved.transport).clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3179,7 +3239,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push(pr.field_init.clone()); + __result.push((*pr.field_init).clone()); } __result }); @@ -3223,7 +3283,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), type_annotation: child.type_annotation.clone(), is_self_recursive: false, @@ -3239,7 +3299,9 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { + if ((item.connective.clone() == Connective::Disj) + && (item.transport.clone() == None)) + { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3279,7 +3341,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), - tr.resolved.clone().properties.clone(), + (*tr.resolved).clone().properties.clone(), ), type_annotation: field.type_annotation.clone(), is_self_recursive: false, @@ -3297,7 +3359,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push(fr.item.clone()); + __result.push((*fr.item).clone()); } __result }); @@ -3352,7 +3414,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push(cr.item.clone()); + __result.push((*cr.item).clone()); } __result }); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 76923b77bc0..8d0917f731a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,7 +210,7 @@ pub fn expand_transitive_services_once( registry: Rc>>, ) -> Rc>> { modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { let has_no_body = (item.body.clone() == None); @@ -218,7 +218,7 @@ if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index ef23eba9abf..5d4fde8c998 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -498,7 +498,8 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) + { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 27e0642597b..74bdb302d18 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -866,9 +866,9 @@ pub fn instantiate_algebra_type( }; let inner_b = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, inner_b.ty.clone()); + let built = make_container_type(kind_name, (*inner_b.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -879,16 +879,16 @@ pub fn instantiate_algebra_type( let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -928,13 +928,13 @@ pub fn instantiate_algebra_type( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, rb.ty.clone()), + ty: make_callable_type(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,7 +962,7 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -974,7 +974,7 @@ pub fn instantiate_algebra_field( __result }); let return_b = instantiate_algebra_type( - template.return_type.clone(), + (*template.return_type).clone(), base.clone(), source_indices.clone(), ); @@ -982,10 +982,10 @@ pub fn instantiate_algebra_field( algebra_method_field( template.name.clone(), param_types.clone(), - return_b.ty.clone(), + (*return_b.ty).clone(), ) } else { - algebra_value_field(template.name.clone(), return_b.ty.clone()) + algebra_value_field(template.name.clone(), (*return_b.ty).clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1017,7 +1017,7 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -1475,9 +1475,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, inner_applied.ty.clone()); + let built = make_container_type(kind_name, (*inner_applied.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1492,7 +1492,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality(ib.ty.clone()), + ty: with_optional_cardinality((*ib.ty).clone()), diagnostics: ib.diagnostics.clone(), }) } @@ -1503,9 +1503,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), ib.ty.clone()); + let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); Rc::new(KernelTypeBuild { - ty: built.ty.clone(), + ty: (*built.ty).clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), + ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1551,7 +1551,7 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push(b.ty.clone()); + __result.push((*b.ty).clone()); } __result }); @@ -1583,7 +1583,7 @@ pub fn apply_type_substitution( } __result }), - rb.ty.clone(), + (*rb.ty).clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1592,11 +1592,11 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self(template.return_type.clone()) + is_receiver_self((*template.return_type).clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable(template.return_type.clone()) + has_type_variable((*template.return_type).clone()) } pub fn has_type_variable(t: Rc) -> bool { @@ -1631,7 +1631,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - template.return_type.clone(), + (*template.return_type).clone(), subst, receiver_type.clone(), source_indices.clone(), @@ -2291,8 +2291,7 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left - .inferred + match left.inferred .clone() .as_deref() .cloned() @@ -2300,8 +2299,7 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right - .inferred + }) => match right.inferred .clone() .as_deref() .cloned() @@ -2641,7 +2639,11 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { + Some(m) => match (*m.field_node).clone().inferred + .clone() + .as_deref() + .cloned() + { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { match rt.inferred.clone().as_deref().cloned() { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 0da15e2a8e5..e0740a56f2b 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -187,14 +187,17 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items(m.module.clone()); + let items = module_items((*m.module).clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { __result.extend( (*check_bare_containers( item.clone(), - authored_name_at(source_indices.clone(), m.module.clone()), + authored_name_at( + source_indices.clone(), + (*m.module).clone(), + ), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 160e9fc850f..0c41f844575 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,14 +690,39 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn build_movable_set(proof: Rc) -> Rc> { +pub fn whole_value_borrow_count(usage: Rc) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for c in usage.consumers.clone().iter().cloned() { + if match c.kind.clone() { + EdgeKind::Read => true, + EdgeKind::Threaded => true, + _ => false, + } { + __result.push(c); + } + } + __result + }) + .len() as i64) +} + +pub fn build_movable_set( + proof: Rc, + param_names: Rc>, +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) + if ((match (*make_decision(usage.clone())).clone() { + OwnershipDecision::SoleOwner { .. } => true, + _ => false, + } && (whole_value_borrow_count(usage.clone()) == 0)) + && (is_owned_local(usage.binding_kind.clone()) + || v1_rt::set_contains(¶m_names, usage.name.clone()))) { __result.push(usage); } @@ -1233,6 +1258,337 @@ pub fn analyze_ownership( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiveState { + pub name: String, + pub whole: bool, + pub any_field: bool, + pub fields: Rc>, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct MoveLicenseAccum { + pub live: Rc>>, + pub licensed: Rc>, +} + +pub fn move_site_key(name: String, span_start: i64) -> String { + v1_rt::concat( + v1_rt::concat(name, "@".to_string()), + (span_start).to_string(), + ) +} + +pub fn empty_live_state(name: String) -> Rc { + Rc::new(LiveState { + name: name, + whole: false, + any_field: false, + fields: v1_rt::rc_empty_set::(), + }) +} + +pub fn live_state_of(acc: Rc, name: String) -> Rc { + match v1_rt::map_get(&acc.live.clone(), name.clone()) { + Some(st) => st.clone(), + None => empty_live_state(name.clone()), + } +} + +pub fn record_whole_use_site( + acc: Rc, + name: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !st.any_field.clone()); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: true, + any_field: st.any_field.clone(), + fields: st.fields.clone(), + }), + ), + licensed: licensed, + }) + } +} + +pub fn record_field_use_site( + acc: Rc, + name: String, + field: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !v1_rt::set_contains(&st.fields.clone(), field.clone())); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: st.whole.clone(), + any_field: true, + fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), + }), + ), + licensed: licensed, + }) + } +} + +pub fn merge_live_states(a: Rc, b: Rc) -> Rc { + Rc::new(LiveState { + name: a.name.clone(), + whole: (a.whole.clone() || b.whole.clone()), + any_field: (a.any_field.clone() || b.any_field.clone()), + fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), + }) +} + +pub fn merge_branch_licenses(branches: Rc>>) -> Rc { + branches.iter().cloned().fold( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + |acc: Rc, br: Rc| { + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + { + let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) + .iter() + .cloned() + .fold( + acc.live, + |lm: Rc>>, k: String| { + let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { + Some(s) => s.clone(), + None => empty_live_state(k.clone()), + }; + match v1_rt::map_get(&lm, k.clone()) { + Some(a_st) => v1_rt::rc_map_insert( + lm.clone(), + k.clone(), + merge_live_states(a_st.clone(), b_st.clone()), + ), + None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), + } + }, + ); + let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) + .iter() + .cloned() + .fold(acc.licensed, |l: Rc>, k: String| { + v1_rt::rc_map_insert(l, k.clone(), true) + }); + Rc::new(MoveLicenseAccum { + live: live_merged.clone(), + licensed: lic_merged.clone(), + }) + } + }, + ) +} + +pub fn license_walk( + acc: Rc, + texpr: Rc, + in_capture: bool, + si: Rc>>, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + match (*texpr.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_whole_use_site( + acc.clone(), + expr_var_name_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + ExprData::ExprLiteral { value: _, .. } => acc.clone(), + ExprData::ExprFieldAccess { .. } => { + let base_node = field_access_base(texpr.clone()); + match (*base_node.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_field_use_site( + acc.clone(), + expr_var_name_at(base_node.clone(), si.clone()), + field_access_field_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + _ => license_walk( + acc.clone(), + base_node.clone(), + in_capture.clone(), + si.clone(), + ), + } + } + ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }), + ExprData::ExprMethodCall { .. } => { + let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }); + license_walk( + args_acc, + method_receiver(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprIf => { + let t_acc = license_walk( + acc.clone(), + if_then_branch(texpr.clone()), + in_capture.clone(), + si.clone(), + ); + let e_acc = match if_else_branch(texpr.clone()) { + Some(eb) => { + license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) + } + None => acc.clone(), + }; + let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); + license_walk( + merged, + if_condition(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprMatch => { + let branch_accs = Rc::new({ + let mut __result = Vec::new(); + for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { + __result.push(license_walk( + acc.clone(), + arm_body(arm_node.clone()), + in_capture.clone(), + si.clone(), + )); + } + __result + }); + let merged = merge_branch_licenses(branch_accs); + license_walk( + merged, + match_scrutinee(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprLet => { + let body_acc = match let_body(texpr.clone()) { + Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), + None => acc.clone(), + }; + license_walk( + body_acc, + let_value(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprLambda => { + license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) + } + ExprData::ExprForEach => { + let body_acc = + license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); + license_walk( + body_acc, + foreach_collection(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, field: Rc| { + license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) + }), + _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + } + }) +} + +pub fn build_move_site_licenses( + body: Rc, + si: Rc>>, +) -> Rc> { + { + let walked = license_walk( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + body, + false, + si, + ); + walked.licensed.clone() + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index b2340d2e960..c1414cba6ac 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::ParseError; +use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,7 +91,11 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream.all.clone().get(stream.pos.clone() as usize).cloned() + stream + .all + .clone() + .get((stream.pos.clone()) as usize) + .cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -2076,7 +2080,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some(r.module.clone()), + module: Some((*r.module).clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2231,7 +2235,7 @@ pub fn parse_imports_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r.import.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r.import).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2279,7 +2283,7 @@ pub fn parse_items_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r.item.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r.item).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -3422,7 +3426,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![rv.variant.clone()]), + Rc::new(vec![(*rv.variant).clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3500,7 +3504,7 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = r.variant.clone(); + let first_variant = (*r.variant).clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), @@ -3571,7 +3575,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3590,7 +3594,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3627,7 +3631,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - r.type_expr.clone(), + (*r.type_expr).clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3646,7 +3650,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: wr.type_expr.clone(), + node: (*wr.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3774,7 +3778,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -4295,11 +4299,11 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), Cardinality::Required, None, None, - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4475,7 +4479,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); + let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4673,7 +4677,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: ret.type_expr.clone(), + node: (*ret.type_expr).clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4708,10 +4712,10 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - r.type_expr.clone(), + (*r.type_expr).clone(), None, - r.type_expr.clone().span.clone(), - r.type_expr.clone().span.clone(), + (*r.type_expr).clone().span.clone(), + (*r.type_expr).clone().span.clone(), ); acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4758,7 +4762,7 @@ pub fn finish_type_expr_from_name( if has_err(r.err.clone()) { return r.clone(); } - let first_arg = r.type_expr.clone(); + let first_arg = (*r.type_expr).clone(); let type_args = collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { @@ -4916,7 +4920,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); + let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -5017,7 +5021,7 @@ pub fn parse_field_list_acc( }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); + let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -5079,7 +5083,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let __tco_0 = __ec.clone(); @@ -5932,23 +5936,23 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - r3.type_expr.clone(), + (*r3.type_expr).clone(), start_span.clone(), r.span.clone(), ); @@ -6035,7 +6039,7 @@ pub fn parse_resource_config_acc( err: r3.err.clone(), }); } - let fi = make_field_init_node(field_name, r3.expr.clone(), zero_span, r.span.clone()); + let fi = make_field_init_node(field_name, (*r3.expr).clone(), zero_span, r.span.clone()); acc = v1_rt::rc_list_push(acc.clone(), fi); match (*eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { @@ -6071,7 +6075,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: r.type_expr.clone(), + node: (*r.type_expr).clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6237,7 +6241,7 @@ pub fn parse_service_after_kw( ); let svc_props = match r.config.clone() { Some(cfg) => service_config_properties( - cfg.endpoint.clone(), + (*cfg.endpoint).clone(), cfg.auth.clone(), cfg.auth_input.clone(), cfg.auth_source.clone(), @@ -6257,7 +6261,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some(r.transport.clone()), + transport: Some((*r.transport).clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6382,7 +6386,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.transport.clone(); + let __tco_2 = (*r.transport).clone(); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -6421,7 +6425,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); + let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6563,32 +6567,32 @@ pub fn parse_config_fields( }; match fname.as_str() { "endpoint" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); retry = __tco_0; continue; } @@ -6636,7 +6640,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6655,7 +6659,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6682,7 +6686,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6701,7 +6705,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6728,7 +6732,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6747,7 +6751,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: r2.transport.clone(), + transport: (*r2.transport).clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6875,49 +6879,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some(r3.expr.clone()); + let __tco_0 = Some((*r3.expr).clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*r3.expr.clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), + let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -7056,7 +7060,7 @@ pub fn parse_shell_fields( }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7162,7 +7166,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some(r3.expr.clone()); + let __tco_1 = Some((*r3.expr).clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7666,7 +7670,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some(r.transport.clone()); + let __tco_2 = Some((*r.transport).clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -8132,7 +8136,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = r.expr.clone(); + let code = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8161,7 +8165,7 @@ pub fn parse_exit_entries_acc( _ => r3.tokens.clone(), }; let code_str = status_expr_to_str(code, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( prop_name, @@ -8170,10 +8174,10 @@ pub fn parse_exit_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8459,7 +8463,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8479,7 +8483,7 @@ pub fn parse_response_entries_acc( }); } let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); + let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( prop_name, @@ -8488,10 +8492,10 @@ pub fn parse_response_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - r3.type_expr.clone().span.clone(), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), + (*r3.type_expr).clone().span.clone(), ), - r3.type_expr.clone().span.clone(), + (*r3.type_expr).clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8608,7 +8612,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = r.expr.clone(); + let status = (*r.expr).clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8627,7 +8631,7 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = r3.expr.clone(); + let body = (*r3.expr).clone(); let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), @@ -8858,7 +8862,8 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); + let __tco_2 = + v1_rt::rc_list_push(capabilities, (*r.capability).clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8978,7 +8983,7 @@ pub fn parse_resource_entries( } let fi = make_field_init_node( fname, - r3.expr.clone(), + (*r3.expr).clone(), make_span(0, 0), r.span.clone(), ); @@ -9474,7 +9479,7 @@ pub fn parse_data_after_kw( err: r.err.clone(), }); } - let te = r.type_expr.clone(); + let te = (*r.type_expr).clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r.err.clone()) { return Rc::new(ItemResult { @@ -9502,7 +9507,7 @@ pub fn parse_data_after_kw( inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(r.expr.clone()), + body: Some((*r.expr).clone()), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -9587,7 +9592,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9660,7 +9665,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(r3.expr.clone()), + EatResult::EatConsumed { .. } => Some((*r3.expr).clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { name: name, span: span, ident_span: Some(name_span), - children: Rc::new(vec![r3.expr.clone()]), + children: Rc::new(vec![(*r3.expr).clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: ret.inferred.clone(), @@ -10105,7 +10110,7 @@ pub fn parse_bare_assignment(tokens: Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![r3.expr.clone()]), + Rc::new(vec![(*r3.expr).clone()]), None, span, name_span, @@ -10164,7 +10169,7 @@ pub fn parse_expr_bp( if has_err(r.err.clone()) { return r.clone(); } - let lhs = r.expr.clone(); + let lhs = (*r.expr).clone(); parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10199,7 +10204,7 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = post.expr.clone(); + let __tco_2 = (*post.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10261,7 +10266,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10270,7 +10275,7 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = r.expr.clone(); + let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; lhs = __tco_2; @@ -10285,7 +10290,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10304,7 +10309,7 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - r.expr.clone(), + (*r.expr).clone(), ]), None, loop_span, @@ -10515,7 +10520,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -11385,13 +11390,13 @@ pub fn parse_index_or_slice( let r = parse_expr(r.tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let first_expr = r.expr.clone(); + let first_expr = (*r.expr).clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11399,13 +11404,13 @@ pub fn parse_index_or_slice( let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: r.expr.clone(), + expr: (*r.expr).clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), }); } - let end_expr = r.expr.clone(); + let end_expr = (*r.expr).clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11520,7 +11525,7 @@ pub fn parse_arg_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), r.arg.clone()); + acc = v1_rt::rc_list_push(acc.clone(), (*r.arg).clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -11576,7 +11581,8 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some(r.expr.clone()), + guard: Some((*r.expr).clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12481,7 +12487,7 @@ pub fn parse_variant_pattern( } let fb = make_field_binding_node( "0".to_string(), - r.pattern.clone(), + (*r.pattern).clone(), span, kernel_span("0".to_string()), ); @@ -12567,7 +12573,7 @@ pub fn parse_variant_bindings_brace_acc( }); let fb = make_field_binding_node( field_name.clone(), - r2.pattern.clone(), + (*r2.pattern).clone(), bind_span, field_name_span, ); @@ -12631,7 +12637,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index a0826e3e1bf..d3042fd1aa4 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -229,12 +229,6 @@ pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() } -pub fn sorted_map_keys(m: &HashMap) -> Vec { - let mut keys = map_keys(m); - keys.sort(); - keys -} - pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -335,40 +329,6 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. -// take_owned_counted: the fail-closed replacement for the silent -// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: -// a failure arm must refuse or be counted, never silently widen). The ownership -// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose -// per-site frequency must stay observable, so the clone arm counts per emitted -// site (site = ":" of the use-site the emitter rewrote). -thread_local! { - static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = - std::cell::RefCell::new(HashMap::new()); -} - -pub fn take_owned_counted(x: Rc, site: &'static str) -> T { - Rc::try_unwrap(x).unwrap_or_else(|rc| { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); - (*rc).clone() - }) -} - -pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| { - let mut v: Vec<(String, u64)> = m - .borrow() - .iter() - .map(|(site, n)| (site.to_string(), *n)) - .collect(); - v.sort(); - v - }) -} - -pub fn reset_take_owned_clone_fallbacks() { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); -} - pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From c12fa613d767489cf4db90d6415b540892ffab11 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 04:36:16 +0000 Subject: [PATCH 18/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_compile.rs | 4 +- src/v1/stage0/src/v1_compiler_complexity.rs | 254 ++++---- src/v1/stage0/src/v1_compiler_emit.rs | 32 +- .../src/v1_compiler_emit_core_support.rs | 2 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 18 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 20 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 148 ++--- src/v1/stage0/src/v1_compiler_infer.rs | 550 +++++++++--------- src/v1/stage0/src/v1_compiler_infer_access.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 16 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 16 +- .../stage0/src/v1_compiler_infer_resolve.rs | 96 +-- src/v1/stage0/src/v1_compiler_infer_types.rs | 42 +- src/v1/stage0/src/v1_compiler_normalize.rs | 4 +- src/v1/stage0/src/v1_compiler_parse.rs | 242 ++++---- 16 files changed, 726 insertions(+), 726 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index bd68c32eb6e..8f308b2e03b 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -1894,7 +1894,7 @@ pub fn serialize_typed_module( v1_rt::concat( v1_rt::concat( "{\"module\": ".to_string(), - serialize_node_ref((*module.module).clone(), key_to_id.clone()), + serialize_node_ref(module.module.clone(), key_to_id.clone()), ), ", \"items\": ".to_string(), ), @@ -2431,7 +2431,7 @@ pub fn emit_resolved_for_target( for m in typed.modules.clone().iter().cloned() { __result.push(authored_name_at( resolved.source_indices.clone(), - (*m.module).clone(), + m.module.clone(), )); } __result diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 182e9e48cc2..ae8cc3fc7d2 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -1372,7 +1372,7 @@ pub fn parser_member_is_always_advancing( Some(state_param) => { let edges = collect_parser_progress_edges( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), parser_name_set, empty_parser_progress_env(), @@ -1393,7 +1393,7 @@ pub fn parser_member_is_always_advancing( } __all } && (parser_success_progress( - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), empty_parser_progress_env(), proven.clone(), @@ -1671,7 +1671,7 @@ pub fn collect_parser_edges_for_scc( match parser_state_param(entry.params.clone(), si.clone()) { Some(state_param) => collect_parser_progress_edges( name.clone(), - (*entry.body).clone(), + entry.body.clone(), state_param.clone(), scc_name_set.clone(), empty_parser_progress_env(), @@ -2208,7 +2208,7 @@ pub fn build_scc_measure_params( acc.clone(), name.clone(), recursive_measure_param_names( - (*entry.body).clone(), + entry.body.clone(), entry.params.clone(), si.clone(), ), @@ -5757,7 +5757,7 @@ pub fn build_call_graph( __result.extend( (*collect_local_call_edges_in_expr( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), local_func_set.clone(), si.clone(), )) @@ -6478,7 +6478,7 @@ pub fn is_scc_container_child_descent( |best: _, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); let descent_vars = collect_descent_vars( - (*entry.body).clone(), + entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, @@ -6486,7 +6486,7 @@ pub fn is_scc_container_child_descent( si.clone(), ); let param_edges = collect_scc_child_edges( - (*entry.body).clone(), + entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), @@ -6579,8 +6579,8 @@ pub fn collect_scc_proof_edges_for_dim( Some(entry) => { let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); +let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); @@ -6654,15 +6654,15 @@ pub fn collect_scc_independent_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); +let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6736,8 +6736,8 @@ pub fn collect_scc_tree_parser_dim_edges( Some(entry) => { let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars((*entry.body).clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); -let param_edges = collect_scc_child_edges((*entry.body).clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); @@ -6785,7 +6785,7 @@ pub fn collect_scc_cx_l2_tree_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let self_evidence = collect_self_call_evidence((*entry.body).clone(), name.clone(), si.clone()); + let self_evidence = collect_self_call_evidence(entry.body.clone(), name.clone(), si.clone()); let self_has_calls = ((self_evidence.clone().len() as i64) > 0); let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for call_ev in self_evidence.clone().iter().cloned() { if !({ let mut __found = false; for rel in call_ev.clone().iter().cloned() { if match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { .. } => true, @@ -6840,7 +6840,7 @@ Rc::new(vec![Rc::new(ProofEdge { }; let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ - let callee_evidence = collect_callee_evidence((*entry.body).clone(), callee.clone(), si.clone()); + let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { { let ev = derive_edge_evidence(callee_evidence.clone()); @@ -6879,7 +6879,7 @@ pub fn scc_descending_param( match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { let evidence = collect_self_call_evidence( - (*entry.body).clone(), + entry.body.clone(), name.clone(), si.clone(), ); @@ -7216,12 +7216,12 @@ pub fn classify_scc_recursion_pattern( if !(match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { ((max_path_target_calls( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), si.clone(), ) <= 1) && scc_calls_have_arithmetic_descent( - (*entry.body).clone(), + entry.body.clone(), scc_name_set.clone(), func_index.clone(), scc_measure_params.clone(), @@ -7550,7 +7550,7 @@ pub fn resolve_callback_cost( fn_ref.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7559,7 +7559,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7570,7 +7570,7 @@ pub fn resolve_callback_cost( la.clone(), func_index.clone(), scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7583,7 +7583,7 @@ pub fn resolve_callback_cost( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -7616,7 +7616,7 @@ pub fn cost_of_method_by_shape( let loop_work = cost_loop( binder.clone(), size.clone(), - (*body_result.summary.clone().work).clone(), + body_result.summary.clone().work.clone(), ); let os = if (produces_collection == false) { body_result.summary.clone().output_size.clone() @@ -7635,12 +7635,12 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), - table: (*body_result.table).clone(), + table: body_result.table.clone(), }) } CostShape::ShapeSortBody => { @@ -7650,7 +7650,7 @@ pub fn cost_of_method_by_shape( la.clone(), func_index, scc_index, - (*recv_r.table).clone(), + recv_r.table.clone(), parser_always_advancing, recursion_ctx, si.clone(), @@ -7662,7 +7662,7 @@ pub fn cost_of_method_by_shape( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), }; let log_factor = Rc::new(CostExpr::CostLog { @@ -7671,7 +7671,7 @@ pub fn cost_of_method_by_shape( }); let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), per_comparison), + left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), right: log_factor, }); let sort_os = seed_cost_map( @@ -7684,12 +7684,12 @@ pub fn cost_of_method_by_shape( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), sort_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), sort_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), - table: (*key_result.table).clone(), + table: key_result.table.clone(), }) } CostShape::ShapeLinearScan => { @@ -7712,28 +7712,28 @@ pub fn cost_of_method_by_shape( }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*recv_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*recv_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }) } CostShape::ShapeConstant => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), } } @@ -8557,7 +8557,7 @@ pub fn cost_of_expr( r, func_index.clone(), scc_index.clone(), - (*lr.table).clone(), + lr.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8565,23 +8565,23 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*lr.summary.clone().work).clone(), + lr.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().work).clone(), + rr.summary.clone().work.clone(), ), ), span: cost_seq( - (*lr.summary.clone().span).clone(), + lr.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*rr.summary.clone().span).clone(), + rr.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*rr.table).clone(), + table: rr.table.clone(), }) } ExprData::ExprCall { .. } => { @@ -8614,49 +8614,49 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*callee_result.table).clone(), + table: callee_result.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*args_result.summary.clone().work).clone(), (*callee_result.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*args_result.summary.clone().span).clone(), (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } ExprData::ExprMethodCall { @@ -8703,17 +8703,17 @@ pub fn cost_of_expr( None => Some(Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), })), } } @@ -8731,55 +8731,55 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*recv_r.table).clone(), + table: recv_r.table.clone(), }), |acc: Rc, a: Rc| { let ar = cost_of_expr( arg_value(a.clone()), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*ar.table).clone(), + table: ar.table.clone(), }) }, ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( - (*recv_r.summary.clone().work).clone(), + recv_r.summary.clone().work.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().work).clone(), + args_result.summary.clone().work.clone(), ), ), span: cost_seq( - (*recv_r.summary.clone().span).clone(), + recv_r.summary.clone().span.clone(), cost_seq( Rc::new(CostExpr::CostConst { value: 1 }), - (*args_result.summary.clone().span).clone(), + args_result.summary.clone().span.clone(), ), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*args_result.table).clone(), + table: args_result.table.clone(), }) } } @@ -8805,7 +8805,7 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*s_r.table).clone(), + table: s_r.table.clone(), }), branch_costs: Rc::new(vec![]), }), @@ -8814,7 +8814,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*(*acc.result).clone().table).clone(), + (*acc.result).clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8822,22 +8822,22 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_par( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))( (*(*acc.result).clone().summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: cost_par( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))( (*(*acc.result).clone().summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), }), - table: (*ar.table).clone(), + table: ar.table.clone(), }), branch_costs: v1_rt::concat( acc.branch_costs.clone(), - Rc::new(vec![(*ar.summary.clone().work).clone()]), + Rc::new(vec![ar.summary.clone().work.clone()]), ), }) }, @@ -8845,13 +8845,13 @@ pub fn cost_of_expr( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*s_r.summary.clone().work).clone(), + s_r.summary.clone().work.clone(), arms_accum.branch_costs.clone(), ), span: cost_conditional( - (*s_r.summary.clone().span).clone(), + s_r.summary.clone().span.clone(), Rc::new(vec![ - (*(*arms_accum.result).clone().summary.clone().span).clone() + (*arms_accum.result).clone().summary.clone().span.clone() ]), ), output_size: (*arms_accum.result) @@ -8867,7 +8867,7 @@ pub fn cost_of_expr( .certainty .clone(), }), - table: (*(*arms_accum.result).clone().table).clone(), + table: (*arms_accum.result).clone().table.clone(), }) } ExprData::ExprIf => { @@ -8886,7 +8886,7 @@ pub fn cost_of_expr( t, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8897,14 +8897,14 @@ pub fn cost_of_expr( eb.clone(), func_index.clone(), scc_index.clone(), - (*t_r.table).clone(), + t_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: er.summary.clone(), - table: (*er.table).clone(), + table: er.table.clone(), }) } None => Rc::new(SummaryResult { @@ -8914,29 +8914,29 @@ pub fn cost_of_expr( output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), - table: (*t_r.table).clone(), + table: t_r.table.clone(), }), }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( - (*c_r.summary.clone().work).clone(), + c_r.summary.clone().work.clone(), Rc::new(vec![ - (*t_r.summary.clone().work).clone(), - (*e_result.summary.clone().work).clone(), + t_r.summary.clone().work.clone(), + e_result.summary.clone().work.clone(), ]), ), span: cost_conditional( - (*c_r.summary.clone().span).clone(), + c_r.summary.clone().span.clone(), Rc::new(vec![ - (*t_r.summary.clone().span).clone(), - (*e_result.summary.clone().span).clone(), + t_r.summary.clone().span.clone(), + e_result.summary.clone().span.clone(), ]), ), output_size: t_r.summary.clone().output_size.clone(), certainty: Certainty::Proven, }), - table: (*e_result.table).clone(), + table: e_result.table.clone(), }) } ExprData::ExprLet => { @@ -8956,25 +8956,25 @@ pub fn cost_of_expr( b.clone(), func_index.clone(), scc_index.clone(), - (*v_r.table).clone(), + v_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*v_r.summary.clone().work).clone(), (*b_r.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*v_r.summary.clone().span).clone(), (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), }), - table: (*b_r.table).clone(), + table: b_r.table.clone(), }) } None => v_r.clone(), @@ -8995,25 +8995,25 @@ pub fn cost_of_expr( s.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().work).clone(), (*sr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().span).clone(), (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), }), - table: (*sr.table).clone(), + table: sr.table.clone(), }) }, ), @@ -9033,7 +9033,7 @@ pub fn cost_of_expr( bd, func_index.clone(), scc_index.clone(), - (*c_r.table).clone(), + c_r.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -9041,15 +9041,15 @@ pub fn cost_of_expr( let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); let loop_work = - cost_loop(binder, size.clone(), (*bd_r.summary.clone().work).clone()); + cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq((*c_r.summary.clone().work).clone(), loop_work.clone()), - span: cost_seq((*c_r.summary.clone().span).clone(), loop_work.clone()), + work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), - table: (*bd_r.table).clone(), + table: bd_r.table.clone(), }) } ExprData::NoExprData => texpr.children.clone().iter().cloned().fold( @@ -9067,25 +9067,25 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9104,25 +9104,25 @@ pub fn cost_of_expr( child.clone(), func_index.clone(), scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: cost_seq( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), }), - table: (*cr.table).clone(), + table: cr.table.clone(), }) }, ), @@ -9180,7 +9180,7 @@ pub fn get_or_compute_summary( table.clone() }; let result = cost_of_expr( - (*entry.body).clone(), + entry.body.clone(), func_index.clone(), scc_index.clone(), table_prepped, @@ -9199,12 +9199,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_scc_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), scc_members.clone(), ), span: bounded_scc_cost( t.clone(), - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9214,12 +9214,12 @@ pub fn get_or_compute_summary( Rc::new(ComplexitySummary { work: bounded_recursive_cost( t.clone(), - (*result.summary.clone().work).clone(), + result.summary.clone().work.clone(), func_name.clone(), ), span: bounded_recursive_cost( t.clone(), - (*result.summary.clone().span).clone(), + result.summary.clone().span.clone(), func_name.clone(), ), output_size: result.summary.clone().output_size.clone(), @@ -9230,13 +9230,13 @@ pub fn get_or_compute_summary( None => result.summary.clone(), }; let simplified = Rc::new(ComplexitySummary { - work: simplify_cost((*bounded.work).clone()), - span: simplify_cost((*bounded.span).clone()), + work: simplify_cost(bounded.work.clone()), + span: simplify_cost(bounded.span.clone()), output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); let final_table = cache_summary( - (*result.table).clone(), + result.table.clone(), func_name.clone(), simplified.clone(), ); @@ -9605,7 +9605,7 @@ pub fn analyze_structural_bounds( Rc::new(vec![]), |acc: Rc>>, entry: Rc| { let all_calls = - collect_self_call_evidence((*entry.body).clone(), entry.name.clone(), si.clone()); + collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { acc.clone() } else { @@ -9634,7 +9634,7 @@ pub fn analyze_structural_bounds( match factor_opt.clone() { Some(factor) => { let branches = max_path_descending( - (*entry.body).clone(), + entry.body.clone(), entry.name.clone(), param_index.clone(), si.clone(), @@ -9734,13 +9734,13 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls((*entry.body).clone(), entry.name.clone(), si.clone()) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( entry.name.clone(), - (*entry.body).clone(), + entry.body.clone(), entry.params.clone(), parser_always_advancing.clone(), si.clone(), @@ -9813,12 +9813,12 @@ pub fn build_complexity_report( func_name.clone(), func_index.clone(), full_scc_index.clone(), - (*acc.table).clone(), + acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), ); - let class_str = classify_complexity((*sr.summary.clone().work).clone()); + let class_str = classify_complexity(sr.summary.clone().work.clone()); let new_classes = v1_rt::rc_map_insert( acc.classes.clone(), func_name.clone(), @@ -9826,12 +9826,12 @@ pub fn build_complexity_report( ); let new_processed = v1_rt::rc_map_insert(acc.processed.clone(), func_name.clone(), true); - let new_violations = if is_unknown_cost((*sr.summary.clone().work).clone()) { + let new_violations = if is_unknown_cost(sr.summary.clone().work.clone()) { v1_rt::concat( acc.violations.clone(), Rc::new(vec![Rc::new(ComplexityViolation { func_name: func_name.clone(), - reason: extract_unknown_reason((*sr.summary.clone().work).clone()), + reason: extract_unknown_reason(sr.summary.clone().work.clone()), span: entry.span.clone(), })]), ) @@ -9880,9 +9880,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(evicted_table.clone(), func_name.clone()) + evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) } else { - evicted_table.clone() + Rc::new(evicted_table.clone()) }; Rc::new(TopoBuildAcc { table: final_table.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index b79a0b20400..0f289bbabe9 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -594,13 +594,13 @@ pub fn empty_emit_scope() -> Rc { pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { - type_env: (*typed_module.type_env).clone(), - func_env: (*typed_module.func_env).clone(), + type_env: typed_module.type_env.clone(), + func_env: typed_module.func_env.clone(), locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), @@ -645,7 +645,7 @@ pub fn lookup_func_sig_in_scope( scope: Rc, name: String, ) -> Option> { - lookup_func_sig((*scope.func_env).clone(), name) + lookup_func_sig(scope.func_env.clone(), name) } pub fn typed_named_arg_matches( @@ -2550,7 +2550,7 @@ pub fn emit_shared_tco_expr( .clone(); match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at((*frame.expr).clone(), si) == fn_name) { + if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: (*frame.expr).clone().children.clone(), scope: frame.scope.clone(), @@ -2561,7 +2561,7 @@ pub fn emit_shared_tco_expr( } } ExprData::ExprReturn => { - let inner = return_value((*frame.expr).clone()); + let inner = return_value(frame.expr.clone()); { let __tco_0 = Rc::new(TcoFrame { expr: inner, @@ -2628,7 +2628,7 @@ pub fn shared_tco_default_return( ) -> String { { let val_str = recurse_expr( - (*frame.expr).clone(), + frame.expr.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2648,7 +2648,7 @@ pub fn shared_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -2685,9 +2685,9 @@ pub fn shared_tco_if( let syntax = spec.block_syntax.clone(); match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = recurse_expr(c, frame.scope.clone(), frame.depth.clone()); let then_str = recurse_tco(t, frame.scope.clone(), (frame.depth.clone() + 1)); let else_prefix = if syntax.significant_whitespace.clone() { @@ -2811,14 +2811,14 @@ pub fn shared_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = recurse_expr(v.clone(), frame.scope.clone(), frame.depth.clone()); let let_line = emit_let_binding(n.clone(), val_str, target); let next_scope = extend_scope( @@ -3232,8 +3232,8 @@ pub fn emit_unified_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_unified_typed_expr( s, target.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 39ad3967ac0..eee7c7acd88 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -604,7 +604,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc { __result.push(emit_go_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -138,7 +138,7 @@ pub fn emit_go(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -286,7 +286,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { ") ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Go, projection.source_indices.clone(), ), @@ -465,7 +465,7 @@ pub fn emit_go_module( let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let si = (*typed_module.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), m.clone()); + let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( v1_rt::concat( @@ -480,7 +480,7 @@ pub fn emit_go_module( ); let imports_str = emit_go_imports( typed_module.items.clone(), - module_imports(m.clone()), + module_imports(Rc::new(m.clone())), si.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -696,9 +696,9 @@ pub fn emit_go_typed_item( ) -> String { { let env = (*scope.type_env).clone(); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), env.clone()) + emit_go_type_def_from_connective(item.clone(), Rc::new(env.clone())) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -743,10 +743,10 @@ pub fn emit_go_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, env.clone()) + emit_go_service_def(item.clone(), registry, Rc::new(env.clone())) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), env.clone()) + emit_go_resource_def(item.clone(), Rc::new(env.clone())) } else { v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index af3d0bda615..27fd76562e4 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -118,7 +118,7 @@ pub fn emit_python(typed: Rc) -> Rc { __result.push(emit_py_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -126,7 +126,7 @@ pub fn emit_python(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -188,7 +188,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { __result.push({ let mod_name = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); v1_rt::concat( @@ -267,7 +267,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Python, projection.source_indices.clone(), ), @@ -367,9 +367,9 @@ pub fn emit_py_module( let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let si = (*scope.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), m.clone()); + let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); + let imports_str = emit_py_imports(module_imports(Rc::new(m.clone())), si.clone()); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { @@ -583,9 +583,9 @@ pub fn emit_py_typed_item( ) -> String { { let env = (*scope.type_env).clone(); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), env.clone()) + emit_py_type_def_from_connective(item.clone(), Rc::new(env.clone())) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -632,10 +632,10 @@ pub fn emit_py_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, env.clone()) + emit_py_service_def(item.clone(), registry, Rc::new(env.clone())) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), env.clone()) + emit_py_resource_def(item.clone(), Rc::new(env.clone())) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 393558247b1..f31471e25a7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -2604,7 +2604,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, tm: Rc| { let module_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2660,7 +2660,7 @@ pub fn build_scoped_data_item_index( { let module_name = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2686,7 +2686,7 @@ pub fn build_scoped_data_item_index( ) }, ); - module_imports((*typed_module.module).clone()) + module_imports(typed_module.module.clone()) .iter() .cloned() .fold( @@ -3319,7 +3319,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc) -> Rc { }); let mod_filename = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3494,7 +3494,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result.push(emit_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -3502,7 +3502,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -3530,7 +3530,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for m in typed.modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -3713,10 +3713,10 @@ pub fn build_module_export_sets( |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); let exported = get_exported_names( - (*tm.module).clone(), + tm.module.clone(), (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( @@ -3747,7 +3747,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3757,7 +3757,7 @@ pub fn emit_module_full( ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.clone()).iter().cloned() { + for imp in module_imports(Rc::new(m.clone())).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), @@ -3793,12 +3793,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); let imports_str = emit_imports( - module_imports(m.clone()), + module_imports(Rc::new(m.clone())), emit_info.clone(), registry.clone(), local_type_names, @@ -3813,14 +3813,14 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get( ®istry, - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ) { Some(info) => info.service_names.clone(), None => Rc::new(vec![]), @@ -3881,7 +3881,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { if ((is_type_def_item(item.clone()) && is_coproduct_type(item.clone())) && !is_host_freemonoid_vec_alias( - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), emit_info.corpus_repr.clone(), )) { @@ -3896,7 +3896,7 @@ pub fn emit_module_full( __result.push(v1_rt::concat( v1_rt::concat( "use self::".to_string(), - authored_name((*scope.type_env).clone(), item.clone()), + authored_name(scope.type_env.clone(), item.clone()), ), "::*;".to_string(), )); @@ -3917,12 +3917,12 @@ pub fn emit_module_full( .iter() .cloned() { - __result.push(authored_name((*scope.type_env).clone(), item.clone())); + __result.push(authored_name(scope.type_env.clone(), item.clone())); } __result }); - let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(Rc::new(m.clone())); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3985,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4003,26 +4003,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name((*scope.type_env).clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4141,7 +4141,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>, tm: Rc| { let nm = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4154,7 +4154,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4213,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports((*tm.module).clone()), + Some(tm) => module_imports(tm.module.clone()), None => Rc::new(vec![]), } } @@ -4230,7 +4230,7 @@ pub fn module_name_from_filename( for tm in mods.clone().iter().cloned() { __result.push(authored_name_at( source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); } __result @@ -4404,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4496,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4607,7 +4607,7 @@ pub fn reexport_source_module_name_with_visited( for imp in Rc::new({ let mut __result = Vec::new(); for imp in - module_imports((*tm.module).clone()).iter().cloned() + module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4658,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()) + for imp in module_imports(tm.module.clone()) .iter() .cloned() { @@ -4926,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5183,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5219,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5679,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5708,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5847,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - (*scope.type_env).clone(), + scope.type_env.clone(), name.clone(), ) { true @@ -7232,15 +7232,15 @@ pub fn emit_typed_item( let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - env.clone(), + Rc::new(env.clone()), emit_info.clone(), wire_contract_item, data_items, @@ -7500,7 +7500,7 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), @@ -7547,7 +7547,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7599,7 +7599,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env.clone()), ) } else { if is_resource_def_item(item.clone()) { @@ -7607,7 +7607,7 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env.clone()), ) } else { v1_rt::concat( @@ -9682,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9691,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9709,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9942,7 +9942,7 @@ pub fn emit_func_def( (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -12515,7 +12515,7 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); match find_child_named( @@ -12549,7 +12549,7 @@ pub fn field_access_field_is_boxed( (*scope.type_env).clone().source_indices.clone(), )) || is_recursive_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), field_ty_name.clone(), )) } @@ -13299,7 +13299,7 @@ pub fn emit_rust_expr_record_lit( let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13845,7 +13845,7 @@ pub fn emit_discriminant_call_lowering( arg.clone(), (*scope.type_env).clone().source_indices.clone(), ); - match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { + match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13854,7 +13854,7 @@ pub fn emit_discriminant_call_lowering( for child in enum_node.children.clone().iter().cloned() { __result.push({ let child_text = - authored_name((*scope.type_env).clone(), child.clone()); + authored_name(scope.type_env.clone(), child.clone()); let pat = if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat(ty_name.clone(), "::".to_string()), @@ -17585,7 +17585,7 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name((*scope.type_env).clone(), struct_name) { + match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, @@ -18375,7 +18375,7 @@ pub fn emit_typed_record_lit( { let resolved_struct = (*resolve_node( resolved_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) .resolved) @@ -18794,7 +18794,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -19420,7 +19420,7 @@ pub fn emit_rust_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -19457,9 +19457,9 @@ pub fn emit_rust_tco_if( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19736,8 +19736,8 @@ pub fn emit_rust_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19910,14 +19910,14 @@ pub fn emit_rust_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -20064,7 +20064,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - (*frame.expr).clone(), + frame.expr.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -23330,7 +23330,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23653,7 +23653,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -24033,7 +24033,7 @@ pub fn collect_workflow_funcs( item.clone(), authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), registry.clone(), tm.items.clone(), @@ -24128,7 +24128,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )), None => "".to_string(), }; @@ -24149,7 +24149,7 @@ pub fn emit_main_rs( for m in modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 635072e7f2f..5727d713c85 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -250,7 +250,7 @@ pub fn infer_block_stmts( let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); let stmt_typed = (*stmt_result.typed).clone(); let stmt_diags = stmt_result.diagnostics.clone(); - let stmt_rt = resolved_type(stmt_typed.clone()); + let stmt_rt = resolved_type(Rc::new(stmt_typed.clone())); let next_scope = scope_after_stmt_node(stmt.clone(), stmt_rt.clone(), scope.clone()); { @@ -263,7 +263,7 @@ pub fn infer_block_stmts( ); let __tco_1 = (remaining_count - 1); let __tco_2 = next_scope; - let __tco_3 = v1_rt::rc_list_push(typed_stmts, stmt_typed.clone()); + let __tco_3 = v1_rt::rc_list_push(typed_stmts, Rc::new(stmt_typed.clone())); let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; @@ -771,7 +771,7 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for)))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(parent) => { let is_coproduct = (parent.connective.clone() == Connective::Disj); if is_coproduct { @@ -782,7 +782,7 @@ pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option ) { Some(authored_name_at( (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), )) } else { None @@ -810,7 +810,7 @@ pub fn variant_owner_node_authority() -> String { pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match lookup_type_for((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for)))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(owner) => { let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); if owner_is_coproduct { @@ -929,7 +929,7 @@ pub fn record_lit_expected_fields( scope: Rc, ) -> Rc>> { match type_name { - Some(tn) => match lookup_type_by_name((*scope.type_env).clone(), tn.clone()) { + Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { Some(direct) => direct.children.clone(), None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ @@ -1045,7 +1045,7 @@ pub fn record_lit_instantiated_fields( if ((exp.children.clone().len() as i64) == 0) { None } else { - match lookup_type_for((*scope.type_env).clone(), exp.clone()) { + match lookup_type_for(scope.type_env.clone(), exp.clone()) { Some(decl) => { if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) @@ -1129,7 +1129,7 @@ pub fn list_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("List".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1139,7 +1139,7 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { { let b = make_container_type("Set".to_string(), element); Rc::new(KernelListTyDiag { - ty: (*b.ty).clone(), + ty: b.ty.clone(), miss_diags: b.diagnostics.clone(), }) } @@ -1181,7 +1181,7 @@ pub fn set_element_type_from_receiver( receiver_type: Rc, scope: Rc, ) -> Option> { - match set_element_type_in_env(receiver_type, (*scope.type_env).clone()) { + match set_element_type_in_env(receiver_type, scope.type_env.clone()) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, } @@ -1393,7 +1393,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( .. }) => match map_value_type_in_env( receiver_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(value_type) => { if (func_name.clone() == "lookup".to_string()) { @@ -1422,12 +1422,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), (*scope.type_env).clone()) + match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { - bt: (*lk.ty).clone(), + bt: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1460,12 +1460,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( .. }) => match map_value_type_in_env( receiver_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(Tier2bBt { - bt: (*lv.ty).clone(), + bt: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1517,7 +1517,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: other_type, .. }) => match set_element_type_in_env( other_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { Some(elem_slot) => Some(child_type_node(elem_slot.clone())), None => None, @@ -1700,11 +1700,11 @@ pub fn method_pipe_map_keys_values_fallback( span: Rc, ) -> Rc { if (method_name.clone() == "map_keys".to_string()) { - match map_key_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(MethodPipeFallback { - result_ty: (*lk.ty).clone(), + result_ty: lk.ty.clone(), kernel_diags: lk.miss_diags.clone(), }) } @@ -1715,11 +1715,11 @@ pub fn method_pipe_map_keys_values_fallback( } } else { if (method_name.clone() == "map_values".to_string()) { - match map_value_type_in_env(recv_rt.clone(), (*scope.type_env).clone()) { + match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); Rc::new(MethodPipeFallback { - result_ty: (*lv.ty).clone(), + result_ty: lv.ty.clone(), kernel_diags: lv.miss_diags.clone(), }) } @@ -1853,7 +1853,7 @@ pub fn resolve_pattern_subject( node: scrutinee_type, .. } => pattern_subject_from_node(resolve_scrutinee_type_node( - (*scope.type_env).clone(), + scope.type_env.clone(), scrutinee_type.clone(), )), PatternSubject::PatternDynamic { @@ -1928,7 +1928,7 @@ pub fn annotate_pattern_parent_enums( resolved_scrut.clone(), variant_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup); @@ -2001,8 +2001,8 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2020,8 +2020,8 @@ pub fn extend_scope( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2046,8 +2046,8 @@ pub fn extend_scope_match_bound( provenance: Rc, ) -> Rc { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: v1_rt::rc_map_insert( scope.locals.clone(), name.clone(), @@ -2086,8 +2086,8 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) }, ); Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: new_locals, match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2151,7 +2151,7 @@ pub fn derive_field_provenance( } else { { let ind_fields = - inductive_fields_for((*scope.type_env).clone(), scrut_type_name.clone()); + inductive_fields_for(scope.type_env.clone(), scrut_type_name.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { @@ -2211,7 +2211,7 @@ pub fn extend_scope_with_pattern_node( resolved_scrut, vname.clone(), scope.module_name.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), (bindings.clone().len() as i64), ); let variant_subject = lookup_result_subject(variant_lookup.clone()); @@ -2343,7 +2343,7 @@ pub fn extract_fold_init_info( ia.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*init_result.typed).clone(), + init_result.typed.clone(), ia.span.clone(), ia.span.clone(), ), @@ -2378,7 +2378,7 @@ pub fn derive_element_provenance( } else { { let ind_fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), elem_type.clone(), @@ -2507,8 +2507,8 @@ pub fn infer_method_args_with_fold( ), }; let fold_scope = Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2527,7 +2527,7 @@ pub fn infer_method_args_with_fold( a.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -2549,8 +2549,8 @@ pub fn infer_method_args_with_fold( }; let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { Rc::new(InferScope { - type_env: (*scope.type_env).clone(), - func_env: (*scope.func_env).clone(), + type_env: scope.type_env.clone(), + func_env: scope.func_env.clone(), locals: scope.locals.clone(), match_bound_names: scope.match_bound_names.clone(), module_name: scope.module_name.clone(), @@ -2620,7 +2620,7 @@ pub fn infer_arg_with_element_type( arg.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), arg.span.clone(), arg.span.clone(), ), @@ -2677,7 +2677,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span.clone(), @@ -2692,7 +2692,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), span.clone(), span.clone(), @@ -2700,7 +2700,7 @@ pub fn infer_expr( } } } - None => match lookup_func_sig((*scope.func_env).clone(), name.clone()) { + None => match lookup_func_sig(scope.func_env.clone(), name.clone()) { Some(fsig) => { if ((fsig.params.clone().len() as i64) == 0) { ok_infer(make_named_expr_node( @@ -2711,7 +2711,7 @@ pub fn infer_expr( }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { - node: (*fsig.inferred).clone(), + node: fsig.inferred.clone(), })), span.clone(), span.clone(), @@ -2728,7 +2728,7 @@ pub fn infer_expr( Some(Rc::new(InferredNode::Resolved { node: resolved_callable_type( fsig.params.clone(), - (*fsig.inferred).clone(), + fsig.inferred.clone(), ), })), span.clone(), @@ -2773,14 +2773,14 @@ pub fn infer_expr( let base_result = infer_expr(base_expr, scope.clone(), None); let base_typed = (*base_result.typed).clone(); let base_diags = base_result.diagnostics.clone(); - let base_rt = resolved_type(base_typed.clone()); + let base_rt = resolved_type(Rc::new(base_typed.clone())); let resolved_base = - if is_deferred_field_access_base(base_rt.clone(), (*scope.type_env).clone()) { + if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { base_rt.clone() } else { expand_type_for_field_access( base_rt.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; @@ -2809,13 +2809,13 @@ pub fn infer_expr( Some(field_type) => { let field_summary = match field_summary_for_type( base_rt.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ) { Some(s) => Some(s.clone()), None => field_summary_for_type( resolved_base.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), field_name.clone(), ), }; @@ -2824,7 +2824,7 @@ pub fn infer_expr( Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![base_typed.clone()]), + Rc::new(vec![Rc::new(base_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: field_type.clone(), })), @@ -2839,7 +2839,7 @@ pub fn infer_expr( None => { let base_is_type_var = is_deferred_field_access_base( resolved_base.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); if base_is_type_var { { @@ -2851,7 +2851,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed.clone()]), + Rc::new(vec![Rc::new(base_typed.clone())]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), @@ -2879,7 +2879,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![base_typed.clone()]), + Rc::new(vec![Rc::new(base_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: svc_type.clone(), })), @@ -2942,7 +2942,7 @@ pub fn infer_expr( ); let span = texpr.span.clone(); let call_args = texpr.children.clone(); - let sig = lookup_func_sig((*scope.func_env).clone(), func_name.clone()); + let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); let sig_params = match sig.clone() { Some(s) => s.params.clone(), None => Rc::new(vec![]), @@ -2974,7 +2974,7 @@ pub fn infer_expr( expected.clone(), ); let call_fold_acc_type = match call_fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let arg_call = if ((has_lambda && ((call_args.clone().len() as i64) >= 2)) @@ -2986,13 +2986,13 @@ pub fn infer_expr( Some(first_arg) => { let first_result = infer_expr(arg_value(first_arg.clone()), scope.clone(), None); - let first_type = resolved_type((*first_result.typed).clone()); + let first_type = resolved_type(first_result.typed.clone()); let elem_type = for_each_element_type_node( first_type, (*scope.type_env).clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( - (*first_result.typed).clone(), + first_result.typed.clone(), elem_type.clone(), scope.clone(), ); @@ -3012,7 +3012,7 @@ pub fn infer_expr( first_arg.clone(), (*scope.type_env).clone().source_indices.clone(), ), - (*first_result.typed).clone(), + first_result.typed.clone(), first_arg.span.clone(), first_arg.span.clone(), ), @@ -3118,7 +3118,7 @@ pub fn infer_expr( ) { unify_record_lit_generics( formal_raw.clone(), - (*ar.typed).clone(), + ar.typed.clone(), generic_names.clone(), scope.clone(), st.subst.clone(), @@ -3126,7 +3126,7 @@ pub fn infer_expr( } else { unify_generics( formal_raw.clone(), - resolved_type((*ar.typed).clone()), + resolved_type(ar.typed.clone()), generic_names.clone(), (*scope.type_env).clone().source_indices.clone(), st.subst.clone(), @@ -3145,7 +3145,7 @@ pub fn infer_expr( .source_indices .clone(), ), - (*ar.typed).clone(), + ar.typed.clone(), a.span.clone(), a.span.clone(), ), @@ -3180,7 +3180,7 @@ pub fn infer_expr( { let resolved_type = match sig.clone() { Some(s) => substitute_generics( - (*s.inferred).clone(), + s.inferred.clone(), call_subst.clone(), (*scope.type_env).clone().source_indices.clone(), ), @@ -3202,7 +3202,7 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - direct_call_arg_mismatch_diags( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags)))))))))))))))))))))( value_params_for_check, typed_args.clone(), call_subst.clone(), @@ -3230,11 +3230,11 @@ pub fn infer_expr( } else { { let first_arg_type = match typed_args.clone().first().cloned() { - Some(ta) => resolved_type(arg_value(ta.clone())), + Some(ta) => resolved_type(arg_value(Rc::new(ta.clone()))), None => unit_type(), }; let method_receiver = match typed_args.clone().first().cloned() { - Some(ta) => arg_value(ta.clone()), + Some(ta) => arg_value(Rc::new(ta.clone())), None => internal_expr_error_node( "method bridge missing receiver".to_string(), span.clone(), @@ -3250,7 +3250,7 @@ pub fn infer_expr( match Rc::new({ let mut __result = Vec::new(); for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(a.clone())) { + if is_lambda_expr(arg_value(Rc::new(a.clone()))) { __result.push(a); } } @@ -3259,7 +3259,7 @@ pub fn infer_expr( .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), None => call_fold_acc_type.clone(), } } else { @@ -3269,7 +3269,7 @@ pub fn infer_expr( method_receiver.clone(), resolve_method_receiver_type( first_arg_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ), func_name.clone(), if (call_fold_info.clone() != None) { @@ -3328,7 +3328,7 @@ pub fn infer_expr( remaining.clone().iter().cloned() { __result.push(resolved_type( - arg_value(a.clone()), + arg_value(Rc::new(a.clone())), )); } __result @@ -3395,7 +3395,7 @@ pub fn infer_expr( }; let final_receiver = if ((returns_receiver_self && is_fully_resolved( - bridge_result_type.clone(), + Rc::new(bridge_result_type.clone()), (*scope.type_env).clone().source_indices.clone(), )) && !is_fully_resolved( @@ -3410,7 +3410,7 @@ pub fn infer_expr( connective: receiver.connective.clone(), params: receiver.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: bridge_result_type.clone(), + node: Rc::new(bridge_result_type.clone()), })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), @@ -3434,10 +3434,10 @@ pub fn infer_expr( for ta in remaining.clone().iter().cloned() { __result.push(make_arg_node( arg_name_at( - ta.clone(), + Rc::new(ta.clone()), (*scope.type_env).clone().source_indices.clone(), ), - arg_value(ta.clone()), + arg_value(Rc::new(ta.clone())), span.clone(), span.clone(), )); @@ -3456,7 +3456,7 @@ pub fn infer_expr( remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: bridge_result_type.clone(), + node: Rc::new(bridge_result_type.clone()), })), span.clone(), node_name_span(texpr.clone()), @@ -3623,7 +3623,7 @@ match bare_s { }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: bt, + node: Rc::new(bt), })), span.clone(), node_name_span(texpr.clone()), @@ -3686,7 +3686,7 @@ match bare_s { Some(ctor_result) => ctor_result.clone(), None => { let type_match = lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), func_name.clone(), ); let resolved_type = match type_match.clone() @@ -3744,8 +3744,8 @@ match bare_s { let recv_typed = (*recv_result.typed).clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( - resolved_type(recv_typed.clone()), - (*scope.type_env).clone(), + resolved_type(Rc::new(recv_typed.clone())), + scope.type_env.clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), @@ -3760,11 +3760,11 @@ match bare_s { expected.clone(), ); let fold_acc_type = match fold_info.clone() { - Some(fi) => resolved_type(arg_value((*fi.typed_arg).clone())), + Some(fi) => resolved_type(arg_value(fi.typed_arg.clone())), None => error_type(), }; let mc_elem_provenance = derive_element_provenance( - recv_typed.clone(), + Rc::new(recv_typed.clone()), recv_elem_type.clone(), scope.clone(), ); @@ -3800,7 +3800,7 @@ match bare_s { match Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(a.clone())) { + if is_lambda_expr(arg_value(Rc::new(a.clone()))) { __result.push(a); } } @@ -3809,14 +3809,14 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), + Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), None => fold_acc_type.clone(), } } else { fold_acc_type.clone() }; let method_resolution = resolve_known_method_node( - recv_typed.clone(), + Rc::new(recv_typed.clone()), recv_rt.clone(), method_name.clone(), if (fold_info.clone() != None) { @@ -3842,7 +3842,7 @@ match bare_s { let base_result_type = (*pipe_fb.result_ty).clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }) } else { @@ -3854,7 +3854,7 @@ match bare_s { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( - base_result_type.clone(), + Rc::new(base_result_type.clone()), (*scope.type_env).clone().source_indices.clone(), )) { @@ -3862,7 +3862,7 @@ match bare_s { let mc_arg_types = Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - __result.push(resolved_type(arg_value(a.clone()))); + __result.push(resolved_type(arg_value(Rc::new(a.clone())))); } __result }); @@ -3884,18 +3884,18 @@ match bare_s { } } else { Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: base_result_type.clone(), + ty: Rc::new(base_result_type.clone()), diagnostics: Rc::new(vec![]), }), } @@ -3913,8 +3913,8 @@ match bare_s { Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![recv_typed.clone()]), typed_mc_arg_nodes), - Some(Rc::new(InferredNode::Resolved { node: result_type })), + v1_rt::concat(Rc::new(vec![Rc::new(recv_typed.clone())]), typed_mc_arg_nodes), + Some(Rc::new(InferredNode::Resolved { node: Rc::new(result_type) })), span.clone(), node_name_span(texpr.clone()), ); @@ -3936,7 +3936,7 @@ match bare_s { let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); let scrut_typed = (*scrut_result.typed).clone(); let scrut_diags = scrut_result.diagnostics.clone(); - let scrut_rt = resolved_type(scrut_typed.clone()); + let scrut_rt = resolved_type(Rc::new(scrut_typed.clone())); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ @@ -3984,18 +3984,18 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, - body_typed.clone(), + Rc::new(body_typed.clone()), span.clone(), ), diagnostics: v1_rt::concat( pattern_diags.clone(), v1_rt::concat(guard_diags.clone(), body_diags.clone()), ), - body_type: resolved_type(body_typed.clone()), + body_type: resolved_type(Rc::new(body_typed.clone())), }) }); } @@ -4087,7 +4087,7 @@ match bare_s { }), }; if !is_fully_resolved( - (*original.body_type).clone(), + original.body_type.clone(), (*scope.type_env).clone().source_indices.clone(), ) { { @@ -4139,11 +4139,11 @@ match bare_s { typed_arm: make_arm_node( typed_pattern.clone(), if (guard_result.clone() != None) { - Some((*guard_unwrapped.typed).clone()) + Some(guard_unwrapped.typed.clone()) } else { None }, - body_typed.clone(), + Rc::new(body_typed.clone()), span.clone(), ), diagnostics: v1_rt::concat( @@ -4153,7 +4153,7 @@ match bare_s { body_diags.clone(), ), ), - body_type: resolved_type(body_typed.clone()), + body_type: resolved_type(Rc::new(body_typed.clone())), }) } } else { @@ -4199,7 +4199,7 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => check_match_exhaustiveness( + } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness)))))))))))))))))))))( resolved_scrutinee.clone(), typed_arms.clone(), (*scope.type_env).clone(), @@ -4211,7 +4211,7 @@ match bare_s { }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![scrut_typed.clone()]), typed_arms.clone()), + v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed.clone())]), typed_arms.clone()), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4238,8 +4238,8 @@ match bare_s { Some(else_branch) => { let else_result = infer_expr(else_branch.clone(), scope.clone(), expected.clone()); - let then_rt = resolved_type((*then_result.typed).clone()); - let else_rt = resolved_type((*else_result.typed).clone()); + let then_rt = resolved_type(then_result.typed.clone()); + let else_rt = resolved_type(else_result.typed.clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -4266,8 +4266,8 @@ match bare_s { let then_diags = then_result.diagnostics.clone(); let else_typed = (*else_result.typed).clone(); let else_diags = else_result.diagnostics.clone(); - let then_rt = resolved_type(then_typed.clone()); - let else_rt = resolved_type(else_typed.clone()); + let then_rt = resolved_type(Rc::new(then_typed.clone())); + let else_rt = resolved_type(Rc::new(else_typed.clone())); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), @@ -4304,7 +4304,7 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed.clone(), else_typed.clone()]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone()), Rc::new(else_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: unified })), span.clone(), ); @@ -4319,7 +4319,7 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![cond_typed, then_typed.clone()]), + Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), span.clone(), ); @@ -4360,13 +4360,13 @@ match bare_s { let val_result = infer_expr(val_expr, scope.clone(), val_expected); let val_typed = (*val_result.typed).clone(); let val_diags = val_result.diagnostics.clone(); - let val_type = resolved_type(val_typed.clone()); + let val_type = resolved_type(Rc::new(val_typed.clone())); if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed.clone()]), + Rc::new(vec![Rc::new(val_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: val_type })), span.clone(), node_name_span(texpr.clone()), @@ -4382,7 +4382,7 @@ match bare_s { scope.clone(), let_name.clone(), val_type, - classify_binding_provenance(val_typed.clone(), scope.clone()), + classify_binding_provenance(Rc::new(val_typed.clone()), scope.clone()), ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); @@ -4391,7 +4391,7 @@ match bare_s { let let_texpr2 = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![val_typed.clone(), body_typed.clone()]), + Rc::new(vec![Rc::new(val_typed.clone()), Rc::new(body_typed.clone())]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -4460,7 +4460,7 @@ match bare_s { }); let elem_type_node = if ((elem_results.clone().len() as i64) > 0) { match elem_results.clone().first().cloned() { - Some(r) => resolved_type((*r.typed).clone()), + Some(r) => resolved_type(r.typed.clone()), None => unit_type(), } } else { @@ -4516,7 +4516,7 @@ match bare_s { Rc::new(ExprData::ExprListLit), typed_elements, Some(Rc::new(InferredNode::Resolved { - node: (*list_k.ty).clone(), + node: list_k.ty.clone(), })), span.clone(), ); @@ -4540,7 +4540,7 @@ match bare_s { let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), - resolved_type(left_typed.clone()), + resolved_type(Rc::new(left_typed.clone())), (*scope.type_env).clone().source_indices.clone(), ); let bo_texpr = make_expr_node( @@ -4548,9 +4548,9 @@ match bare_s { op: op.clone(), algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![left_typed.clone(), right_typed]), + Rc::new(vec![Rc::new(left_typed.clone()), Rc::new(right_typed)]), Some(Rc::new(InferredNode::Resolved { - node: (*binop_info.result_type).clone(), + node: binop_info.result_type.clone(), })), span.clone(), ); @@ -4567,11 +4567,11 @@ match bare_s { let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), - UnaryOpKind::Neg => resolved_type(operand_typed.clone()), + UnaryOpKind::Neg => resolved_type(Rc::new(operand_typed.clone())), }; let uo_texpr = make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![operand_typed.clone()]), + Rc::new(vec![Rc::new(operand_typed.clone())]), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4715,8 +4715,8 @@ match bare_s { None }; let body_scope = Rc::new(InferScope { - type_env: (*lam_scope.type_env).clone(), - func_env: (*lam_scope.func_env).clone(), + type_env: lam_scope.type_env.clone(), + func_env: lam_scope.func_env.clone(), locals: lam_scope.locals.clone(), match_bound_names: lam_scope.match_bound_names.clone(), module_name: lam_scope.module_name.clone(), @@ -4751,7 +4751,7 @@ match bare_s { match v1_rt::map_get(&lam_scope.locals.clone(), param_name.clone()) { Some(binding) => Some(Rc::new(InferredNode::Resolved { - node: (*binding.resolved).clone(), + node: binding.resolved.clone(), })), None => None, }; @@ -4781,7 +4781,7 @@ match bare_s { }); let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), + v1_rt::concat(Rc::new(vec![Rc::new(body_typed.clone())]), typed_param_nodes), body_typed.inferred.clone(), span.clone(), ); @@ -4801,7 +4801,7 @@ match bare_s { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); make_interp_part_node( - (*r.typed).clone(), + r.typed.clone(), part_node.span.clone(), ) } @@ -4862,7 +4862,7 @@ match bare_s { Rc::new(ExprData::ExprBlock), state.typed_stmts.clone(), Some(Rc::new(InferredNode::Resolved { - node: (*state.last_type).clone(), + node: state.last_type.clone(), })), span.clone(), ); @@ -4908,7 +4908,7 @@ match bare_s { }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![inner_typed.clone(), target_type.clone()]), + Rc::new(vec![Rc::new(inner_typed.clone()), target_type.clone()]), Some(Rc::new(InferredNode::Resolved { node: target_type.clone(), })), @@ -4931,11 +4931,11 @@ match bare_s { let coll_typed = (*coll_result.typed).clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( - resolved_type(coll_typed.clone()), + resolved_type(Rc::new(coll_typed.clone())), (*scope.type_env).clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( - coll_typed.clone(), + Rc::new(coll_typed.clone()), elem_type_node.clone(), scope.clone(), ); @@ -4951,7 +4951,7 @@ match bare_s { let fe_texpr = make_named_expr_node( variable.clone(), Rc::new(ExprData::ExprForEach), - Rc::new(vec![coll_typed.clone(), body_typed.clone()]), + Rc::new(vec![Rc::new(coll_typed.clone()), Rc::new(body_typed.clone())]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -5009,7 +5009,7 @@ match bare_s { }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base_typed.clone(), index_typed.clone()]), + Rc::new(vec![Rc::new(base_typed.clone()), Rc::new(index_typed.clone())]), idx_inferred, span.clone(), ); @@ -5085,9 +5085,9 @@ match bare_s { let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), Rc::new(vec![ - base_typed.clone(), - start_typed.clone(), - end_typed.clone(), + Rc::new(base_typed.clone()), + Rc::new(start_typed.clone()), + Rc::new(end_typed.clone()), ]), slc_inferred, span.clone(), @@ -5106,7 +5106,7 @@ match bare_s { let inner_result = infer_expr(inner_expr, scope.clone(), expected.clone()); let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*inner_result.typed).clone()]), + Rc::new(vec![inner_result.typed.clone()]), (*inner_result.typed).clone().inferred.clone(), span.clone(), ); @@ -5145,7 +5145,7 @@ pub fn infer_variant_constructor_call( None => None, Some(parent_enum) => { let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), parent_enum.clone()) { + match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { Some(variant_node) => { @@ -5304,7 +5304,7 @@ pub fn peel_alias_once_for_field_access( if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { - break once.clone(); + break Rc::new(once.clone()); } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) @@ -5312,11 +5312,11 @@ pub fn peel_alias_once_for_field_access( { { let __tco_0 = once.clone(); - n = __tco_0; + n = Rc::new(__tco_0); continue; } } else { - break once.clone(); + break Rc::new(once.clone()); } } } @@ -5638,7 +5638,7 @@ pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, ) -> Option>>> { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) @@ -5653,7 +5653,7 @@ pub fn record_lit_alias_struct_fields( }; let expanded = expand_type_for_field_access( to_expand, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); if ((expanded.connective.clone() == Connective::Conj) @@ -5674,7 +5674,7 @@ pub fn record_lit_construction_field_names( ) -> Option>> { { let si = (*scope.type_env).clone().source_indices.clone(); - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) && (decl.connective.clone() == Connective::Conj)) @@ -5707,7 +5707,7 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { - match lookup_type_by_name((*scope.type_env).clone(), type_name) { + match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { let mut __found = false; for p in decl.properties.clone().iter().cloned() { @@ -5874,7 +5874,7 @@ pub fn infer_record_lit( || type_node_is_callable(ft.clone())) || field_type_is_optional_coproduct( ft.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), )) { Some(ft.clone()) @@ -5893,16 +5893,16 @@ pub fn infer_record_lit( let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { - let got_node = resolved_type(ar_typed.clone()); + let got_node = resolved_type(Rc::new(ar_typed.clone())); if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), (*scope.type_env).clone().source_indices.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ) { { let expected_for_shape = match lookup_type_for( - (*scope.type_env).clone(), + scope.type_env.clone(), with_required_cardinality(expected_node.clone()), ) { Some(resolved) => resolved.clone(), @@ -5930,7 +5930,7 @@ pub fn infer_record_lit( Rc::new(FieldInferResult { typed_field: make_field_init_node( fi_name.clone(), - ar_typed.clone(), + Rc::new(ar_typed.clone()), fi.span.clone(), node_name_span(fi.clone()), ), @@ -5965,7 +5965,7 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { __result.push(Rc::new(Node { name: field_init_node_name_at( - (*fir.typed_field).clone(), + fir.typed_field.clone(), (*scope.type_env).clone().source_indices.clone(), ), span: (*fir.typed_field).clone().span.clone(), @@ -6024,7 +6024,7 @@ pub fn infer_record_lit( } else { { let type_lookup = - lookup_type_by_name((*scope.type_env).clone(), type_name.clone().unwrap()); + lookup_type_by_name(scope.type_env.clone(), type_name.clone().unwrap()); let local_variant_parent = lookup_variant_parent_enum(scope.clone(), type_name.clone().unwrap()); let effective_lookup = match type_lookup.clone() { @@ -6034,7 +6034,7 @@ pub fn infer_record_lit( lookup_in_scope(scope.locals.clone(), type_name.clone().unwrap()); match local_lookup { Some(local_node) => { - lookup_type_for((*scope.type_env).clone(), local_node.clone()) + lookup_type_for(scope.type_env.clone(), local_node.clone()) } None => None, } @@ -6054,7 +6054,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( - (*fir.typed_field).clone(), + fir.typed_field.clone(), (*scope.type_env).clone().source_indices.clone(), ) == "value".to_string()) { @@ -6067,7 +6067,7 @@ pub fn infer_record_lit( .cloned(); match val_field { Some(val_fir) => with_optional_cardinality(resolved_type( - (*val_fir.infer_result.clone().typed).clone(), + val_fir.infer_result.clone().typed.clone(), )), None => raw_resolved, } @@ -6088,7 +6088,7 @@ pub fn infer_record_lit( let sole_ctor_diags = if type_has_sole_constructor(type_name.clone().unwrap(), scope.clone()) { match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), type_name.clone().unwrap(), ) { Some(decl) => { @@ -6593,7 +6593,7 @@ pub fn build_per_field_for_let( ExprData::ExprCall { .. } => { let callee = expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { @@ -6653,7 +6653,7 @@ pub fn build_per_field_for_let( } => { let callee = expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { @@ -6756,7 +6756,7 @@ pub fn resolve_collection_field( for f in Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ) .iter() @@ -6889,10 +6889,10 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let fields = inductive_fields_for( - (*scope.type_env).clone(), + scope.type_env.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -6962,7 +6962,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), None => match v1_rt::map_get( &ctx.param_names.clone(), @@ -6975,7 +6975,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { let callee = expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); - let from_provenance = match lookup_func_sig((*ctx.func_env).clone(), callee.clone()) { + let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) @@ -7065,7 +7065,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }; if ((elem.clone() != "".to_string()) - && is_recursive_type_by_name((*ctx.type_env).clone(), elem.clone())) + && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { let fields = - inductive_fields_for((*ctx.type_env).clone(), elem.clone()); + inductive_fields_for(ctx.type_env.clone(), elem.clone()); let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7571,7 +7571,7 @@ pub fn classify_argument( } } }; - let fields = inductive_fields_for((*ctx.type_env).clone(), type_name); + let fields = inductive_fields_for(ctx.type_env.clone(), type_name); let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { @@ -7612,7 +7612,7 @@ pub fn classify_argument( (*ctx.type_env).clone().source_indices.clone(), ); let from_provenance = match lookup_func_sig( - (*ctx.func_env).clone(), + ctx.func_env.clone(), callee.clone(), ) { Some(sig) => { @@ -7642,7 +7642,7 @@ pub fn classify_argument( None => "".to_string(), }; let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), type_name, ); let cf = Rc::new({ @@ -7918,10 +7918,10 @@ pub fn read_arg_provenance( } _ => { let fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), authored_name_at( (*ctx.type_env).clone().source_indices.clone(), - (*binding.resolved).clone(), + binding.resolved.clone(), ), ); let matching = Rc::new({ @@ -8153,11 +8153,11 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), source_type.clone(), ); let cf = Rc::new({ @@ -8205,7 +8205,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }); make_arg_node( @@ -8324,7 +8324,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ); Rc::new({ @@ -8368,7 +8368,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) - && ((inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()).len() + && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) || (scrut_inducing_field.clone() != None)); @@ -8378,7 +8378,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), (*ctx.type_env).clone().source_indices.clone(), ); - match lookup_func_sig((*ctx.func_env).clone(), callee) { + match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -8414,18 +8414,18 @@ let arm_ctx = match variant_arm_ctx.clone() { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { - let inner_ind_fields = inductive_fields_for((*c.type_env).clone(), ind_field.element_type.clone()); + let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { @@ -8439,14 +8439,14 @@ match inner_matching.clone() { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), param_order: ic.param_order.clone(), - type_env: (*ic.type_env).clone(), + type_env: ic.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ic.sub_value_vars.clone(), inner_bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: inner_ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ic.size_aliases.clone(), scope_locals: ic.scope_locals.clone(), - func_env: (*ic.func_env).clone(), + func_env: ic.func_env.clone(), per_field_vars: ic.per_field_vars.clone(), }) } else { @@ -8462,7 +8462,7 @@ match inner_matching.clone() { ctx.clone() }, None => { - let ind_fields = inductive_fields_for((*ctx.type_env).clone(), scrut_type.clone()); + let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { @@ -8476,14 +8476,14 @@ match matching.clone() { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(c.sub_value_vars.clone(), bind_name.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }) } else { @@ -8499,11 +8499,11 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::PreservedValue)), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }) } else { @@ -8512,14 +8512,14 @@ match matching.clone() { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), ind_field.element_type.clone()), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), bname.clone(), Rc::new(SubValueRelation::StrictSubValue { field: ind_field.clone(), factor: Rc::new(ShrinkFactor::UnitShrink), })), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => ctx.clone(), @@ -8599,7 +8599,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ctx.param_names.clone() }, param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), binding_name.clone(), @@ -8615,7 +8615,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }) } @@ -8623,7 +8623,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: ctx.sub_value_vars.clone(), size_aliases: inner_size_aliases, scope_locals: v1_rt::rc_map_insert( @@ -8635,7 +8635,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: inner_per_field, }), }; @@ -8716,7 +8716,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota acc.ctx.clone().param_names.clone() }, param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( acc.ctx.clone().sub_value_vars.clone(), bname.clone(), @@ -8732,7 +8732,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota provenance: rel.clone(), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }) } @@ -8740,7 +8740,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota fn_name: acc.ctx.clone().fn_name.clone(), param_names: acc.ctx.clone().param_names.clone(), param_order: acc.ctx.clone().param_order.clone(), - type_env: (*acc.ctx.clone().type_env).clone(), + type_env: acc.ctx.clone().type_env.clone(), sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), size_aliases: new_sa.clone(), scope_locals: v1_rt::rc_map_insert( @@ -8754,7 +8754,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), }), ), - func_env: (*acc.ctx.clone().func_env).clone(), + func_env: acc.ctx.clone().func_env.clone(), per_field_vars: acc.ctx.clone().per_field_vars.clone(), }), } @@ -8862,7 +8862,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( - (*ctx.type_env).clone(), + ctx.type_env.clone(), base_type.clone(), ) .iter() @@ -8951,7 +8951,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), @@ -8971,14 +8971,14 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_empty_map::>() } else { @@ -8986,7 +8986,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }, size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }, @@ -9081,7 +9081,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ind_field.element_type.clone(), ), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), fe_var.clone(), @@ -9091,18 +9091,18 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), None => Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), - type_env: (*ctx.type_env).clone(), + type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), - func_env: (*ctx.func_env).clone(), + func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), }), }; @@ -9762,7 +9762,7 @@ pub fn classify_body_per_field( let terminal = (*unwrapped.expr).clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( - terminal, + Rc::new(terminal), param_names, param_types, type_env.clone(), @@ -10077,7 +10077,7 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = compose_callee_param_map( + let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map)))))))))))))))))))))( param_map.clone(), call_args.clone(), c.param_order.clone(), @@ -10111,7 +10111,7 @@ pub fn arm_ctx_from_variant_provenance( fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), param_order: c.param_order.clone(), - type_env: (*c.type_env).clone(), + type_env: c.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( c.sub_value_vars.clone(), bind_name.clone(), @@ -10119,7 +10119,7 @@ pub fn arm_ctx_from_variant_provenance( ), size_aliases: c.size_aliases.clone(), scope_locals: c.scope_locals.clone(), - func_env: (*c.func_env).clone(), + func_env: c.func_env.clone(), per_field_vars: c.per_field_vars.clone(), }), } @@ -10341,7 +10341,7 @@ pub fn collect_variant_constructors( Some(sig) => { if ((authored_name_at( type_env.source_indices.clone(), - (*sig.inferred).clone(), + sig.inferred.clone(), ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) @@ -10674,7 +10674,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: provenance .clone(), @@ -10759,7 +10759,7 @@ pub fn populate_output_provenance( Rc::new(ResolvedFuncSig { name: sig.name.clone(), params: sig.params.clone(), - inferred: (*sig.inferred).clone(), + inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), output_provenance: if has_scalar.clone() { @@ -10873,7 +10873,7 @@ pub fn infer_property_values( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -10936,7 +10936,7 @@ pub fn infer_auth_source_properties( name: p.name.clone(), span: p.span.clone(), ident_span: p.ident_span.clone(), - children: Rc::new(vec![(*val_result.typed).clone()]), + children: Rc::new(vec![val_result.typed.clone()]), connective: p.connective.clone(), params: p.params.clone(), inferred: p.inferred.clone(), @@ -11101,7 +11101,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc body_typed.inferred.clone() }; let is_recursive = expr_has_self_call( - body_typed.clone(), + Rc::new(body_typed.clone()), authored_name_at( (*scope.type_env).clone().source_indices.clone(), item.clone(), @@ -11109,7 +11109,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - annotate_descent_evidence( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence)))))))))))))))))))))( body_typed.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -11121,7 +11121,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.func_env).clone(), ) } else { - body_typed.clone() + Rc::new(body_typed.clone()) }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11147,7 +11147,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno, is_self_recursive: is_recursive.clone(), has_non_tail_self_call: expr_has_non_tail_self_call( - body_typed.clone(), + Rc::new(body_typed.clone()), authored_name_at( (*scope.type_env).clone().source_indices.clone(), item.clone(), @@ -11188,7 +11188,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(body_typed.clone()), + body: Some(Rc::new(body_typed.clone())), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11238,7 +11238,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(val_typed.clone()), + body: Some(Rc::new(val_typed.clone())), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11762,7 +11762,7 @@ pub fn deps_excluding_leaf_self( source_indices: Rc>>, ) -> Rc> { { - let deps0 = node_type_deps((*b.resolved).clone(), source_indices); + let deps0 = node_type_deps(b.resolved.clone(), source_indices); let is_bare_self = (((((*b.resolved).clone().connective.clone() == Connective::NoConnective) && (((*b.resolved).clone().children.clone().len() as i64) == 0)) @@ -11884,7 +11884,7 @@ pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12314,7 +12314,7 @@ pub fn build_type_env( } __result }); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -12479,7 +12479,7 @@ pub fn build_type_env( } }, ); - let param_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let param_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let is_type_decl = match v1_rt::map_get( @@ -12605,7 +12605,7 @@ pub fn build_type_env( v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); @@ -12837,7 +12837,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - let module_name_str = authored_name_at(source_indices.clone(), (*module.module).clone()); + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12845,7 +12845,7 @@ pub fn build_type_env_unresolved( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(typed_parent) => Rc::new(vec![type_env_for_import( imp.module_path.clone(), - (*typed_parent.type_env).clone(), + typed_parent.type_env.clone(), )]), None => Rc::new(vec![]), }) @@ -12856,7 +12856,7 @@ pub fn build_type_env_unresolved( __result }); let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); - let local_bindings = module_items((*module.module).clone()).iter().cloned().fold( + let local_bindings = module_items(module.module.clone()).iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, item: Rc| { let item_ident = intern( @@ -13054,7 +13054,7 @@ pub fn build_type_env_unresolved( v1_rt::rc_set_insert(acc, name.clone()) }); let local_inductive_fields = build_item_inductive_fields( - module_items((*module.module).clone()), + module_items(module.module.clone()), cycle_set_for_inductive, source_indices.clone(), ); @@ -13199,12 +13199,12 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let func_sig = if (is_func || is_zero_arg_func) { { let declared_rt = if (ritem.inferred.clone() != None) { - Some(resolved_type(ritem.clone())) + Some(resolved_type(Rc::new(ritem.clone()))) } else { None }; Some(Rc::new(DeclaredFuncSig { - name: authored_name_at(env.source_indices.clone(), ritem.clone()), + name: authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), params: ritem.params.clone(), inferred: declared_rt, is_async: ((ritem.uses.clone().len() as i64) > 0), @@ -13237,7 +13237,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { let root = namespace_root_from_properties( ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), ritem.clone()), + authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), env.source_indices.clone(), ); Some(nominal_type_binding(root)) @@ -13246,13 +13246,13 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc None }; Rc::new(ItemContribution { - resolved_item: ritem.clone(), + resolved_item: Rc::new(ritem.clone()), resolve_diagnostics: resolved.diagnostics.clone(), func_sig: func_sig, svc_entries: svc_entries, svc_local: svc_local, item_info: build_item_info( - ritem.clone(), + Rc::new(ritem.clone()), env.source_indices.clone(), module_name.clone(), ), @@ -13292,7 +13292,7 @@ pub fn fold_module_contributions( svc_registry, authored_name_at( source_indices.clone(), - (*contribution.resolved_item).clone(), + contribution.resolved_item.clone(), ), contribution.svc_entries.clone(), ) @@ -13314,7 +13314,7 @@ pub fn fold_module_contributions( .collect::>(), ); let __tco_1 = - v1_rt::rc_list_push(resolved_items, (*contribution.resolved_item).clone()); + v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); let __tco_2 = next_func_sigs; let __tco_3 = next_svc_registry; let __tco_4 = next_svc_locals; @@ -13357,7 +13357,7 @@ pub fn insert_variant_owner_checked( ) -> Rc { match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { Some(prev) => { - let prev_name = authored_name_at(source_indices.clone(), (*prev.resolved).clone()); + let prev_name = authored_name_at(source_indices.clone(), prev.resolved.clone()); let owner_name = authored_name_at(source_indices.clone(), owner.clone()); let same_owner = (((prev_name.clone() == owner_name.clone()) && ((*prev.resolved).clone().span.clone().file.clone() @@ -13506,7 +13506,7 @@ pub fn owner_of_exported_arm( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if !import_is_all(imp.clone()) { __result.push(imp); } @@ -13601,7 +13601,7 @@ pub fn exported_coproduct_item( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if !import_is_all(imp.clone()) { __result.push(imp); } @@ -13802,7 +13802,7 @@ pub fn build_module_context( ); Rc::new(ModuleContext { resolved_items: local.resolved_items.clone(), - func_env: (*resolve_result.func_env).clone(), + func_env: resolve_result.func_env.clone(), svc_registry: merged_scope.svc_registry.clone(), locals: all_locals, variant_locals: env_variant_locals.clone(), @@ -13859,9 +13859,9 @@ pub fn typecheck_module( if ((env_errors.len() as i64) > 0) { return Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { - module: (*resolved.module).clone(), + module: resolved.module.clone(), items: Rc::new(vec![]), - type_env: env.clone(), + type_env: Rc::new(env.clone()), type_env_cache: env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: v1_rt::rc_empty_map::>(), @@ -13873,13 +13873,13 @@ pub fn typecheck_module( }); } let resolved_module_name = - authored_name_at(source_indices.clone(), (*resolved.module).clone()); + authored_name_at(source_indices.clone(), resolved.module.clone()); let contributions = Rc::new({ let mut __result = Vec::new(); - for item in module_items((*resolved.module).clone()).iter().cloned() { + for item in module_items(resolved.module.clone()).iter().cloned() { __result.push(analyze_item( item.clone(), - env.clone(), + Rc::new(env.clone()), resolved_module_name.clone(), )); } @@ -13889,7 +13889,7 @@ pub fn typecheck_module( contributions, parent_index.clone(), resolved.resolved_imports.clone(), - env.clone(), + Rc::new(env.clone()), resolved_module_name.clone(), ); let data_locals = ctx.resolved_items.clone().iter().cloned().fold( @@ -13914,8 +13914,8 @@ pub fn typecheck_module( }, ); let infer_scope = Rc::new(InferScope { - type_env: env.clone(), - func_env: (*ctx.func_env).clone(), + type_env: Rc::new(env.clone()), + func_env: ctx.func_env.clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), @@ -13938,7 +13938,7 @@ pub fn typecheck_module( } __result }); - let updated_func_env = populate_output_provenance( + let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance)))))))))))))))))))))( typed_items.clone(), (*ctx.func_env).clone(), env.clone(), @@ -13960,9 +13960,9 @@ pub fn typecheck_module( uses: item.uses.clone(), body: Some(annotate_descent_evidence( item.body.clone().clone().unwrap(), - authored_name_at(source_indices.clone(), item.clone()), + authored_name_at(source_indices.clone(), Rc::new(item.clone())), item.params.clone(), - env.clone(), + Rc::new(env.clone()), data_locals.clone(), updated_func_env.clone(), )), @@ -13977,7 +13977,7 @@ pub fn typecheck_module( ident: None, }) } else { - item.clone() + Rc::new(item.clone()) }, ); } @@ -13985,7 +13985,7 @@ pub fn typecheck_module( }); let typed_base = module_node( resolved_module_name.clone(), - module_imports((*resolved.module).clone()), + module_imports(resolved.module.clone()), ctx.resolved_items.clone(), (*resolved.module).clone().span.clone(), ); @@ -13997,7 +13997,7 @@ pub fn typecheck_module( typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: env.clone(), + type_env: Rc::new(env.clone()), type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), @@ -14143,8 +14143,8 @@ pub fn topo_resolve_types( Some(binding) => { let pre = (*binding.resolved).clone(); let result = - resolve_node(pre.clone(), env.clone(), module_name.clone()); - let resolved = preserve_nominal_brand_on_resolve( + resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve)))))))))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14206,8 +14206,8 @@ pub fn topo_resolve_types( match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { let pre = (*binding.resolved).clone(); - let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); - let resolved = preserve_nominal_brand_on_resolve( + let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve)))))))))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14298,7 +14298,7 @@ pub fn collect_parent_envs( } __result }); - let resolved_mod_name = authored_name_at(source_indices, (*resolved.module).clone()); + let resolved_mod_name = authored_name_at(source_indices, resolved.module.clone()); let diagnostics = Rc::new({ let mut __result = Vec::new(); for imp in resolved.resolved_imports.clone().iter().cloned() { @@ -14673,7 +14673,7 @@ pub fn typecheck_modules( let __tco_1 = v1_rt::rc_list_push(modules, typed.clone()); let __tco_2 = v1_rt::rc_map_insert( module_index, - authored_name_at(source_indices.clone(), (*typed.module).clone()), + authored_name_at(source_indices.clone(), typed.module.clone()), typed.clone(), ); let __tco_3 = v1_rt::rc_map_merge(item_registry, typed.item_registry.clone()); @@ -14811,7 +14811,7 @@ pub fn direct_import_exporter_count( ) -> i64 { (Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { if { let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { @@ -14891,7 +14891,7 @@ pub fn rewire_type_env_import_str_binding_identity( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -14935,7 +14935,7 @@ pub fn rewire_type_env_import_str_binding_identity( }, ); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { bindings: (*m.type_env).clone().bindings.clone(), @@ -14949,7 +14949,7 @@ pub fn rewire_type_env_import_str_binding_identity( intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), + func_env: m.func_env.clone(), item_registry: m.item_registry.clone(), }) }); @@ -15170,7 +15170,7 @@ pub fn rewire_type_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -15200,7 +15200,7 @@ pub fn rewire_type_env_parent_links( __result.push({ let import_parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = @@ -15208,7 +15208,7 @@ pub fn rewire_type_env_parent_links( match v1_rt::map_get(&index, path.clone()) { Some(parent) => Rc::new(vec![type_env_for_import( path.clone(), - (*parent.type_env).clone(), + parent.type_env.clone(), )]), None => Rc::new(vec![]), } @@ -15220,7 +15220,7 @@ pub fn rewire_type_env_parent_links( __result }); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { bindings: (*m.type_env).clone().bindings.clone(), @@ -15240,7 +15240,7 @@ pub fn rewire_type_env_parent_links( intern_table: (*m.type_env).clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), - func_env: (*m.func_env).clone(), + func_env: m.func_env.clone(), item_registry: m.item_registry.clone(), }) }); @@ -15260,7 +15260,7 @@ pub fn rewire_func_env_parent_links( |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, - authored_name_at(source_indices.clone(), (*m.module).clone()), + authored_name_at(source_indices.clone(), m.module.clone()), m.clone(), ) }, @@ -15271,7 +15271,7 @@ pub fn rewire_func_env_parent_links( __result.push({ let parents = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*m.module).clone()).iter().cloned() { + for imp in module_imports(m.module.clone()).iter().cloned() { __result.extend( (*{ let path = @@ -15288,9 +15288,9 @@ pub fn rewire_func_env_parent_links( __result }); Rc::new(TypedModule { - module: (*m.module).clone(), + module: m.module.clone(), items: m.items.clone(), - type_env: (*m.type_env).clone(), + type_env: m.type_env.clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: (*m.func_env).clone().local.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index 0ca86943c45..c3d02096a6e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -131,7 +131,7 @@ pub fn check_index_access_node( match keyed_collection_parts(normed.clone(), source_indices.clone()) { Some(parts) => { let key_diags = if node_type_equals( - (*parts.key_type).clone(), + parts.key_type.clone(), normed_index.clone(), source_indices.clone(), ) { @@ -140,7 +140,7 @@ pub fn check_index_access_node( Rc::new(vec![access_error("keyed collection index key type does not match the collection key type".to_string(), span.clone(), module_name)]) }; access_result( - with_optional_cardinality((*parts.value_type).clone()), + with_optional_cardinality(parts.value_type.clone()), key_diags, span.clone(), "invalid keyed collection index access".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index daa958bdc8e..77676a00023 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -209,14 +209,14 @@ pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { pub fn lookup_type(env: Rc, ident: i64) -> Option> { match lookup_binding(env, ident) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match lookup_binding_by_name(env, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 63743b2107e..58133bfe102 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -74,7 +74,7 @@ pub fn lookup_in_scope( name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { - Some(binding) => Some((*binding.resolved).clone()), + Some(binding) => Some(binding.resolved.clone()), None => None, } } @@ -499,7 +499,7 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some((*make_container_type("Witness".to_string(), raw.clone()).ty).clone()) + Some(make_container_type("Witness".to_string(), raw.clone()).ty.clone()) } } None => None, @@ -584,7 +584,7 @@ pub fn lookup_structural_method( { { let base_result = lookup_field_in_product( - (*enriched.ty).clone(), + enriched.ty.clone(), method_name.clone(), source_indices.clone(), ); @@ -613,8 +613,8 @@ pub fn lookup_structural_method( }; let resolution = match template_match { Some(t) => Some(Rc::new(MethodFieldResult { - field_node: (*mfr.field_node).clone(), - result_type: (*mfr.result_type).clone(), + field_node: mfr.field_node.clone(), + result_type: mfr.result_type.clone(), size_effect: t.size_effect.clone(), cost_shape: t.cost_shape.clone(), algebra_template: Some(t.clone()), @@ -660,7 +660,7 @@ pub fn resolve_known_method_node( match tier0.resolution.clone() { Some(mfr) => { let semantics = Rc::new(MethodSemantics::AlgebraMethodSemantics { - method_def: (*mfr.field_node).clone(), + method_def: mfr.field_node.clone(), fold_accumulator_type: fold_accumulator_type, size_effect: mfr.size_effect.clone(), cost_shape: mfr.cost_shape.clone(), @@ -668,7 +668,7 @@ pub fn resolve_known_method_node( }); Rc::new(KnownMethodResolution { semantics: Some(semantics), - result_type: Some((*mfr.result_type).clone()), + result_type: Some(mfr.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }) } @@ -686,7 +686,7 @@ pub fn resolve_known_method_node( ), op_params: svc_result.op_params.clone(), })), - result_type: Some((*svc_result.result_type).clone()), + result_type: Some(svc_result.result_type.clone()), diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 12c6fb18bc5..7e4b3673ab3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,24 +44,24 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - (*make_map_type( + Rc::new((*make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) .ty) - .clone() + .clone()) } pub fn list_of_type_variable(id: String) -> Rc { - (*make_container_type("List".to_string(), type_variable_node(id)).ty).clone() + make_container_type("List".to_string(), type_variable_node(id)).ty.clone() } pub fn list_of_element(element: Rc) -> Rc { - (*make_container_type("List".to_string(), element).ty).clone() + make_container_type("List".to_string(), element).ty.clone() } pub fn witness_of_element(element: Rc) -> Rc { - (*make_container_type("Witness".to_string(), element).ty).clone() + make_container_type("Witness".to_string(), element).ty.clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -129,9 +129,9 @@ pub fn builtin_function_registry() -> Rc>> { ) .ty) .clone(); - let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); - let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), Rc::new(set_ty.clone())); + let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), Rc::new(set_ty.clone())); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty.clone())); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 93bb2d20793..8fe704ae16a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -144,7 +144,7 @@ pub fn collect_unit_variant_phantom_matches( Rc::new(vec![]), |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( env.clone(), - structural_type_for_variant_lookup(env.clone(), (*binding.resolved).clone()), + structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), variant_name.clone(), ) { Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), @@ -268,14 +268,14 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S }; if ((((brand.clone() != "".to_string()) && (brand.clone() - != authored_name_at(source_indices.clone(), structural.clone()))) + != authored_name_at(source_indices.clone(), Rc::new(structural.clone())))) && !is_declared_container_alias_spelling(brand.clone())) && !is_transparent_primitive_alias_rhs( - structural.clone(), + Rc::new(structural.clone()), source_indices.clone(), )) { - with_authored_identity(n.clone(), structural.clone()) + with_authored_identity(n.clone(), Rc::new(structural.clone())) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) @@ -291,7 +291,7 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S ) .resolved) .clone(); - with_authored_identity(n.clone(), target_resolved) + with_authored_identity(n.clone(), Rc::new(target_resolved)) } _ => resolved.clone(), } @@ -401,7 +401,7 @@ pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Op .cloned() { Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => Some((*b.resolved).clone()), + Some(b) => Some(b.resolved.clone()), None => None, }, None => None, @@ -624,8 +624,8 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - (*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) - .clone() + Rc::new((*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) + .clone()) } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), @@ -758,7 +758,7 @@ pub fn resolve_node_bounded( name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: Rc::new(vec![base_resolved]), + children: Rc::new(vec![Rc::new(base_resolved)]), connective: n.connective.clone(), params: n.params.clone(), inferred: n.inferred.clone(), @@ -813,7 +813,7 @@ pub fn resolve_node_bounded( params: child.params.clone(), inferred: Some(Rc::new( InferredNode::Resolved { - node: rt_resolved.clone(), + node: Rc::new(rt_resolved.clone()), }, )), return_cardinality: child @@ -896,7 +896,7 @@ pub fn resolve_node_bounded( let inner_resolved = (*inner_result.resolved).clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { - resolved: with_optional_cardinality(inner_resolved), + resolved: with_optional_cardinality(Rc::new(inner_resolved)), diagnostics: inner_diags, }) } @@ -966,7 +966,7 @@ pub fn resolve_node_bounded( connective: field_child.connective.clone(), params: field_child.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: rt_resolved.clone(), + node: Rc::new(rt_resolved.clone()), })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), @@ -1177,7 +1177,7 @@ pub fn resolve_node_bounded( Some(arg) => v1_rt::rc_map_insert( acc.clone(), slot_name.clone(), - arg.clone(), + Rc::new(arg.clone()), ), None => acc.clone(), } @@ -1378,7 +1378,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: key_resolved, + node: Rc::new(key_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1400,7 +1400,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: val_resolved, + node: Rc::new(val_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1473,7 +1473,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: el_resolved, + node: Rc::new(el_resolved), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1797,10 +1797,10 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc::new(FieldResult { field: make_field_node( field_node_name_at(field.clone(), env.source_indices.clone()), - type_resolved, + Rc::new(type_resolved), field_node_cardinality(field.clone()), match default_resolved.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, field_node_from_key(field.clone(), env.source_indices.clone()), @@ -1826,7 +1826,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> connective: authored_type.connective.clone(), params: authored_type.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: type_resolved.clone(), + node: Rc::new(type_resolved.clone()), })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), @@ -1841,7 +1841,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> ident: None, }) } else { - type_resolved.clone() + Rc::new(type_resolved.clone()) }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), @@ -1893,7 +1893,7 @@ pub fn resolve_resource_use( Rc::new(ResourceUseResult { resource_use: make_resource_use_node( resource_use_name_at(ru.clone(), env.source_indices.clone()), - type_resolved, + Rc::new(type_resolved), ru.span.clone(), node_name_span(ru.clone()), ), @@ -1914,7 +1914,7 @@ pub fn resolve_named_arg( Rc::new(NamedArgResolveResult { arg: make_arg_node( arg_name_at(arg.clone(), env.source_indices.clone()), - value_expr, + Rc::new(value_expr), arg.span.clone(), node_name_span(arg.clone()), ), @@ -1939,7 +1939,7 @@ pub fn resolve_field_init( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(field_init.clone(), env.source_indices.clone()), - value_expr, + Rc::new(value_expr), field_init.span.clone(), node_name_span(field_init.clone()), ), @@ -1975,10 +1975,10 @@ pub fn resolve_match_arm( arm: make_arm_node( arm_pattern(arm.clone()), match guard_result.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }, - body_expr, + Rc::new(body_expr), arm.span.clone(), ), diagnostics: v1_rt::concat(guard_diags, body_diags), @@ -2004,7 +2004,7 @@ pub fn resolve_string_part( let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { - expr: resolved_expr, + expr: Rc::new(resolved_expr), }), diagnostics: expr_diags, }) @@ -2036,7 +2036,7 @@ pub fn resolve_transport_binding( Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(p.clone(), env.source_indices.clone()), - (*val_result.expr).clone(), + val_result.expr.clone(), p.span.clone(), node_name_span(p.clone()), ), @@ -2149,7 +2149,7 @@ pub fn resolve_expr_types( }), }; Rc::new(ExprResolveResult { - expr: map_children(texpr.clone(), |child| (*r.expr).clone()), + expr: map_children(texpr.clone(), |child| r.expr.clone()), diagnostics: r.diagnostics.clone(), }) } @@ -2175,7 +2175,7 @@ pub fn resolve_expr_types( } else { Some(authored_name(env.clone(), arg_node.clone())) }, - (*vr.expr).clone(), + vr.expr.clone(), arg_node.span.clone(), node_name_span(arg_node.clone()), ), @@ -2244,7 +2244,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*rr.expr).clone(), + expr: rr.expr.clone(), diagnostics: rr.diagnostics.clone(), }) } @@ -2269,7 +2269,7 @@ pub fn resolve_expr_types( child.clone(), )) }, - (*vr.expr).clone(), + vr.expr.clone(), child.span.clone(), node_name_span(child.clone()), ), @@ -2336,7 +2336,7 @@ pub fn resolve_expr_types( module_name.clone(), ); Rc::new(ExprResolveResult { - expr: (*sr.expr).clone(), + expr: sr.expr.clone(), diagnostics: sr.diagnostics.clone(), }) } @@ -2375,8 +2375,8 @@ pub fn resolve_expr_types( Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - Some((*guard_r.expr).clone()), - (*body_r.expr).clone(), + Some(guard_r.expr.clone()), + body_r.expr.clone(), child.span.clone(), ), diagnostics: v1_rt::concat( @@ -2405,7 +2405,7 @@ pub fn resolve_expr_types( None => Rc::new(MatchPattern::Wildcard), }, None, - (*body_r.expr).clone(), + body_r.expr.clone(), child.span.clone(), ), diagnostics: body_r.diagnostics.clone(), @@ -2545,7 +2545,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_field_init_node( authored_name(env.clone(), fi_node.clone()), - (*vr.expr).clone(), + vr.expr.clone(), fi_node.span.clone(), node_name_span(fi_node.clone()), ), @@ -2645,7 +2645,7 @@ pub fn resolve_expr_types( op: op.clone(), algebra_field: af.clone(), }), - Rc::new(vec![(*lr.expr).clone(), (*rr.expr).clone()]), + Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2663,7 +2663,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![(*r.expr).clone()]), + Rc::new(vec![r.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2690,7 +2690,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![(*r.expr).clone()]), lam_param_nodes), + v1_rt::concat(Rc::new(vec![r.expr.clone()]), lam_param_nodes), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2715,7 +2715,7 @@ pub fn resolve_expr_types( ); Rc::new(ExprResolveResult { expr: make_interp_part_node( - (*r.expr).clone(), + r.expr.clone(), part_node.span.clone(), ), diagnostics: r.diagnostics.clone(), @@ -2811,7 +2811,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![(*r.expr).clone(), (*tr.resolved).clone()]), + Rc::new(vec![r.expr.clone(), tr.resolved.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2838,7 +2838,7 @@ pub fn resolve_expr_types( expr: make_named_expr_node( foreach_variable_at(texpr.clone(), env.source_indices.clone()), Rc::new(ExprData::ExprForEach), - Rc::new(vec![(*cr.expr).clone(), (*br.expr).clone()]), + Rc::new(vec![cr.expr.clone(), br.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), node_name_span(texpr.clone()), @@ -2869,7 +2869,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![(*br.expr).clone(), (*ir.expr).clone()]), + Rc::new(vec![br.expr.clone(), ir.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -2909,9 +2909,9 @@ pub fn resolve_expr_types( expr: make_expr_node( Rc::new(ExprData::ExprSlice), Rc::new(vec![ - (*br.expr).clone(), - (*sr.expr).clone(), - (*er.expr).clone(), + br.expr.clone(), + sr.expr.clone(), + er.expr.clone(), ]), texpr.inferred.clone(), texpr.span.clone(), @@ -2935,7 +2935,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprReturn), - Rc::new(vec![(*r.expr).clone()]), + Rc::new(vec![r.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -3140,7 +3140,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_ret = if (item.inferred.clone() == None) { None } else { - Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) + Some(Rc::new(InferredNode::Resolved { node: Rc::new(ret_resolved) })) }; let use_results = Rc::new({ let mut __result = Vec::new(); diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 74bdb302d18..c34bb9630bd 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -866,9 +866,9 @@ pub fn instantiate_algebra_type( }; let inner_b = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type(kind_name, (*inner_b.ty).clone()); + let built = make_container_type(kind_name, inner_b.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_b.diagnostics.clone(), built.diagnostics.clone(), @@ -879,16 +879,16 @@ pub fn instantiate_algebra_type( let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } AlgebraTypeTemplate::WitnessOf { inner: inner, .. } => { let ib = instantiate_algebra_type(inner.clone(), base.clone(), source_indices.clone()); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -934,7 +934,7 @@ pub fn instantiate_algebra_type( }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: make_callable_type(param_nodes, (*rb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -974,18 +974,18 @@ pub fn instantiate_algebra_field( __result }); let return_b = instantiate_algebra_type( - (*template.return_type).clone(), + template.return_type.clone(), base.clone(), source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - algebra_method_field( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))( template.name.clone(), param_types.clone(), (*return_b.ty).clone(), ) } else { - algebra_value_field(template.name.clone(), (*return_b.ty).clone()) + algebra_value_field(template.name.clone(), return_b.ty.clone()) }; Rc::new(KernelTypeBuild { ty: field_ty, @@ -1475,9 +1475,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type(kind_name, (*inner_applied.ty).clone()); + let built = make_container_type(kind_name, inner_applied.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat( inner_applied.diagnostics.clone(), built.diagnostics.clone(), @@ -1492,7 +1492,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: with_optional_cardinality((*ib.ty).clone()), + ty: with_optional_cardinality(ib.ty.clone()), diagnostics: ib.diagnostics.clone(), }) } @@ -1503,9 +1503,9 @@ pub fn apply_type_substitution( receiver.clone(), source_indices.clone(), ); - let built = make_container_type("Witness".to_string(), (*ib.ty).clone()); + let built = make_container_type("Witness".to_string(), ib.ty.clone()); Rc::new(KernelTypeBuild { - ty: (*built.ty).clone(), + ty: built.ty.clone(), diagnostics: v1_rt::concat(ib.diagnostics.clone(), built.diagnostics.clone()), }) } @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: make_tuple_type((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1575,7 +1575,7 @@ pub fn apply_type_substitution( for pn in param_nodes.iter().cloned() { __result.push(make_param_node( "_".to_string(), - pn.clone(), + Rc::new(pn.clone()), None, no_span(), no_span(), @@ -1583,7 +1583,7 @@ pub fn apply_type_substitution( } __result }), - (*rb.ty).clone(), + rb.ty.clone(), ), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) @@ -1592,11 +1592,11 @@ pub fn apply_type_substitution( } pub fn template_return_is_receiver_self(template: Rc) -> bool { - is_receiver_self((*template.return_type).clone()) + is_receiver_self(template.return_type.clone()) } pub fn template_return_has_variables(template: Rc) -> bool { - has_type_variable((*template.return_type).clone()) + has_type_variable(template.return_type.clone()) } pub fn has_type_variable(t: Rc) -> bool { @@ -1631,7 +1631,7 @@ pub fn resolve_type_variables_from_template( source_indices.clone(), ); apply_type_substitution( - (*template.return_type).clone(), + template.return_type.clone(), subst, receiver_type.clone(), source_indices.clone(), diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index e0740a56f2b..5e140789267 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -187,7 +187,7 @@ pub fn normalize_graph( for m in graph.modules.clone().iter().cloned() { __result.extend( (*{ - let items = module_items((*m.module).clone()); + let items = module_items(m.module.clone()); Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { @@ -196,7 +196,7 @@ pub fn normalize_graph( item.clone(), authored_name_at( source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ), source_indices.clone(), )) diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index c1414cba6ac..9e84c2e617c 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -2080,7 +2080,7 @@ pub fn parse_with_table( } else { Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: Some((*r.module).clone()), + module: Some(r.module.clone()), error: None, }), intern_table: r.ctx.clone().intern_table.clone(), @@ -2235,7 +2235,7 @@ pub fn parse_imports_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.import).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.import.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -2283,7 +2283,7 @@ pub fn parse_items_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.item).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.item.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -3426,7 +3426,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( rv.tokens.clone(), rv.ctx.clone(), - Rc::new(vec![(*rv.variant).clone()]), + Rc::new(vec![rv.variant.clone()]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3508,7 +3508,7 @@ pub fn parse_type_body_after_eq( let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), - Rc::new(vec![first_variant]), + Rc::new(vec![Rc::new(first_variant)]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -3575,7 +3575,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3594,7 +3594,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3631,7 +3631,7 @@ pub fn parse_type_body_after_eq( let wr = try_where_clause( r.tokens.clone(), r.ctx.clone(), - (*r.type_expr).clone(), + r.type_expr.clone(), start_span.clone(), ); if has_err(wr.err.clone()) { @@ -3650,7 +3650,7 @@ pub fn parse_type_body_after_eq( connective: Connective::NoConnective, params: type_params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*wr.type_expr).clone(), + node: wr.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -3778,7 +3778,7 @@ pub fn parse_predicates_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.predicate).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.predicate.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = skip_newlines(__ec.clone()); @@ -4299,7 +4299,7 @@ pub fn parse_positional_variant_type_fields( } let field = make_field_node( "0".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), Cardinality::Required, None, None, @@ -4479,7 +4479,7 @@ pub fn parse_more_variants_acc( { let __tco_0 = r2.tokens.clone(); let __tco_1 = r2.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r2.variant).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r2.variant.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -4677,7 +4677,7 @@ pub fn parse_callable_type_expr( connective: Connective::Arrow, params: params_result.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: (*ret.type_expr).clone(), + node: ret.type_expr.clone(), })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -4712,7 +4712,7 @@ pub fn parse_callable_param_types( } let param = make_param_node( "".to_string(), - (*r.type_expr).clone(), + r.type_expr.clone(), None, (*r.type_expr).clone().span.clone(), (*r.type_expr).clone().span.clone(), @@ -4764,7 +4764,7 @@ pub fn finish_type_expr_from_name( } let first_arg = (*r.type_expr).clone(); let type_args = - collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); + collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![Rc::new(first_arg)])); if has_err(type_args.err.clone()) { return Rc::new(TypeResult { type_expr: dummy_te.clone(), @@ -4920,7 +4920,7 @@ pub fn collect_type_args( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(args, (*r.type_expr).clone()); + let __tco_2 = v1_rt::rc_list_push(args, r.type_expr.clone()); tokens = __tco_0; ctx = __tco_1; args = __tco_2; @@ -5021,7 +5021,7 @@ pub fn parse_field_list_acc( }); { let __tco_0 = r.ctx.clone(); - let __tco_1 = v1_rt::rc_list_push(acc, (*r.field).clone()); + let __tco_1 = v1_rt::rc_list_push(acc, r.field.clone()); ctx = __tco_0; acc = __tco_1; continue; @@ -5083,7 +5083,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let f = make_field_node( name, - te.clone(), + Rc::new(te.clone()), te.return_cardinality.clone(), None, from_key, @@ -5347,7 +5347,7 @@ pub fn parse_fn_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5449,7 +5449,7 @@ pub fn parse_fn_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5681,7 +5681,7 @@ pub fn parse_block_item_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5751,7 +5751,7 @@ pub fn parse_block_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(body), + body: Some(Rc::new(body)), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5856,7 +5856,7 @@ pub fn parse_uses_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.resource_use).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.resource_use.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { let __tco_0 = __ec.clone(); @@ -5966,7 +5966,7 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc { let ru = make_resource_use_node( name, - (*r3.type_expr).clone(), + r3.type_expr.clone(), start_span.clone(), r.span.clone(), ); @@ -6039,7 +6039,7 @@ pub fn parse_resource_config_acc( err: r3.err.clone(), }); } - let fi = make_field_init_node(field_name, (*r3.expr).clone(), zero_span, r.span.clone()); + let fi = make_field_init_node(field_name, r3.expr.clone(), zero_span, r.span.clone()); acc = v1_rt::rc_list_push(acc.clone(), fi); match (*eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { @@ -6075,7 +6075,7 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - } Rc::new(OptRetResult { inferred: Some(Rc::new(InferredNode::Resolved { - node: (*r.type_expr).clone(), + node: r.type_expr.clone(), })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), @@ -6241,7 +6241,7 @@ pub fn parse_service_after_kw( ); let svc_props = match r.config.clone() { Some(cfg) => service_config_properties( - (*cfg.endpoint).clone(), + cfg.endpoint.clone(), cfg.auth.clone(), cfg.auth_input.clone(), cfg.auth_source.clone(), @@ -6261,7 +6261,7 @@ pub fn parse_service_after_kw( uses: Rc::new(vec![]), body: None, connective: Connective::NoConnective, - transport: Some((*r.transport).clone()), + transport: Some(r.transport.clone()), properties: v1_rt::concat(Rc::new(vec![ns_prop]), svc_props), type_annotation: None, is_self_recursive: false, @@ -6389,7 +6389,7 @@ pub fn parse_service_entries( let __tco_2 = (*r.transport).clone(); tokens = __tco_0; ctx = __tco_1; - transport = __tco_2; + transport = Rc::new(__tco_2); continue; } } else { @@ -6425,7 +6425,7 @@ pub fn parse_service_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(operations, (*r.operation).clone()); + let __tco_2 = v1_rt::rc_list_push(operations, r.operation.clone()); tokens = __tco_0; ctx = __tco_1; operations = __tco_2; @@ -6640,7 +6640,7 @@ pub fn parse_transport_binding( parse_rest_binding_body(skip_newlines(r.tokens.clone()), ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6659,7 +6659,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6686,7 +6686,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6705,7 +6705,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -6732,7 +6732,7 @@ pub fn parse_transport_binding( ); if has_err(r2.err.clone()) { return Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -6751,7 +6751,7 @@ pub fn parse_transport_binding( }); } Rc::new(TransportResult { - transport: (*r2.transport).clone(), + transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), err: None, @@ -8164,8 +8164,8 @@ pub fn parse_exit_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(code, ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let code_str = status_expr_to_str(Rc::new(code), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( prop_name, @@ -8482,8 +8482,8 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(status, ctx.source_indices.clone()); - let type_name = node_to_name_str((*r3.type_expr).clone(), ctx.source_indices.clone()); + let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( prop_name, @@ -8641,9 +8641,9 @@ pub fn parse_mock_response_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(status, ctx.source_indices.clone()); + let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); let prop_name = v1_rt::concat("mock_".to_string(), status_str); - let entry = make_field_init_node(prop_name, body, make_span(0, 0), make_span(0, 0)); + let entry = make_field_init_node(prop_name, Rc::new(body), make_span(0, 0), make_span(0, 0)); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), @@ -8863,7 +8863,7 @@ pub fn parse_resource_entries( let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); let __tco_2 = - v1_rt::rc_list_push(capabilities, (*r.capability).clone()); + v1_rt::rc_list_push(capabilities, r.capability.clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -8983,7 +8983,7 @@ pub fn parse_resource_entries( } let fi = make_field_init_node( fname, - (*r3.expr).clone(), + r3.expr.clone(), make_span(0, 0), r.span.clone(), ); @@ -9507,11 +9507,11 @@ pub fn parse_data_after_kw( inferred: None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some((*r.expr).clone()), + body: Some(r.expr.clone()), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), - type_annotation: Some(te), + type_annotation: Some(Rc::new(te)), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -9592,7 +9592,7 @@ pub fn parse_param_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.param).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.param.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -9665,7 +9665,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, type_expr, None, start_span.clone(), name_span); + let p = make_param_node(name, Rc::new(type_expr), None, start_span.clone(), name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -9807,7 +9807,7 @@ pub fn parse_stmts_acc( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = v1_rt::rc_list_push(acc, (*r.expr).clone()); + let __tco_2 = v1_rt::rc_list_push(acc, r.expr.clone()); tokens = __tco_0; ctx = __tco_1; acc = __tco_2; @@ -9942,7 +9942,7 @@ pub fn parse_constrained_assignment( let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![(*r3.expr).clone()]), + Rc::new(vec![r3.expr.clone()]), None, span, name_span, @@ -10045,7 +10045,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> let node = make_named_expr_node( name, Rc::new(ExprData::ExprLet), - Rc::new(vec![(*r3.expr).clone()]), + Rc::new(vec![r3.expr.clone()]), None, span, name_span, @@ -10170,7 +10170,7 @@ pub fn parse_expr_bp( return r.clone(); } let lhs = (*r.expr).clone(); - parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) + parse_expr_loop(r.tokens.clone(), r.ctx.clone(), Rc::new(lhs), min_bp) } } @@ -10207,7 +10207,7 @@ pub fn parse_expr_loop( let __tco_2 = (*post.expr).clone(); tokens = __tco_0; ctx = __tco_1; - lhs = __tco_2; + lhs = Rc::new(__tco_2); continue; } } else { @@ -10266,7 +10266,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10278,7 +10278,7 @@ pub fn parse_expr_loop( let __tco_2 = (*r.expr).clone(); tokens = __tco_0; ctx = __tco_1; - lhs = __tco_2; + lhs = Rc::new(__tco_2); continue; } } else { @@ -10290,7 +10290,7 @@ pub fn parse_expr_loop( ); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -10309,7 +10309,7 @@ pub fn parse_expr_loop( }), Rc::new(vec![ lhs.clone(), - (*r.expr).clone(), + r.expr.clone(), ]), None, loop_span, @@ -10520,7 +10520,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -11390,7 +11390,7 @@ pub fn parse_index_or_slice( let r = parse_expr(r.tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -11404,7 +11404,7 @@ pub fn parse_index_or_slice( let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ExprResult { - expr: (*r.expr).clone(), + expr: r.expr.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -11423,7 +11423,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![base, first_expr, end_expr]), + Rc::new(vec![base, Rc::new(first_expr), Rc::new(end_expr)]), None, span, ), @@ -11446,7 +11446,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base, first_expr]), + Rc::new(vec![base, Rc::new(first_expr)]), None, span, ), @@ -11525,7 +11525,7 @@ pub fn parse_arg_list_acc( err: r.err.clone(), }); } - acc = v1_rt::rc_list_push(acc.clone(), (*r.arg).clone()); + acc = v1_rt::rc_list_push(acc.clone(), r.arg.clone()); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { EatResult::EatConsumed { tokens: __ec, .. } => { tokens = skip_newlines(__ec.clone()); @@ -11582,7 +11582,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R }); } Rc::new(GuardResult { - guard: Some((*r.expr).clone()), + guard: Some(r.expr.clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: None, @@ -12487,7 +12487,7 @@ pub fn parse_variant_pattern( } let fb = make_field_binding_node( "0".to_string(), - (*r.pattern).clone(), + r.pattern.clone(), span, kernel_span("0".to_string()), ); @@ -12573,7 +12573,7 @@ pub fn parse_variant_bindings_brace_acc( }); let fb = make_field_binding_node( field_name.clone(), - (*r2.pattern).clone(), + r2.pattern.clone(), bind_span, field_name_span, ); @@ -12665,7 +12665,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![condition, then_branch]), + Rc::new(vec![Rc::new(condition), Rc::new(then_branch)]), None, span, ), @@ -12769,7 +12769,7 @@ pub fn parse_let(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Date: Sun, 5 Jul 2026 04:46:49 +0000 Subject: [PATCH 19/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_complexity.rs | 32 ++++++++++---------- src/v1/stage0/src/v1_compiler_emit_rust.rs | 14 ++++----- src/v1/stage0/src/v1_compiler_infer.rs | 18 +++++------ src/v1/stage0/src/v1_compiler_infer_types.rs | 8 ++--- src/v1/stage0/src/v1_compiler_parse.rs | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index ae8cc3fc7d2..9cfd9c91d3c 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -8628,11 +8628,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8645,11 +8645,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*args_result.summary.clone().work).clone(), (*callee_result.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*args_result.summary.clone().span).clone(), (*callee_result.summary.clone().span).clone(), ), @@ -8745,11 +8745,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8822,11 +8822,11 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( (*(*acc.result).clone().summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( (*(*acc.result).clone().summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8963,11 +8963,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*v_r.summary.clone().work).clone(), (*b_r.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*v_r.summary.clone().span).clone(), (*b_r.summary.clone().span).clone(), ), @@ -9002,11 +9002,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*sr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*sr.summary.clone().span).clone(), ), @@ -9074,11 +9074,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), @@ -9111,11 +9111,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index f31471e25a7..b1d1b988134 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -3747,7 +3747,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3813,7 +3813,7 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3922,7 +3922,7 @@ pub fn emit_module_full( __result }); let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3985,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4009,20 +4009,20 @@ pub fn emit_module_full( } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 5727d713c85..546f803d36f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -771,7 +771,7 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for)))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(parent) => { let is_coproduct = (parent.connective.clone() == Connective::Disj); if is_coproduct { @@ -810,7 +810,7 @@ pub fn variant_owner_node_authority() -> String { pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for)))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(owner) => { let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); if owner_is_coproduct { @@ -3202,7 +3202,7 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags)))))))))))))))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))( value_params_for_check, typed_args.clone(), call_subst.clone(), @@ -4199,7 +4199,7 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness)))))))))))))))))))))( + } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))( resolved_scrutinee.clone(), typed_arms.clone(), (*scope.type_env).clone(), @@ -10077,7 +10077,7 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map)))))))))))))))))))))( + let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))( param_map.clone(), call_args.clone(), c.param_order.clone(), @@ -11109,7 +11109,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence)))))))))))))))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))( body_typed.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -13938,7 +13938,7 @@ pub fn typecheck_module( } __result }); - let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance)))))))))))))))))))))( + let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))( typed_items.clone(), (*ctx.func_env).clone(), env.clone(), @@ -14144,7 +14144,7 @@ pub fn topo_resolve_types( let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve)))))))))))))))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14207,7 +14207,7 @@ pub fn topo_resolve_types( Some(binding) => { let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve)))))))))))))))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index c34bb9630bd..e4524ca2d05 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -934,7 +934,7 @@ pub fn instantiate_algebra_type( }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))(param_nodes, (*rb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -979,7 +979,7 @@ pub fn instantiate_algebra_field( source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))( template.name.clone(), param_types.clone(), (*return_b.ty).clone(), @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 9e84c2e617c..0858d6d4efe 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -12077,7 +12077,7 @@ pub fn parse_match_arm(tokens: Rc, ctx: Rc) -> Rc Date: Sun, 5 Jul 2026 04:57:19 +0000 Subject: [PATCH 20/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_complexity.rs | 32 ++++++++++---------- src/v1/stage0/src/v1_compiler_emit_rust.rs | 14 ++++----- src/v1/stage0/src/v1_compiler_infer.rs | 18 +++++------ src/v1/stage0/src/v1_compiler_infer_types.rs | 8 ++--- src/v1/stage0/src/v1_compiler_parse.rs | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 9cfd9c91d3c..c4c048ea455 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -8628,11 +8628,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8645,11 +8645,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*args_result.summary.clone().work).clone(), (*callee_result.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*args_result.summary.clone().span).clone(), (*callee_result.summary.clone().span).clone(), ), @@ -8745,11 +8745,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8822,11 +8822,11 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))))))))))))))))))( (*(*acc.result).clone().summary.clone().work).clone(), (*ar.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))))))))))))))))))( (*(*acc.result).clone().summary.clone().span).clone(), (*ar.summary.clone().span).clone(), ), @@ -8963,11 +8963,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*v_r.summary.clone().work).clone(), (*b_r.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*v_r.summary.clone().span).clone(), (*b_r.summary.clone().span).clone(), ), @@ -9002,11 +9002,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().work).clone(), (*sr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().span).clone(), (*sr.summary.clone().span).clone(), ), @@ -9074,11 +9074,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), @@ -9111,11 +9111,11 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().work).clone(), (*cr.summary.clone().work).clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))( + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( (*acc.summary.clone().span).clone(), (*cr.summary.clone().span).clone(), ), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b1d1b988134..44c791c0fb1 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -3747,7 +3747,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), Rc::new(m.clone())), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3813,7 +3813,7 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(authored_name(scope.type_env.clone(), Rc::new(m.clone()))); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3922,7 +3922,7 @@ pub fn emit_module_full( __result }); let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()); + let this_module_name = authored_name(scope.type_env.clone(), Rc::new(m.clone())); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3985,7 +3985,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), Rc::new(m.clone())), registry.clone(), scope.clone(), shared_types.clone(), @@ -4009,20 +4009,20 @@ pub fn emit_module_full( } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), Rc::new(m.clone()))); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (authored_name(scope.type_env.clone(), Rc::new(m.clone())) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name))))))))((*scope.type_env).clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), Rc::new(m.clone()))), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 546f803d36f..7e17adad060 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -771,7 +771,7 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(parent) => { let is_coproduct = (parent.connective.clone() == Connective::Disj); if is_coproduct { @@ -810,7 +810,7 @@ pub fn variant_owner_node_authority() -> String { pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { + match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { Some(owner) => { let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); if owner_is_coproduct { @@ -3202,7 +3202,7 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))))))))))))))))))))))))( value_params_for_check, typed_args.clone(), call_subst.clone(), @@ -4199,7 +4199,7 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))( + } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))))))))))))))))))))))))( resolved_scrutinee.clone(), typed_arms.clone(), (*scope.type_env).clone(), @@ -10077,7 +10077,7 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))( + let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))))))))))))))))))))))))( param_map.clone(), call_args.clone(), c.param_order.clone(), @@ -11109,7 +11109,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc (*scope.type_env).clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))))))))))))))))))))))))( body_typed.clone(), authored_name_at( (*scope.type_env).clone().source_indices.clone(), @@ -13938,7 +13938,7 @@ pub fn typecheck_module( } __result }); - let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))( + let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))))))))))))))))))))))))( typed_items.clone(), (*ctx.func_env).clone(), env.clone(), @@ -14144,7 +14144,7 @@ pub fn topo_resolve_types( let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))))))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), @@ -14207,7 +14207,7 @@ pub fn topo_resolve_types( Some(binding) => { let pre = (*binding.resolved).clone(); let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))( + let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))))))))))))))))))( pre.clone(), (*result.resolved).clone(), binding.name.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index e4524ca2d05..968c11e800a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))))))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -934,7 +934,7 @@ pub fn instantiate_algebra_type( }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))(param_nodes, (*rb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))))))))))))))))))))))))(param_nodes, (*rb.ty).clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -979,7 +979,7 @@ pub fn instantiate_algebra_field( source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))( + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))))))))))))))))))))))))( template.name.clone(), param_types.clone(), (*return_b.ty).clone(), @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))))))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 0858d6d4efe..55472764352 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -12077,7 +12077,7 @@ pub fn parse_match_arm(tokens: Rc, ctx: Rc) -> Rc Date: Sun, 5 Jul 2026 05:03:20 +0000 Subject: [PATCH 21/27] Repair seed: pin src/v1/stage0 to origin/main content + take_owned_counted v1_rt helper The earlier restore-then-merge auto-merged generated seed files across generations, committing a mixed-generation seed that does not build (732 errors) and dropping the v1_rt counted helper. The branch's intended seed delta is exactly one file: v1_rt.rs gains take_owned_counted + its counters. Verified: cargo build -p v1-compiler clean (0 errors) on this tree. Co-Authored-By: Claude Fable 5 --- src/v1/stage0/src/cli_run.rs | 75 +- src/v1/stage0/src/v1_compiler_compile.rs | 13 +- src/v1/stage0/src/v1_compiler_complexity.rs | 143 +- src/v1/stage0/src/v1_compiler_emit.rs | 71 +- .../src/v1_compiler_emit_core_support.rs | 15 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 34 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 36 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 674 ++- src/v1/stage0/src/v1_compiler_infer.rs | 3910 ++++++++--------- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 9 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 7 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 244 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 43 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 32 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 61 +- .../stage0/src/v1_compiler_infer_patterns.rs | 238 +- .../stage0/src/v1_compiler_infer_resolve.rs | 438 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 3 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 32 +- src/v1/stage0/src/v1_compiler_normalize.rs | 5 +- src/v1/stage0/src/v1_compiler_ownership.rs | 360 +- src/v1/stage0/src/v1_compiler_parse.rs | 216 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 40 + 25 files changed, 2978 insertions(+), 3727 deletions(-) diff --git a/src/v1/stage0/src/cli_run.rs b/src/v1/stage0/src/cli_run.rs index d7705f45931..1a0ef765766 100644 --- a/src/v1/stage0/src/cli_run.rs +++ b/src/v1/stage0/src/cli_run.rs @@ -9668,9 +9668,48 @@ fn test_migration_debt_stem_covered(v1_stem: &str, floor_stems: &[String]) -> bo floor_stems.iter().any(|floor_stem| floor_stem == v1_stem) } +// Second stem source (typed retirement path): a `_retired.dag` declaration under the +// corpus records a reviewed, typed retirement (delete-redundant / delete-low-value) for a v1 +// test module whose behavior does NOT migrate to an exact-stem floor `*_test.dag` witness. A +// retired stem covers the module identically to a floor-witness stem — it excludes the module +// from the debt roster and authorizes its delete through the delete-guard. The typed disposition +// and its justification live in the `.dag` decl (`test.retirement.model`, single authority, +// type-checked by the compile-clean gate); this guard reads only the filename stem, exactly as +// it reads floor witnesses. A file counts only if it actually *constructs* a `TestModuleRetirement` +// (the `TestModuleRetirement {` constructor form) — an empty stub, or one that merely imports the +// type without declaring a retirement (`{ TestModuleRetirement }`), cannot silence the guard. The +// compile-clean gate independently type-checks the constructed value against `test.retirement.model`. +fn test_migration_retired_stems() -> Vec { + let mut stems: Vec = corpus_dag_files() + .into_iter() + .filter(|(_, content)| content.contains("TestModuleRetirement {")) + .filter_map(|(path, _)| { + let file_name = std::path::Path::new(&path) + .file_name() + .and_then(|n| n.to_str())?; + file_name + .strip_suffix("_retired.dag") + .map(|s| s.to_string()) + }) + .collect(); + stems.sort(); + stems.dedup(); + stems +} + +// The covered set consumed by both the debt roster and the delete-guard: floor-witness stems +// (migrate path) unioned with retired stems (delete path). One union, two consumers. +fn test_migration_covered_stems() -> Vec { + let mut stems = test_migration_debt_floor_stems(); + stems.extend(test_migration_retired_stems()); + stems.sort(); + stems.dedup(); + stems +} + fn build_test_migration_debt_report() -> TestMigrationDebtReport { let dir = test_migration_debt_v1_test_dir(); - let floor_stems = test_migration_debt_floor_stems(); + let floor_stems = test_migration_covered_stems(); let mut entries = Vec::new(); let read_dir = match std::fs::read_dir(&dir) { Ok(rd) => rd, @@ -9847,7 +9886,7 @@ fn test_migration_delete_guard_uncovered_deletes_inner() -> Result, if base_rev == head_rev { return Ok(Vec::new()); } - let floor_stems = test_migration_debt_floor_stems(); + let floor_stems = test_migration_covered_stems(); let deleted = test_migration_delete_guard_deleted_v1_test_paths(&base, &head)?; let mut violations = Vec::new(); for path in deleted { @@ -9916,6 +9955,38 @@ mod test_migration_debt_tests { let stem = test_migration_debt_stem("cron_tag_test.rs"); assert!(!test_migration_debt_stem_covered(&stem, &floor_stems)); } + + // Green-by-execution for the typed retirement path: the demonstrator + // `dag/test/retirement/map_lookup_dual_dispatch_retired.dag` declares a `TestModuleRetirement` + // whose stem is `map_lookup_dual_dispatch`. That stem is NOT a floor-witness stem (its covering + // witness is `map_lookup_dual_dispatch_witness_test.dag`, stem `map_lookup_dual_dispatch_witness`), + // so the retirement is the *only* thing that covers it — the union must pick it up. + #[test] + fn retired_stem_is_covered_but_not_a_floor_stem() { + let stem = "map_lookup_dual_dispatch"; + assert!( + test_migration_retired_stems().iter().any(|s| s == stem), + "retirement declaration must contribute its stem" + ); + // Discriminating control: the same stem is NOT a floor-witness stem — so the coverage + // comes strictly from the retirement path, not an accidental floor match. + assert!( + !test_migration_debt_floor_stems().iter().any(|s| s == stem), + "stem must be covered only via retirement, not a floor witness" + ); + assert!(test_migration_covered_stems().iter().any(|s| s == stem)); + } + + // The retired module no longer appears in the debt roster (the retirement excluded it). + #[test] + fn retired_module_is_not_debt() { + assert!( + !test_migration_debt_module_names() + .iter() + .any(|m| m == "map_lookup_dual_dispatch_test.rs"), + "a retired module must drop out of the debt roster" + ); + } } // Host-fed fact extraction for `v2.lens.host_language_transport_script` — the lens `.dag` table diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 8f308b2e03b..1c1e8ecd469 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -167,7 +167,7 @@ pub fn extract_func_entries(typed: Rc) -> Rc>> { __result.push(Rc::new(FuncEntry { name: authored_name_at( - (*m.type_env).clone().source_indices.clone(), + m.type_env.clone().source_indices.clone(), item.clone(), ), body: item.body.clone().clone().unwrap(), @@ -232,12 +232,12 @@ pub fn extract_ownership_proofs(typed: Rc) -> Rc) -> Rc>(), |acc: Rc>>, m: Rc| { - v1_rt::rc_map_merge(acc, (*m.type_env).clone().source_indices.clone()) + v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) } diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index c4c048ea455..368276eb3bc 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -2207,11 +2207,7 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names( - entry.body.clone(), - entry.params.clone(), - si.clone(), - ), + recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), ), None => acc.clone(), }, @@ -7669,9 +7665,9 @@ pub fn cost_of_method_by_shape( base: 2, argument: size.clone(), }); - let per_comparison = (*key_result.summary.clone().work).clone(); + let per_comparison = key_result.summary.clone().work.clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), + left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, }); let sort_os = seed_cost_map( @@ -8628,13 +8624,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8645,13 +8641,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*args_result.summary.clone().work).clone(), - (*callee_result.summary.clone().work).clone(), + work: cost_seq( + args_result.summary.clone().work.clone(), + callee_result.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*args_result.summary.clone().span).clone(), - (*callee_result.summary.clone().span).clone(), + span: cost_seq( + args_result.summary.clone().span.clone(), + callee_result.summary.clone().span.clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), @@ -8745,13 +8741,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8814,7 +8810,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*acc.result).clone().table.clone(), + acc.result.clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8822,13 +8818,13 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))))))))))))))))))( - (*(*acc.result).clone().summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_par( + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par))))))))))))))))))))))))))))))( - (*(*acc.result).clone().summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_par( + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), @@ -8850,24 +8846,18 @@ pub fn cost_of_expr( ), span: cost_conditional( s_r.summary.clone().span.clone(), - Rc::new(vec![ - (*arms_accum.result).clone().summary.clone().span.clone() - ]), + Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), ), - output_size: (*arms_accum.result) + output_size: arms_accum + .result .clone() .summary .clone() .output_size .clone(), - certainty: (*arms_accum.result) - .clone() - .summary - .clone() - .certainty - .clone(), + certainty: arms_accum.result.clone().summary.clone().certainty.clone(), }), - table: (*arms_accum.result).clone().table.clone(), + table: arms_accum.result.clone().table.clone(), }) } ExprData::ExprIf => { @@ -8963,13 +8953,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*v_r.summary.clone().work).clone(), - (*b_r.summary.clone().work).clone(), + work: cost_seq( + v_r.summary.clone().work.clone(), + b_r.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*v_r.summary.clone().span).clone(), - (*b_r.summary.clone().span).clone(), + span: cost_seq( + v_r.summary.clone().span.clone(), + b_r.summary.clone().span.clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), @@ -9002,13 +8992,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().work).clone(), - (*sr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + sr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().span).clone(), - (*sr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + sr.summary.clone().span.clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), @@ -9040,8 +9030,7 @@ pub fn cost_of_expr( ); let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = - cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), @@ -9074,13 +9063,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9111,13 +9100,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq))))))))))))))))))))))))))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9235,11 +9224,8 @@ pub fn get_or_compute_summary( output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = cache_summary( - result.table.clone(), - func_name.clone(), - simplified.clone(), - ); + let final_table = + cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); Rc::new(SummaryResult { summary: simplified.clone(), table: final_table, @@ -9734,8 +9720,7 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) - > 0) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( @@ -9860,7 +9845,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - (*sr.table).clone(), + sr.table.clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), @@ -9880,9 +9865,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) + evict_summary(evicted_table.clone(), func_name.clone()) } else { - Rc::new(evicted_table.clone()) + evicted_table.clone() }; Rc::new(TopoBuildAcc { table: final_table.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 0f289bbabe9..e7c5382b4eb 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -599,7 +599,7 @@ pub fn module_emit_scope(typed_module: Rc) -> Rc { locals: v1_rt::rc_empty_map::>(), match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ), service_registry: v1_rt::rc_empty_map::>>>(), @@ -620,7 +620,7 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() != None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) @@ -710,7 +707,7 @@ pub fn order_typed_call_args( acc, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), true, ) @@ -724,7 +721,7 @@ pub fn order_typed_call_args( &arg_map, param_node_name_at( param.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ) { Some(arg) => Rc::new(vec![arg.clone()]), @@ -742,7 +739,7 @@ pub fn order_typed_call_args( if { let n = arg_name_at( arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (n.clone() == None) { true @@ -2544,15 +2541,12 @@ pub fn emit_shared_tco_expr( mut emit_default_return: impl Fn(Rc) -> String + Clone, ) -> String { loop { - let si = (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + let si = frame.scope.clone().type_env.clone().source_indices.clone(); + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { - args: (*frame.expr).clone().children.clone(), + args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), depth: frame.depth.clone(), })); @@ -2627,11 +2621,7 @@ pub fn shared_tco_default_return( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { { - let val_str = recurse_expr( - frame.expr.clone(), - frame.scope.clone(), - frame.depth.clone(), - ); + let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); v1_rt::concat( v1_rt::concat(spec.tco.clone().break_return.clone(), " ".to_string()), val_str, @@ -2645,18 +2635,15 @@ pub fn shared_tco_non_self_call( spec: Rc, recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = recurse_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), frame.scope.clone(), frame.depth.clone(), ); @@ -2683,7 +2670,7 @@ pub fn shared_tco_if( ) -> String { { let syntax = spec.block_syntax.clone(); - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); let t = if_then_branch(frame.expr.clone()); @@ -2808,14 +2795,11 @@ pub fn shared_tco_let( recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let v = let_value(frame.expr.clone()); let bd = let_body(frame.expr.clone()); @@ -2848,9 +2832,9 @@ pub fn shared_tco_block( emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { spec.tco.clone().break_return.clone() } else { @@ -2952,10 +2936,7 @@ pub fn emit_unified_tco_expr( params.clone(), target.clone(), |child| recurse_expr(child.clone(), input.scope.clone(), input.depth.clone()), - (*input.scope.clone().type_env) - .clone() - .source_indices - .clone(), + input.scope.clone().type_env.clone().source_indices.clone(), ) }, |frame| { @@ -3130,7 +3111,7 @@ pub fn emit_tco_match_go( render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); let body_depth = (case_depth.clone() + 1); @@ -3230,7 +3211,7 @@ pub fn emit_unified_tco_match( render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); let arm_list = match_arm_nodes(frame.expr.clone()); @@ -3461,7 +3442,7 @@ pub fn emit_unified_typed_func_body( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let prefix = if bs.significant_whitespace.clone() { "".to_string() } else { @@ -5264,7 +5245,7 @@ pub fn emit_typed_method_call_unified( ) -> String { { let spec = language_spec(target.clone()); - let source_indices = (*scope.type_env).clone().source_indices.clone(); + let source_indices = scope.type_env.clone().source_indices.clone(); if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -5752,7 +5733,7 @@ pub fn emit_unified_typed_expr( render_pattern: impl Fn(Rc) -> String + Clone, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let spec = language_spec(target.clone()); emit_shared_expr( texpr, @@ -5772,7 +5753,7 @@ pub fn emit_unified_typed_expr( }, |expr| emit_expr_var_shared(expr.clone(), target.clone(), si.clone()), |expr| { - let fa_si = (*scope.type_env).clone().source_indices.clone(); + let fa_si = scope.type_env.clone().source_indices.clone(); if is_typed_service_call_receiver(expr.clone(), fa_si.clone()) { match extract_typed_service_name(expr.clone(), fa_si.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index eee7c7acd88..e384a9d4951 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -585,7 +585,7 @@ pub fn extract_test_projections(typed: Rc) -> Rc) -> Rc) -> Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_go_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -137,7 +137,7 @@ pub fn emit_go(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -462,10 +462,10 @@ pub fn emit_go_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*typed_module.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); + let si = typed_module.type_env.clone().source_indices.clone(); + let mod_name_str = authored_name_at(si.clone(), m.clone()); let pkg_name = go_package_name(mod_name_str.clone()); let pkg_decl = v1_rt::concat( v1_rt::concat( @@ -480,7 +480,7 @@ pub fn emit_go_module( ); let imports_str = emit_go_imports( typed_module.items.clone(), - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), si.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -695,10 +695,10 @@ pub fn emit_go_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let env = scope.type_env.clone(); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_go_type_def_from_connective(item.clone(), Rc::new(env.clone())) + emit_go_type_def_from_connective(item.clone(), env.clone()) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { emit_go_type_alias( @@ -743,10 +743,10 @@ pub fn emit_go_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_go_service_def(item.clone(), registry, Rc::new(env.clone())) + emit_go_service_def(item.clone(), registry, env.clone()) } else { if is_resource_def_item(item.clone()) { - emit_go_resource_def(item.clone(), Rc::new(env.clone())) + emit_go_resource_def(item.clone(), env.clone()) } else { v1_rt::concat( v1_rt::concat( @@ -1141,7 +1141,7 @@ pub fn emit_go_fn_def( scope: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Go, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -1255,15 +1255,15 @@ pub fn emit_go_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_type = emit_node_type( inferred, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1388,7 +1388,7 @@ pub fn emit_go_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1800,7 +1800,7 @@ pub fn emit_go_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Go, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let val_str = emit_go_typed_expr(value, registry, scope.clone(), depth, 1024); v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 27fd76562e4..ddb3cc3f4a9 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -117,7 +117,7 @@ pub fn emit_python(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_py_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -125,7 +125,7 @@ pub fn emit_python(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -187,7 +187,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { for tm in modules.iter().cloned() { __result.push({ let mod_name = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); let items = language_spec(RenderTarget::Python).items.clone(); @@ -364,12 +364,12 @@ pub fn emit_py_module( registry: Rc>>, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); - let mod_name_str = authored_name_at(si.clone(), Rc::new(m.clone())); + let si = scope.type_env.clone().source_indices.clone(); + let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); - let imports_str = emit_py_imports(module_imports(Rc::new(m.clone())), si.clone()); + let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { @@ -582,10 +582,10 @@ pub fn emit_py_typed_item( scope: Rc, ) -> String { { - let env = (*scope.type_env).clone(); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let env = scope.type_env.clone(); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { - emit_py_type_def_from_connective(item.clone(), Rc::new(env.clone())) + emit_py_type_def_from_connective(item.clone(), env.clone()) } else { if is_type_alias_item(item.clone(), env.source_indices.clone()) { v1_rt::concat( @@ -632,10 +632,10 @@ pub fn emit_py_typed_item( ) } else { if is_service_def_item(item.clone()) { - emit_py_service_def(item.clone(), registry, Rc::new(env.clone())) + emit_py_service_def(item.clone(), registry, env.clone()) } else { if is_resource_def_item(item.clone()) { - emit_py_resource_def(item.clone(), Rc::new(env.clone())) + emit_py_resource_def(item.clone(), env.clone()) } else { v1_rt::concat("# unhandled node: ".to_string(), item_text) } @@ -876,7 +876,7 @@ pub fn emit_py_fn_def( ) -> String { { let depth = 0; - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Python, si.clone()); let ret_str = emit_inferred_shared(inferred, RenderTarget::Python, si.clone()); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -990,15 +990,15 @@ pub fn emit_py_func_def( params.clone(), uses.clone(), service_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let ret_str = emit_inferred_shared( inferred, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -1123,7 +1123,7 @@ pub fn emit_py_typed_expr( emit_unified_pattern( pat.clone(), RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, ) @@ -1536,7 +1536,7 @@ pub fn emit_py_data_def( let ty_str = emit_node_type( type_node, RenderTarget::Python, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let upper_name = to_screaming_snake(name); let val_str = emit_py_typed_expr(value, registry, scope.clone(), 0, 1024); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 44c791c0fb1..b45fa7ffa52 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, - build_read_only_params, collect_callable_refs, move_site_key, + analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, + collect_callable_refs, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -1401,6 +1401,11 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { + if let Some(host) = + rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) + { + return host; + } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2603,7 +2608,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); Rc::new({ @@ -2620,10 +2625,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - item.clone(), - ); + let item_name = + authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2659,7 +2662,7 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ); let local = Rc::new({ @@ -2679,7 +2682,7 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), item.clone(), ), item.clone(), @@ -2693,7 +2696,7 @@ pub fn build_scoped_data_item_index( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2701,7 +2704,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), ) .iter() .cloned() @@ -3248,14 +3251,12 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, - pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, - pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3279,7 +3280,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), - move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3371,7 +3367,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: ownership.move_sites_index.clone(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3448,7 +3437,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); svc_items.clone().iter().cloned().fold( @@ -3457,7 +3446,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3493,7 +3482,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -3501,7 +3490,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -3528,10 +3517,8 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3682,8 +3669,6 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: base_info.move_sites_index.clone(), - move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3712,12 +3697,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); let exported = get_exported_names( tm.module.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3742,26 +3727,26 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name(scope.type_env.clone(), Rc::new(m.clone())), + authored_name(scope.type_env.clone(), m.clone()), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(Rc::new(m.clone())).iter().cloned() { + for imp in module_imports(m.clone()).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) .iter() .cloned(), @@ -3778,11 +3763,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __result.push(item); @@ -3798,13 +3783,13 @@ pub fn emit_module_full( __result }); let imports_str = emit_imports( - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), emit_info.clone(), registry.clone(), local_type_names, export_sets.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3813,7 +3798,7 @@ pub fn emit_module_full( v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(authored_name(scope.type_env.clone(), Rc::new(m.clone()))); + module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3921,14 +3906,14 @@ pub fn emit_module_full( } __result }); - let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = authored_name(scope.type_env.clone(), Rc::new(m.clone())); + let module_import_items = module_imports(m.clone()); + let this_module_name = authored_name(scope.type_env.clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3937,7 +3922,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3945,7 +3930,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3968,10 +3953,8 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - i.clone(), - ) == "wire_contract".to_string())) + && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) + == "wire_contract".to_string())) { __result.push(i); } @@ -3985,7 +3968,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name(scope.type_env.clone(), Rc::new(m.clone())), + authored_name(scope.type_env.clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4009,20 +3992,20 @@ pub fn emit_module_full( } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), Rc::new(m.clone()))); + let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), Rc::new(m.clone())) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), Rc::new(m.clone()))), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4140,7 +4123,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { @@ -4153,7 +4136,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { @@ -4228,10 +4211,7 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at( - source_indices.clone(), - tm.module.clone(), - )); + __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); } __result }) @@ -4606,8 +4586,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in - module_imports(tm.module.clone()).iter().cloned() + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -7229,18 +7208,18 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - Rc::new(env.clone()), + env.clone(), emit_info.clone(), wire_contract_item, data_items, @@ -7500,12 +7479,12 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco.clone() { + let fn_read_only = if item_is_tco { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7516,17 +7495,6 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco.clone() { - v1_rt::rc_empty_map::() - } else { - match v1_rt::map_get( - &emit_info.move_sites_index.clone(), - qualified_name.clone(), - ) { - Some(m) => m.clone(), - None => v1_rt::rc_empty_map::(), - } - }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7539,15 +7507,13 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), }); let is_effectful = match lookup_item( registry.clone(), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7599,7 +7565,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env.clone(), ) } else { if is_resource_def_item(item.clone()) { @@ -7607,7 +7573,7 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env.clone()), + env.clone(), ) } else { v1_rt::concat( @@ -7627,15 +7593,6 @@ pub fn emit_typed_item( } } -pub fn needs_box_wrapping_shared_dominates() -> String { - thread_local! { - static CACHED: String = { - "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7643,32 +7600,35 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { + // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box + // — shared_types dominates the recursive check. Replaced by regen's + // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } else { - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } else { - if ((n.children.clone().len() as i64) == 0) { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } + } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; + } + if ((n.children.clone().len() as i64) == 0) { + { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } - } else { - break false; - } + break v1_rt::set_contains(&recursive_types, name.clone()); } } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } } } } @@ -9601,7 +9561,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9939,7 +9899,7 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), @@ -9948,10 +9908,10 @@ pub fn emit_func_def( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -10021,7 +9981,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -12262,28 +12222,10 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } -pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { - if (use_span.clone() == 0) { - false - } else { - match v1_rt::map_get( - &emit_info.move_sites.clone(), - move_site_key(name.clone(), use_span.clone()), - ) { - Some(v) => { - (v.clone() - && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) - } - None => false, - } - } -} - pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, - use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12296,16 +12238,7 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let site_move_kind_allowed = match binding_kind.clone().as_deref().cloned() { - Some(VarBindingKind::MatchBoundBinding) => false, - Some(VarBindingKind::FunctionValueBinding) => false, - Some(VarBindingKind::VariantValueBinding { parent_enum: _, .. }) => false, - _ => true, - }; - let moves_by_value = - (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) - || (site_move_kind_allowed - && move_licensed_at_site(emit_info.clone(), name.clone(), use_span))); + let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12414,7 +12347,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12521,12 +12454,12 @@ pub fn field_access_field_is_boxed( match find_child_named( base_struct, field, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12536,23 +12469,18 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - { - let faithful_nat_field = ((emit_info.corpus_repr.clone() - == RustCorpusRepr::FaithfulFreeMonoid) - && ((field_ty_name.clone() == "Nat".to_string()) - || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); - ((faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - (*scope.type_env).clone().source_indices.clone(), - )) - || is_recursive_type_by_name( - scope.type_env.clone(), - field_ty_name.clone(), - )) - } + let faithful_nat_field = + matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) + && (field_ty_name.clone() == "Nat".to_string() + || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); + faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) } } None => false, @@ -12620,7 +12548,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12683,7 +12611,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -13057,7 +12985,6 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), - expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13080,7 +13007,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13089,11 +13016,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13138,10 +13065,7 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_call_expr( f, expr.children.clone(), @@ -13175,10 +13099,8 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = expr_method_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let m = + expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_method_call( expr.clone(), r, @@ -13253,10 +13175,8 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13292,10 +13212,10 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, @@ -13459,7 +13379,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13478,10 +13398,8 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = foreach_variable_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let v = + foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13589,7 +13507,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13608,7 +13526,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, |expr| { @@ -13841,10 +13759,8 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let ty_name = + resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { @@ -13863,7 +13779,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13972,7 +13888,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13997,7 +13913,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14130,7 +14046,7 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14145,7 +14061,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14274,7 +14190,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14421,7 +14337,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14489,10 +14405,8 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at( - a.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) + { Some(n) => n.clone(), None => "".to_string(), }, @@ -14510,7 +14424,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __found = true; @@ -14536,7 +14450,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14561,7 +14475,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14679,7 +14593,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14736,11 +14650,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14801,7 +14715,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14994,7 +14908,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15012,7 +14926,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -15056,7 +14970,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15103,7 +15017,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15125,19 +15039,6 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); - let site = v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - lambda_expr.span.clone().file.clone(), - ":".to_string(), - ), - (lambda_expr.span.clone().start.clone()).to_string(), - ), - ":".to_string(), - ), - acc_name.clone(), - ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15145,22 +15046,16 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), - ), - acc_ident.clone(), - ), - " = v1_rt::take_owned_counted(".to_string(), + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), ), acc_ident.clone(), ), - ", \"".to_string(), + " = Rc::try_unwrap(".to_string(), ), - site, + acc_ident.clone(), ), - "\"); ".to_string(), + ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), ), body_str, ), @@ -15212,7 +15107,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15253,33 +15148,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15307,7 +15202,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15317,7 +15212,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) .first() .cloned() @@ -15329,7 +15224,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15343,7 +15238,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15361,8 +15256,6 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15378,7 +15271,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15396,8 +15289,6 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15415,7 +15306,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15473,7 +15364,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15485,7 +15376,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15511,7 +15402,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15560,7 +15451,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }; @@ -15632,7 +15523,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15644,7 +15535,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { "_".to_string() @@ -15719,7 +15610,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15784,7 +15675,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15882,7 +15773,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -16006,7 +15897,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -16063,7 +15954,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -16081,7 +15972,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16154,7 +16045,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16358,7 +16249,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16487,13 +16378,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -17059,7 +16950,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17129,11 +17020,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17165,7 +17056,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17307,7 +17198,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17406,7 +17297,6 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), - arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17505,7 +17395,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17589,7 +17479,7 @@ pub fn rust_struct_field_type_node( Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17616,10 +17506,8 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - receiver_type, - ); + let receiver_type_name = + authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17636,7 +17524,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, } @@ -17683,7 +17571,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17711,7 +17599,7 @@ pub fn is_already_optional( } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - ((*binding.resolved).clone().return_cardinality.clone() + (binding.resolved.clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17754,7 +17642,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_base, ), f, @@ -17888,7 +17776,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17896,7 +17784,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17905,7 +17793,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18125,13 +18013,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18152,7 +18040,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18168,7 +18056,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18242,7 +18130,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18252,7 +18140,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18262,7 +18150,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ), @@ -18282,10 +18170,7 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18366,20 +18251,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = (*resolve_node( + let resolved_struct = resolve_node( resolved_type.clone(), scope.type_env.clone(), scope.module_name.clone(), ) - .resolved) - .clone(); + .resolved + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18636,10 +18521,7 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18706,7 +18588,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18925,7 +18807,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -19009,10 +18891,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -19328,10 +19210,8 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19347,7 +19227,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19417,18 +19297,15 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = emit_typed_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19455,7 +19332,7 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); let t = if_then_branch(frame.expr.clone()); @@ -19676,7 +19553,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19734,7 +19611,7 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); let arm_list = match_arm_nodes(frame.expr.clone()); @@ -19752,18 +19629,12 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), rt.clone(), ) } @@ -19800,10 +19671,7 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19907,14 +19775,11 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let v = let_value(frame.expr.clone()); let bd = let_body(frame.expr.clone()); @@ -19932,10 +19797,7 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -20005,9 +19867,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -20181,7 +20043,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20332,7 +20194,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -23012,8 +22874,7 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) - && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -23045,12 +22906,12 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -23059,7 +22920,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -23068,11 +22929,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -23103,7 +22964,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ); @@ -23114,16 +22975,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23227,10 +23088,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23239,19 +23100,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23259,14 +23120,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23298,7 +23159,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23314,7 +23175,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23339,7 +23200,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -23347,7 +23208,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23367,13 +23228,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23390,14 +23251,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23420,7 +23281,8 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -23484,14 +23346,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -24019,7 +23881,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ) { __result.push(item); } @@ -24032,12 +23894,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), registry.clone(), tm.items.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -24110,7 +23972,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )), None => "".to_string(), @@ -24147,10 +24009,8 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 7e17adad060..0525069bf0f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -45,18 +45,20 @@ pub use crate::v1_compiler_infer_emit_info::{ EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ - build_type_env_calls, empty_type_env_cache, inductive_fields_for, inductive_fields_list_to_map, - is_recursive_type, is_recursive_type_by_name, lookup_type, lookup_type_by_name, - lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, - merge_type_env_cache_calls, put_inductive_field, put_inductive_field_cross, - rewire_type_env_import_str_binding_calls, rewire_type_env_parent_links_calls, + empty_type_env_cache, flatten_visible_bindings, inductive_fields_for, + inductive_fields_list_to_map, is_recursive_type, is_recursive_type_by_name, lookup_type, + lookup_type_by_name, lookup_type_for, merge_envs, merge_inductive_fields, merge_type_env_cache, + put_inductive_field, put_inductive_field_cross, record_build_type_env_call, + record_rewire_type_env_import_str_binding_call, record_rewire_type_env_parent_links_call, str_bindings_from_bindings, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; use crate::v1_compiler_infer_items::ItemKind::{ DataItem, FnItem, FuncItem, OtherItem, ServiceItem, TypeItem, }; -pub use crate::v1_compiler_infer_items::{inferred_to_outputs, item_kind}; +pub use crate::v1_compiler_infer_items::{ + inferred_to_outputs, item_kind, variant_locals_from_items, +}; pub use crate::v1_compiler_infer_items::{ ItemInfo, ItemKind, ResolvedGraph, TypedGraph, TypedModule, }; @@ -107,11 +109,13 @@ pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; +// HAND-PATCH (§1c re-export chains): accessor for the chain followers below. +use crate::v1_std_core::import_specific_names_at; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; use crate::v1_std_core::CompilerDiagnostic::{ - FieldNotFound, InternalError, SoleConstructorViolation, TypeMismatch, UnresolvedType, - VariantCollision, + InternalError, SoleConstructorViolation, TypeMismatch, VariantCollision, }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ @@ -142,19 +146,18 @@ pub use crate::v1_std_core::{ field_access_field_at, field_binding_name_at, field_binding_pattern, field_init_node_name_at, field_init_node_value, field_node_name_at, field_node_type_expr, find_child_named, float_type, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, has_child_named, - has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, - import_specific_names_at, index_base, index_expr, int_type, intern, intern_str, - is_child_accessor_in_model, is_compiler_error, is_container_type, is_error_diagnostic, - is_kernel_type, is_property_contraction, is_tree_size_reducing, kernel_type_set, lambda_body, - lambda_param_names_at, let_binding_name_at, let_body, let_value, local_transport_node, - make_arg_node, make_arm_node, make_error_node, make_expr_error_node, make_expr_node, - make_field_binding_node, make_field_init_node, make_interp_part_node, make_named_expr_node, - make_param_node, make_span, make_text_part_node, make_transport_node, map_children, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, - module_items, module_node, no_span, node_name_span, none_type, param_node_name_at, - param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, - return_value, slice_base, slice_end, slice_start, string_type, unaryop_operand, unit_type, - with_optional_cardinality, with_required_cardinality, + has_inferred, if_condition, if_else_branch, if_then_branch, import_is_all, index_base, + index_expr, int_type, intern, intern_str, is_child_accessor_in_model, is_compiler_error, + is_container_type, is_error_diagnostic, is_kernel_type, is_property_contraction, + is_tree_size_reducing, kernel_type_set, lambda_body, lambda_param_names_at, + let_binding_name_at, let_body, let_value, local_transport_node, make_arg_node, make_arm_node, + make_error_node, make_expr_error_node, make_expr_node, make_field_binding_node, + make_field_init_node, make_interp_part_node, make_named_expr_node, make_param_node, make_span, + make_text_part_node, make_transport_node, map_children, match_arm_nodes, match_scrutinee, + method_arg_nodes, method_receiver, module_imports, module_items, module_node, no_span, + node_name_span, none_type, param_node_name_at, param_node_type_expr, record_lit_type_name_at, + resource_use_name_at, resource_use_resource, return_value, slice_base, slice_end, slice_start, + string_type, unaryop_operand, unit_type, with_optional_cardinality, with_required_cardinality, }; pub use crate::v1_std_core::{ CallSemantics, Cardinality, CompilerDiagnostic, Connective, DeclaredFuncEnv, DeclaredFuncSig, @@ -248,9 +251,9 @@ pub fn infer_block_stmts( let is_last = (remaining_count.clone() == 1); let stmt_expected = if is_last { expected.clone() } else { None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected); - let stmt_typed = (*stmt_result.typed).clone(); + let stmt_typed = stmt_result.typed.clone(); let stmt_diags = stmt_result.diagnostics.clone(); - let stmt_rt = resolved_type(Rc::new(stmt_typed.clone())); + let stmt_rt = resolved_type(stmt_typed.clone()); let next_scope = scope_after_stmt_node(stmt.clone(), stmt_rt.clone(), scope.clone()); { @@ -263,7 +266,7 @@ pub fn infer_block_stmts( ); let __tco_1 = (remaining_count - 1); let __tco_2 = next_scope; - let __tco_3 = v1_rt::rc_list_push(typed_stmts, Rc::new(stmt_typed.clone())); + let __tco_3 = v1_rt::rc_list_push(typed_stmts, stmt_typed.clone()); let __tco_4 = v1_rt::rc_list_push(diag_chunks, stmt_diags); let __tco_5 = stmt_rt.clone(); remaining = __tco_0; @@ -770,66 +773,53 @@ pub fn internal_expr_error_node(message: String, span: Rc) -> Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(parent) => { - let is_coproduct = (parent.connective.clone() == Connective::Disj); - if is_coproduct { - if has_child_named( - parent.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - binding.resolved.clone(), - )) - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(parent) => { + let is_coproduct = (parent.connective.clone() == Connective::Disj); + if is_coproduct { + if has_child_named( + parent.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + Some(authored_name_at( + scope.type_env.clone().source_indices.clone(), + binding.resolved.clone(), + )) } else { None } + } else { + None } - None => None, } - } + None => None, + }, None => None, } } -pub fn variant_owner_node_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (DESIGN resolver-graph-major §1c, 2026-07-04): a constructor literal's owner is the BINDING EDGE — scope.locals binds the arm name to its owning coproduct node at env construction (local declaration or direct import), so owner lookup is O(1) map_get + dealias. No whole-environment scan, no expected-type owner-picking, no name round-trip through lookup_type_by_name (the owner node rides the binding even when the enum's name is not itself visible). Unbound constructor literal = UnresolvedType error; two visible owners for one arm name = VariantCollision at env construction.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): O(1) owner lookup +// via the binding edge — replaced by regen's true emission of variant_owner_node +// in the convergence commit. pub fn variant_owner_node(scope: Rc, name: String) -> Option> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { - Some(binding) => { - match Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(lookup_type_for))))))))))))))))))))))))))))))((*scope.type_env).clone(), (*binding.resolved).clone()) { - Some(owner) => { - let owner_is_coproduct = (owner.connective.clone() == Connective::Disj); - if owner_is_coproduct { - if has_child_named( - owner.clone(), - name.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { - Some(owner.clone()) - } else { - None - } - } else { - None - } + Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { + Some(owner) => { + if owner.connective.clone() == Connective::Disj + && has_child_named( + owner.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + ) + { + Some(owner) + } else { + None } - None => None, } - } + None => None, + }, None => None, } } @@ -852,6 +842,45 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc, + name: String, + scope_enum: String, + expected: Option>, +) -> Option { + match expected { + Some(exp_node) => { + let exp_name = authored_name_at( + scope.type_env.clone().source_indices.clone(), + exp_node.clone(), + ); + if (((exp_name.clone() != "".to_string()) && (exp_name.clone() != scope_enum)) + && (exp_name.clone() != name.clone())) + { + match lookup_type_by_name(scope.type_env.clone(), exp_name.clone()) { + Some(exp_type) => { + if ((exp_type.connective.clone() == Connective::Disj) + && has_child_named( + exp_type.clone(), + name.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { + Some(exp_name.clone()) + } else { + None + } + } + None => None, + } + } else { + None + } + } + None => None, + } +} + pub fn inference_error( message: String, span: Rc, @@ -882,15 +911,7 @@ pub fn type_mismatch_error( ) } -pub fn optional_coproduct_field_shape_predicate_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: field_type_is_optional_coproduct + rejects_string_for_optional_coproduct_field — CardOptional+Disj Bool predicates over lookup_type_for-resolved shape; ground as inhabitable OptionalCoproduct in std_types at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - +// 🟡 dissolve-on: optional_coproduct_field_shape_predicate_dissolution_trigger (04_infer.dag) pub fn rejects_string_for_optional_coproduct_field( expected: Rc, got: Rc, @@ -898,30 +919,32 @@ pub fn rejects_string_for_optional_coproduct_field( env: Rc, ) -> bool { { + if (expected.return_cardinality.clone() != Cardinality::CardOptional) { + return false; + } let expected_resolved = - match lookup_type_for(env, with_required_cardinality(expected.clone())) { + match lookup_type_for(env.clone(), with_required_cardinality(expected.clone())) { Some(resolved) => resolved.clone(), None => with_required_cardinality(expected.clone()), }; - let expected_is_optional_coproduct = ((expected.return_cardinality.clone() - == Cardinality::CardOptional) - && (expected_resolved.connective.clone() == Connective::Disj)); - let got_is_string = ((node_type_shape(got.clone(), source_indices.clone()) - == "Primitive(String)".to_string()) - || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string())); + let expected_is_optional_coproduct = + (expected_resolved.connective.clone() == Connective::Disj); + let got_shape = node_type_shape(got.clone(), source_indices.clone()); + let got_is_string = (got_shape == "Primitive(String)".to_string()) + || (authored_name_at(source_indices.clone(), got.clone()) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } pub fn field_type_is_optional_coproduct(ft: Rc, env: Rc) -> bool { - { - let inner = match lookup_type_for(env, with_required_cardinality(ft.clone())) { - Some(resolved) => resolved.clone(), - None => with_required_cardinality(ft.clone()), - }; - ((ft.return_cardinality.clone() == Cardinality::CardOptional) - && (inner.connective.clone() == Connective::Disj)) + if (ft.return_cardinality.clone() != Cardinality::CardOptional) { + return false; } + let inner = match lookup_type_for(env.clone(), with_required_cardinality(ft.clone())) { + Some(resolved) => resolved.clone(), + None => with_required_cardinality(ft.clone()), + }; + (inner.connective.clone() == Connective::Disj) } pub fn record_lit_expected_fields( @@ -931,12 +954,15 @@ pub fn record_lit_expected_fields( match type_name { Some(tn) => match lookup_type_by_name(scope.type_env.clone(), tn.clone()) { Some(direct) => direct.children.clone(), + // HAND-PATCH (§1c): owner via the binding edge (variant_owner_node), + // no name round-trip, no whole-env scan fallback. Regen replaces + // this with the dag source's true emission. None => match variant_owner_node(scope.clone(), tn.clone()) { Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), v.clone(), ) == tn.clone()) { @@ -958,6 +984,37 @@ pub fn record_lit_expected_fields( } } +pub fn record_lit_variant_fields_from_visible_env( + env: Rc, + variant_name: String, + module_name: String, +) -> Rc>> { + let source_indices = env.source_indices.clone(); + let visible = flatten_visible_bindings(env.clone()); + for binding in Rc::new(v1_rt::map_values(&visible)).iter().cloned() { + let node = expand_type_for_field_access( + binding.resolved.clone(), + env.clone(), + module_name.clone(), + ); + if (node.connective.clone() == Connective::Disj) { + for arm in node.children.clone().iter().cloned() { + let arm_name = authored_name_at(source_indices.clone(), arm.clone()); + if (arm_name == variant_name.clone()) { + let expanded = + expand_type_for_field_access(arm.clone(), env.clone(), module_name.clone()); + if (expanded.connective.clone() == Connective::Conj) { + return expanded.children.clone(); + } else { + return arm.children.clone(); + } + } + } + } + } + Rc::new(vec![]) +} + pub fn record_lit_expanded_from_expected( type_name: Option, expected: Option>, @@ -967,7 +1024,7 @@ pub fn record_lit_expanded_from_expected( Some(tn) => match expected { Some(exp) => { if (((authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), exp.clone(), ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) @@ -978,7 +1035,7 @@ pub fn record_lit_expanded_from_expected( match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), expanded.clone(), ) == tn.clone()) { @@ -990,7 +1047,7 @@ pub fn record_lit_expanded_from_expected( _ => { let rt = resolved_type(exp.clone()); if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), rt.clone(), ) == tn.clone()) { @@ -1035,10 +1092,8 @@ pub fn record_lit_instantiated_fields( match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - exp.clone(), - ) != tn.clone()) + if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) + != tn.clone()) { None } else { @@ -1054,7 +1109,7 @@ pub fn record_lit_instantiated_fields( } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { - let slot = authored_name_at((*scope.type_env).clone().source_indices.clone(), pair.1.clone()); + let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), None => acc.clone(), @@ -1079,7 +1134,8 @@ match exp.children.clone().get(pair.0.clone() as usize).cloned() { node: substitute_generics( field_node_type_expr(sf.clone()), subst.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -1146,17 +1202,13 @@ pub fn set_kernel_ty_from_element(element: Rc) -> Rc { } pub fn set_builtin_receiver_is_set(receiver_arg: Rc, scope: Rc) -> bool { - match arg_value(receiver_arg).inferred - .clone() - .as_deref() - .cloned() - { + match arg_value(receiver_arg).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: receiver_type, .. }) => node_is_set_collection( receiver_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1171,7 +1223,7 @@ pub fn set_union_other_operand_is_resolved_non_set( node: other_type, .. }) => !node_is_set_collection( other_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => false, } @@ -1383,7 +1435,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1391,19 +1444,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: receiver_type, .. - }) => match map_value_type_in_env( - receiver_type.clone(), - scope.type_env.clone(), - ) { - Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { - witness_of_element(value_type.clone()) - } else { - with_optional_cardinality(value_type.clone()) + }) => { + match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { + Some(value_type) => { + if (func_name.clone() == "lookup".to_string()) { + witness_of_element(value_type.clone()) + } else { + with_optional_cardinality(value_type.clone()) + } } + None => resolve_builtin_call_type(func_name.clone()), } - None => resolve_builtin_call_type(func_name.clone()), - }, + } _ => resolve_builtin_call_type(func_name.clone()), }, None => resolve_builtin_call_type(func_name.clone()), @@ -1413,7 +1465,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1422,8 +1475,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( node: receiver_type, .. }) => { - match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) - { + match map_key_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); Rc::new(Tier2bBt { @@ -1450,7 +1502,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1494,7 +1547,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( || (func_name.clone() == "set_contains".to_string())) { match typed_args.clone().get(1 as usize).cloned() { - Some(insert_arg) => match arg_value(insert_arg.clone()).inferred + Some(insert_arg) => match arg_value(insert_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1508,7 +1562,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } } else { match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => match arg_value(other_arg.clone()).inferred + Some(other_arg) => match arg_value(other_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1545,7 +1600,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( false }; let recv_elem = match typed_args.clone().first().cloned() { - Some(receiver_arg) => match arg_value(receiver_arg.clone()).inferred + Some(receiver_arg) => match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1566,7 +1622,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(oe) => set_element_types_mismatch( re.clone(), oe.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }, @@ -1617,7 +1673,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( if ((recv_is_set.clone() && !elem_mismatch.clone()) && !union_other_bad.clone()) { - match arg_value(receiver_arg.clone()).inferred + match arg_value(receiver_arg.clone()) + .inferred .clone() .as_deref() .cloned() @@ -1628,11 +1685,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => match recv_elem.clone() { Some(_) => receiver_type.clone(), None => match operand_elem.clone() { - Some(element) => (*set_kernel_ty_from_element( - element.clone(), - ) - .ty) - .clone(), + Some(element) => { + set_kernel_ty_from_element(element.clone()) + .ty + .clone() + } None => { resolve_builtin_call_type(func_name.clone()) } @@ -1884,7 +1941,7 @@ pub fn annotate_pattern_parent_enums( .. } => { let scrutinee_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_scrut_node.clone(), ); let optional_cardinality_subject = @@ -1940,16 +1997,16 @@ pub fn annotate_pattern_parent_enums( variant_subject.clone(), field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); make_field_binding_node( field_binding_name_at( binding.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), annotate_pattern_parent_enums( field_binding_pattern(binding.clone()), @@ -1988,11 +2045,11 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R |acc: Rc>>, p: Rc| { v1_rt::rc_map_insert( acc, - param_node_name_at(p.clone(), (*scope.type_env).clone().source_indices.clone()), + param_node_name_at(p.clone(), scope.type_env.clone().source_indices.clone()), Rc::new(TypeBinding { name: param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resolved: param_node_type_expr(p.clone()), provenance: Rc::new(SubValueRelation::PreservedValue), @@ -2115,7 +2172,7 @@ pub fn scope_after_stmt_node( scope.clone(), let_binding_name_at( stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), stmt_type, classify_binding_provenance(val, scope.clone()), @@ -2141,7 +2198,7 @@ pub fn derive_field_provenance( _ => { let scrut_type_name = match (*scrutinee_subject).clone() { PatternSubject::PatternResolved { node: n, .. } => authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(n.clone()), ), _ => "".to_string(), @@ -2224,13 +2281,13 @@ pub fn extend_scope_with_pattern_node( |acc: Rc, fb: Rc| { let field_name = field_binding_name_at( fb.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_lookup = lookup_field_in_variant( variant_subject.clone(), field_name.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let field_subject = lookup_result_subject(field_lookup.clone()); let field_type = pattern_binding_type(field_subject.clone()); @@ -2320,7 +2377,7 @@ pub fn extract_fold_init_info( if arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(a); } @@ -2341,7 +2398,7 @@ pub fn extract_fold_init_info( typed_arg: make_arg_node( arg_name_at( ia.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), init_result.typed.clone(), ia.span.clone(), @@ -2370,7 +2427,7 @@ pub fn derive_element_provenance( SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ) == "".to_string()) { @@ -2380,7 +2437,7 @@ pub fn derive_element_provenance( let ind_fields = inductive_fields_for( scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), elem_type.clone(), ), ); @@ -2441,10 +2498,10 @@ pub fn infer_method_args_with_fold( let is_init_arg = (arg_has_name( a.clone(), "init".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || ((arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == None) && (idx.clone() == 0))); if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { @@ -2525,7 +2582,7 @@ pub fn infer_method_args_with_fold( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ar.typed.clone(), a.span.clone(), @@ -2616,10 +2673,7 @@ pub fn infer_arg_with_element_type( let ar = infer_expr(arg_value(arg.clone()), scope.clone(), Some(element_type)); Rc::new(ArgInferResult { typed_arg: make_arg_node( - arg_name_at( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), + arg_name_at(arg.clone(), scope.type_env.clone().source_indices.clone()), ar.typed.clone(), arg.span.clone(), arg.span.clone(), @@ -2657,15 +2711,16 @@ pub fn infer_expr( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let name = + expr_var_name_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => { let scope_parent = lookup_variant_parent_enum(scope.clone(), name.clone()); match scope_parent { + // HAND-PATCH (§1c): the expected-type-as-owner-picker + // is deleted; the binding edge alone names the owner. + // Regen replaces this with the dag source's true emission. Some(scope_enum) => ok_infer(make_named_expr_node( name.clone(), Rc::new(ExprData::ExprVar { @@ -2766,14 +2821,14 @@ pub fn infer_expr( ExprData::ExprFieldAccess { summary: _, .. } => { let field_name = field_access_field_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let base_expr = field_access_base(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); - let base_rt = resolved_type(Rc::new(base_typed.clone())); + let base_rt = resolved_type(base_typed.clone()); let resolved_base = if is_deferred_field_access_base(base_rt.clone(), scope.type_env.clone()) { base_rt.clone() @@ -2784,16 +2839,26 @@ pub fn infer_expr( scope.module_name.clone(), ) }; - let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { + let resolved_base_is_error = if resolved_base.inferred.clone() != None { is_compiler_error(resolved_base.inferred.clone().clone().unwrap()) } else { false }; if resolved_base_is_error { + // HAND-PATCH (debug instrumentation, removed with regen): + // name the error-typed base so the fail-open seam is located. Rc::new(InferResult { typed: make_expr_error_node( ExprErrorKind::SemanticExprError, - "error type cascade".to_string(), + format!( + "error type cascade (field '{}' on error-typed base '{}' in {})", + field_name, + authored_name_at( + scope.type_env.clone().source_indices.clone(), + base_typed.clone() + ), + scope.module_name + ), span.clone(), ), diagnostics: base_diags, @@ -2803,7 +2868,7 @@ pub fn infer_expr( let field_type_lookup = lookup_field_type_node( resolved_base.clone(), field_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match field_type_lookup { Some(field_type) => { @@ -2824,7 +2889,7 @@ pub fn infer_expr( Rc::new(ExprData::ExprFieldAccess { summary: field_summary, }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: field_type.clone(), })), @@ -2851,7 +2916,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::TypeVariable { id: "field_of_type_var".to_string(), })), @@ -2868,7 +2933,7 @@ pub fn infer_expr( base_rt.clone(), field_name.clone(), scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_type) => { let fa_texpr = make_named_expr_node( @@ -2879,7 +2944,7 @@ pub fn infer_expr( value_shape: FieldValueShape::PlainValue, })), }), - Rc::new(vec![Rc::new(base_typed.clone())]), + Rc::new(vec![base_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: svc_type.clone(), })), @@ -2902,7 +2967,8 @@ pub fn infer_expr( "' on type '".to_string(), ), authored_name_at( - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -2936,10 +3002,8 @@ pub fn infer_expr( } } ExprData::ExprCall { .. } => { - let func_name = expr_call_func_at( - texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let func_name = + expr_call_func_at(texpr.clone(), scope.type_env.clone().source_indices.clone()); let span = texpr.span.clone(); let call_args = texpr.children.clone(); let sig = lookup_func_sig(scope.func_env.clone(), func_name.clone()); @@ -2989,7 +3053,7 @@ pub fn infer_expr( let first_type = resolved_type(first_result.typed.clone()); let elem_type = for_each_element_type_node( first_type, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let call_elem_provenance = derive_element_provenance( first_result.typed.clone(), @@ -3010,7 +3074,7 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( first_arg.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), first_result.typed.clone(), first_arg.span.clone(), @@ -3031,7 +3095,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3045,7 +3109,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3057,7 +3121,7 @@ pub fn infer_expr( { __result.push(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -3093,7 +3157,7 @@ pub fn infer_expr( let formal_param_type = substitute_generics( formal_raw.clone(), st.subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected = if has_formal.clone() { Some(formal_param_type.clone()) @@ -3114,7 +3178,7 @@ pub fn infer_expr( formal_raw.clone(), arg_value(a.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { unify_record_lit_generics( formal_raw.clone(), @@ -3128,7 +3192,7 @@ pub fn infer_expr( formal_raw.clone(), resolved_type(ar.typed.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.subst.clone(), ) } @@ -3140,10 +3204,7 @@ pub fn infer_expr( typed_arg: make_arg_node( arg_name_at( a.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ), ar.typed.clone(), a.span.clone(), @@ -3164,7 +3225,7 @@ pub fn infer_expr( let typed_args = Rc::new({ let mut __result = Vec::new(); for air in arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3182,7 +3243,7 @@ pub fn infer_expr( Some(s) => substitute_generics( s.inferred.clone(), call_subst.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => error_type(), }; @@ -3191,7 +3252,7 @@ pub fn infer_expr( for p in sig_params.clone().iter().cloned() { if !param_is_generic_decl( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { __result.push(p); } @@ -3202,11 +3263,11 @@ pub fn infer_expr( if module_skips_direct_call_arg_check(scope.module_name.clone()) { Rc::new(vec![]) } else { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(direct_call_arg_mismatch_diags))))))))))))))))))))))))))))))( + direct_call_arg_mismatch_diags( value_params_for_check, typed_args.clone(), call_subst.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) }; @@ -3230,11 +3291,11 @@ pub fn infer_expr( } else { { let first_arg_type = match typed_args.clone().first().cloned() { - Some(ta) => resolved_type(arg_value(Rc::new(ta.clone()))), + Some(ta) => resolved_type(arg_value(ta.clone())), None => unit_type(), }; let method_receiver = match typed_args.clone().first().cloned() { - Some(ta) => arg_value(Rc::new(ta.clone())), + Some(ta) => arg_value(ta.clone()), None => internal_expr_error_node( "method bridge missing receiver".to_string(), span.clone(), @@ -3242,7 +3303,7 @@ pub fn infer_expr( }; let call_acc_is_under_resolved = !is_fully_resolved( call_fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() != None) && call_acc_is_under_resolved) @@ -3250,7 +3311,7 @@ pub fn infer_expr( match Rc::new({ let mut __result = Vec::new(); for a in typed_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(Rc::new(a.clone()))) { + if is_lambda_expr(arg_value(a.clone())) { __result.push(a); } } @@ -3259,7 +3320,7 @@ pub fn infer_expr( .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), None => call_fold_acc_type.clone(), } } else { @@ -3278,7 +3339,7 @@ pub fn infer_expr( None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_known_method = (method_resolution.result_type.clone() != None); if (is_known_method && ((typed_args.clone().len() as i64) > 0)) { @@ -3292,13 +3353,11 @@ pub fn infer_expr( .skip(1 as usize) .collect::>(), ); - let base_result_type = - match method_resolution.result_type.clone() { - Some(mt) => mt.clone(), - None => error_type(), - }; - let method_tv = if (method_resolution.semantics.clone() == None) - { + let base_result_type = match method_resolution.result_type.clone() { + Some(mt) => mt.clone(), + None => error_type(), + }; + let method_tv = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), @@ -3315,7 +3374,8 @@ pub fn infer_expr( if (template_return_has_variables(t.clone()) || !is_fully_resolved( base_result_type.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3328,7 +3388,7 @@ pub fn infer_expr( remaining.clone().iter().cloned() { __result.push(resolved_type( - arg_value(Rc::new(a.clone())), + arg_value(a.clone()), )); } __result @@ -3348,7 +3408,8 @@ pub fn infer_expr( call_arg_types, first_arg_type.clone(), fold_overrides, - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -3372,10 +3433,9 @@ pub fn infer_expr( }), } }; - let bridge_result_type = (*method_tv.ty).clone(); + let bridge_result_type = method_tv.ty.clone(); let template_subst_diags = method_tv.diagnostics.clone(); - let returns_receiver_self = if (method_resolution.semantics - .clone() + let returns_receiver_self = if (method_resolution.semantics.clone() == None) { false @@ -3395,12 +3455,12 @@ pub fn infer_expr( }; let final_receiver = if ((returns_receiver_self && is_fully_resolved( - Rc::new(bridge_result_type.clone()), - (*scope.type_env).clone().source_indices.clone(), + bridge_result_type.clone(), + scope.type_env.clone().source_indices.clone(), )) && !is_fully_resolved( first_arg_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { Rc::new(Node { name: receiver.name.clone(), @@ -3410,7 +3470,7 @@ pub fn infer_expr( connective: receiver.connective.clone(), params: receiver.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bridge_result_type.clone()), + node: bridge_result_type.clone(), })), return_cardinality: receiver.return_cardinality.clone(), uses: receiver.uses.clone(), @@ -3434,10 +3494,10 @@ pub fn infer_expr( for ta in remaining.clone().iter().cloned() { __result.push(make_arg_node( arg_name_at( - Rc::new(ta.clone()), - (*scope.type_env).clone().source_indices.clone(), + ta.clone(), + scope.type_env.clone().source_indices.clone(), ), - arg_value(Rc::new(ta.clone())), + arg_value(ta.clone()), span.clone(), span.clone(), )); @@ -3448,15 +3508,14 @@ pub fn infer_expr( typed: make_named_expr_node( func_name.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: method_resolution.semantics - .clone(), + method_semantics: method_resolution.semantics.clone(), }), v1_rt::concat( Rc::new(vec![final_receiver]), remaining_arg_nodes, ), Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bridge_result_type.clone()), + node: bridge_result_type.clone(), })), span.clone(), node_name_span(texpr.clone()), @@ -3475,7 +3534,7 @@ pub fn infer_expr( { let bare_m = bare_map_node(); match expected.clone() { - Some(exp) => if node_is_keyed_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_keyed_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3539,7 +3598,7 @@ match bare_m { { let bare_s = bare_set_node(); match expected.clone() { - Some(exp) => if node_is_set_collection(exp.clone(), (*scope.type_env).clone().source_indices.clone()) { + Some(exp) => if node_is_set_collection(exp.clone(), scope.type_env.clone().source_indices.clone()) { Rc::new(InferResult { typed: make_named_expr_node(func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(CallSemantics::PlainCallSemantics), @@ -3607,7 +3666,7 @@ match bare_s { scope.clone(), span.clone(), ); - let bt = (*tier2b.bt).clone(); + let bt = tier2b.bt.clone(); let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(CallSemantics::LookupCallSemantics) @@ -3623,7 +3682,7 @@ match bare_s { }), typed_arg_nodes, Some(Rc::new(InferredNode::Resolved { - node: Rc::new(bt), + node: bt, })), span.clone(), node_name_span(texpr.clone()), @@ -3641,7 +3700,8 @@ match bare_s { func_name.clone(), ) { Some(binding) => { - if (((*binding.resolved) + if ((binding + .resolved .clone() .params .clone() @@ -3649,7 +3709,7 @@ match bare_s { as i64) > 0) { - Some((*binding.resolved).clone()) + Some(binding.resolved.clone()) } else { None } @@ -3735,21 +3795,21 @@ match bare_s { } => { let method_name = expr_method_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let recv_result = infer_expr(recv, scope.clone(), None); - let recv_typed = (*recv_result.typed).clone(); + let recv_typed = recv_result.typed.clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = resolve_method_receiver_type( - resolved_type(Rc::new(recv_typed.clone())), + resolved_type(recv_typed.clone()), scope.type_env.clone(), ); let recv_elem_type = for_each_element_type_node( recv_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let mc_method_name = Some(method_name.clone()); let fold_info = extract_fold_init_info( @@ -3764,7 +3824,7 @@ match bare_s { None => error_type(), }; let mc_elem_provenance = derive_element_provenance( - Rc::new(recv_typed.clone()), + recv_typed.clone(), recv_elem_type.clone(), scope.clone(), ); @@ -3780,7 +3840,7 @@ match bare_s { let typed_mc_args = Rc::new({ let mut __result = Vec::new(); for air in mc_arg_infer_results.clone().iter().cloned() { - __result.push((*air.typed_arg).clone()); + __result.push(air.typed_arg.clone()); } __result }); @@ -3793,14 +3853,14 @@ match bare_s { }); let mc_acc_is_under_resolved = !is_fully_resolved( fold_acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let refined_fold_acc_type = if ((fold_info.clone() != None) && mc_acc_is_under_resolved) { match Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - if is_lambda_expr(arg_value(Rc::new(a.clone()))) { + if is_lambda_expr(arg_value(a.clone())) { __result.push(a); } } @@ -3809,14 +3869,14 @@ match bare_s { .first() .cloned() { - Some(lambda_arg) => resolved_type(arg_value(Rc::new(lambda_arg.clone()))), + Some(lambda_arg) => resolved_type(arg_value(lambda_arg.clone())), None => fold_acc_type.clone(), } } else { fold_acc_type.clone() }; let method_resolution = resolve_known_method_node( - Rc::new(recv_typed.clone()), + recv_typed.clone(), recv_rt.clone(), method_name.clone(), if (fold_info.clone() != None) { @@ -3825,7 +3885,7 @@ match bare_s { None }, scope.service_registry.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let pipe_fb = match method_resolution.result_type.clone() { Some(rt) => Rc::new(MethodPipeFallback { @@ -3839,10 +3899,10 @@ match bare_s { span.clone(), ), }; - let base_result_type = (*pipe_fb.result_ty).clone(); + let base_result_type = pipe_fb.result_ty.clone(); let method_tv_mc = if (method_resolution.semantics.clone() == None) { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } else { @@ -3854,15 +3914,15 @@ match bare_s { Some(t) => { if (template_return_has_variables(t.clone()) || !is_fully_resolved( - Rc::new(base_result_type.clone()), - (*scope.type_env).clone().source_indices.clone(), + base_result_type.clone(), + scope.type_env.clone().source_indices.clone(), )) { { let mc_arg_types = Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.clone().iter().cloned() { - __result.push(resolved_type(arg_value(Rc::new(a.clone())))); + __result.push(resolved_type(arg_value(a.clone()))); } __result }); @@ -3879,28 +3939,28 @@ match bare_s { mc_arg_types, recv_rt.clone(), mc_fold_overrides, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } } else { Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }) } } None => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), }, _ => Rc::new(KernelTypeBuild { - ty: Rc::new(base_result_type.clone()), + ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), }), } }; - let result_type = (*method_tv_mc.ty).clone(); + let result_type = method_tv_mc.ty.clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); let method_semantics = if (method_resolution.semantics.clone() != None) { method_resolution.semantics.clone() @@ -3913,8 +3973,8 @@ match bare_s { Rc::new(ExprData::ExprMethodCall { method_semantics: method_semantics, }), - v1_rt::concat(Rc::new(vec![Rc::new(recv_typed.clone())]), typed_mc_arg_nodes), - Some(Rc::new(InferredNode::Resolved { node: Rc::new(result_type) })), + v1_rt::concat(Rc::new(vec![recv_typed.clone()]), typed_mc_arg_nodes), + Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), node_name_span(texpr.clone()), ); @@ -3934,9 +3994,9 @@ match bare_s { let scrut = match_scrutinee(texpr.clone()); let arm_nodes = match_arm_nodes(texpr.clone()); let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); - let scrut_typed = (*scrut_result.typed).clone(); + let scrut_typed = scrut_result.typed.clone(); let scrut_diags = scrut_result.diagnostics.clone(); - let scrut_rt = resolved_type(Rc::new(scrut_typed.clone())); + let scrut_rt = resolved_type(scrut_typed.clone()); let scrut_subject = pattern_subject_from_inferred(scrut_typed.inferred.clone()); let scrut_provenance = classify_binding_provenance(scrut.clone(), scope.clone()); let arm_infer_results = Rc::new({ @@ -3966,7 +4026,7 @@ match bare_s { }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -3988,14 +4048,14 @@ match bare_s { } else { None }, - Rc::new(body_typed.clone()), + body_typed.clone(), span.clone(), ), diagnostics: v1_rt::concat( pattern_diags.clone(), v1_rt::concat(guard_diags.clone(), body_diags.clone()), ), - body_type: resolved_type(Rc::new(body_typed.clone())), + body_type: resolved_type(body_typed.clone()), }) }); } @@ -4004,7 +4064,7 @@ match bare_s { let arm_body_types = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.body_type).clone()); + __result.push(ar.body_type.clone()); } __result }); @@ -4023,14 +4083,14 @@ match bare_s { prefer_specific_type( acc, t.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }), None => scrut_rt.clone(), }; let arm_infer_results = if is_fully_resolved( unified_arm_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new({ let mut __result = Vec::new(); @@ -4088,7 +4148,7 @@ match bare_s { }; if !is_fully_resolved( original.body_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let arm_pat = arm_pattern(arm_node.clone()); @@ -4121,7 +4181,7 @@ match bare_s { arm_scope.clone(), Some(unified_arm_type.clone()), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let guard_unwrapped = match guard_result.clone() { Some(gr) => gr.clone(), @@ -4143,7 +4203,7 @@ match bare_s { } else { None }, - Rc::new(body_typed.clone()), + body_typed.clone(), span.clone(), ), diagnostics: v1_rt::concat( @@ -4153,7 +4213,7 @@ match bare_s { body_diags.clone(), ), ), - body_type: resolved_type(Rc::new(body_typed.clone())), + body_type: resolved_type(body_typed.clone()), }) } } else { @@ -4169,7 +4229,7 @@ match bare_s { let typed_arms = Rc::new({ let mut __result = Vec::new(); for ar in arm_infer_results.clone().iter().cloned() { - __result.push((*ar.typed_arm).clone()); + __result.push(ar.typed_arm.clone()); } __result }); @@ -4199,10 +4259,10 @@ match bare_s { PatternSubject::PatternResolved { node: resolved_scrutinee, .. - } => Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(check_match_exhaustiveness))))))))))))))))))))))))))))))( + } => check_match_exhaustiveness( resolved_scrutinee.clone(), typed_arms.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), span.clone(), scope.module_name.clone(), ), @@ -4211,7 +4271,7 @@ match bare_s { }; let match_texpr = make_expr_node( Rc::new(ExprData::ExprMatch), - v1_rt::concat(Rc::new(vec![Rc::new(scrut_typed.clone())]), typed_arms.clone()), + v1_rt::concat(Rc::new(vec![scrut_typed.clone()]), typed_arms.clone()), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4229,10 +4289,10 @@ match bare_s { let then_expr = if_then_branch(texpr.clone()); let else_expr = if_else_branch(texpr.clone()); let cond_result = infer_expr(cond, scope.clone(), None); - let cond_typed = (*cond_result.typed).clone(); + let cond_typed = cond_result.typed.clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); match else_expr { Some(else_branch) => { @@ -4242,10 +4302,10 @@ match bare_s { let else_rt = resolved_type(else_result.typed.clone()); let then_result = if (!is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(then_expr.clone(), scope.clone(), Some(else_rt.clone())) } else { @@ -4253,30 +4313,30 @@ match bare_s { }; let else_result = if (!is_fully_resolved( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_fully_resolved( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { infer_expr(else_branch.clone(), scope.clone(), Some(then_rt.clone())) } else { else_result.clone() }; - let then_typed = (*then_result.typed).clone(); + let then_typed = then_result.typed.clone(); let then_diags = then_result.diagnostics.clone(); - let else_typed = (*else_result.typed).clone(); + let else_typed = else_result.typed.clone(); let else_diags = else_result.diagnostics.clone(); - let then_rt = resolved_type(Rc::new(then_typed.clone())); - let else_rt = resolved_type(Rc::new(else_typed.clone())); + let then_rt = resolved_type(then_typed.clone()); + let else_rt = resolved_type(else_typed.clone()); let unified = prefer_specific_type( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let branch_diags = if node_type_compatible( then_rt.clone(), else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Rc::new(vec![]) } else { @@ -4288,14 +4348,14 @@ match bare_s { .to_string(), node_type_shape( then_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), " vs ".to_string(), ), node_type_shape( else_rt.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), ), span.clone(), @@ -4304,7 +4364,7 @@ match bare_s { }; let if_texpr = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone()), Rc::new(else_typed.clone())]), + Rc::new(vec![cond_typed, then_typed.clone(), else_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: unified })), span.clone(), ); @@ -4319,7 +4379,7 @@ match bare_s { None => { let if_texpr2 = make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(cond_typed), Rc::new(then_typed.clone())]), + Rc::new(vec![cond_typed, then_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: unit_type() })), span.clone(), ); @@ -4333,7 +4393,7 @@ match bare_s { ExprData::ExprLet => { let let_name = let_binding_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let val_expr = let_value(texpr.clone()); @@ -4344,7 +4404,7 @@ match bare_s { binding_kind: _, .. } => { (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), bd.clone(), ) == let_name.clone()) } @@ -4358,15 +4418,15 @@ match bare_s { None }; let val_result = infer_expr(val_expr, scope.clone(), val_expected); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); - let val_type = resolved_type(Rc::new(val_typed.clone())); + let val_type = resolved_type(val_typed.clone()); if (body_expr.clone() == None) { { let let_texpr = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed.clone())]), + Rc::new(vec![val_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: val_type })), span.clone(), node_name_span(texpr.clone()), @@ -4382,16 +4442,16 @@ match bare_s { scope.clone(), let_name.clone(), val_type, - classify_binding_provenance(Rc::new(val_typed.clone()), scope.clone()), + classify_binding_provenance(val_typed.clone(), scope.clone()), ); let body_result = infer_expr(body_expr.clone().unwrap(), extended, expected.clone()); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let let_texpr2 = make_named_expr_node( let_name.clone(), Rc::new(ExprData::ExprLet), - Rc::new(vec![Rc::new(val_typed.clone()), Rc::new(body_typed.clone())]), + Rc::new(vec![val_typed.clone(), body_typed.clone()]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -4409,7 +4469,7 @@ match bare_s { infer_record_lit( record_lit_type_name_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), field_inits, span.clone(), @@ -4425,7 +4485,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => Some(child_type_node(elem.clone())), @@ -4447,7 +4507,7 @@ match bare_s { let typed_elements = Rc::new({ let mut __result = Vec::new(); for r in elem_results.clone().iter().cloned() { - __result.push((*r.typed).clone()); + __result.push(r.typed.clone()); } __result }); @@ -4468,7 +4528,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(elem) => child_type_node(elem.clone()), @@ -4486,7 +4546,7 @@ match bare_s { Some(exp) => { if node_is_element_collection( exp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match exp.children.clone().first().cloned() { Some(_) => Rc::new(vec![]), @@ -4533,22 +4593,22 @@ match bare_s { let left_expr = binop_left(texpr.clone()); let right_expr = binop_right(texpr.clone()); let left_result = infer_expr(left_expr, scope.clone(), None); - let left_typed = (*left_result.typed).clone(); + let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); let right_result = infer_expr(right_expr, scope.clone(), None); - let right_typed = (*right_result.typed).clone(); + let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = infer_binop_type_node( op.clone(), - resolved_type(Rc::new(left_typed.clone())), - (*scope.type_env).clone().source_indices.clone(), + resolved_type(left_typed.clone()), + scope.type_env.clone().source_indices.clone(), ); let bo_texpr = make_expr_node( Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: binop_info.algebra_field.clone(), }), - Rc::new(vec![Rc::new(left_typed.clone()), Rc::new(right_typed)]), + Rc::new(vec![left_typed.clone(), right_typed]), Some(Rc::new(InferredNode::Resolved { node: binop_info.result_type.clone(), })), @@ -4563,15 +4623,15 @@ match bare_s { let span = texpr.span.clone(); let operand_expr = unaryop_operand(texpr.clone()); let operand_result = infer_expr(operand_expr, scope.clone(), None); - let operand_typed = (*operand_result.typed).clone(); + let operand_typed = operand_result.typed.clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { UnaryOpKind::Not => bool_type(), - UnaryOpKind::Neg => resolved_type(Rc::new(operand_typed.clone())), + UnaryOpKind::Neg => resolved_type(operand_typed.clone()), }; let uo_texpr = make_expr_node( Rc::new(ExprData::ExprUnaryOp { op: op.clone() }), - Rc::new(vec![Rc::new(operand_typed.clone())]), + Rc::new(vec![operand_typed.clone()]), Some(Rc::new(InferredNode::Resolved { node: result_type })), span.clone(), ); @@ -4585,7 +4645,7 @@ match bare_s { let lam_body = lambda_body(texpr.clone()); let lam_params = lambda_param_names_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let lam_param_nodes = Rc::new( texpr @@ -4725,7 +4785,7 @@ match bare_s { lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let typed_param_nodes = Rc::new({ let mut __result = Vec::new(); @@ -4781,7 +4841,7 @@ match bare_s { }); let lam_texpr = make_expr_node( Rc::new(ExprData::ExprLambda), - v1_rt::concat(Rc::new(vec![Rc::new(body_typed.clone())]), typed_param_nodes), + v1_rt::concat(Rc::new(vec![body_typed.clone()]), typed_param_nodes), body_typed.inferred.clone(), span.clone(), ); @@ -4800,10 +4860,7 @@ match bare_s { _ => match part_node.children.clone().first().cloned() { Some(inner) => { let r = infer_expr(inner.clone(), scope.clone(), None); - make_interp_part_node( - r.typed.clone(), - part_node.span.clone(), - ) + make_interp_part_node(r.typed.clone(), part_node.span.clone()) } None => part_node.clone(), }, @@ -4891,9 +4948,9 @@ match bare_s { let cast_inner = cast_expr(texpr.clone()); let target_type = cast_target(texpr.clone()); let inner_result = infer_expr(cast_inner, scope.clone(), None); - let inner_typed = (*inner_result.typed).clone(); + let inner_typed = inner_result.typed.clone(); let inner_diags = inner_result.diagnostics.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let target_name = authored_name_at(si.clone(), target_type.clone()); let cast_diag = validate_cast( inner_typed.inferred.clone(), @@ -4908,7 +4965,7 @@ match bare_s { }; let cast_texpr = make_expr_node( Rc::new(ExprData::ExprCast), - Rc::new(vec![Rc::new(inner_typed.clone()), target_type.clone()]), + Rc::new(vec![inner_typed.clone(), target_type.clone()]), Some(Rc::new(InferredNode::Resolved { node: target_type.clone(), })), @@ -4922,20 +4979,20 @@ match bare_s { ExprData::ExprForEach => { let variable = foreach_variable_at( texpr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let span = texpr.span.clone(); let coll = foreach_collection(texpr.clone()); let body_expr = foreach_body(texpr.clone()); let coll_result = infer_expr(coll, scope.clone(), None); - let coll_typed = (*coll_result.typed).clone(); + let coll_typed = coll_result.typed.clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = for_each_element_type_node( - resolved_type(Rc::new(coll_typed.clone())), - (*scope.type_env).clone().source_indices.clone(), + resolved_type(coll_typed.clone()), + scope.type_env.clone().source_indices.clone(), ); let elem_provenance = derive_element_provenance( - Rc::new(coll_typed.clone()), + coll_typed.clone(), elem_type_node.clone(), scope.clone(), ); @@ -4946,12 +5003,12 @@ match bare_s { elem_provenance, ); let body_result = infer_expr(body_expr.clone(), body_scope, None); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = make_named_expr_node( variable.clone(), Rc::new(ExprData::ExprForEach), - Rc::new(vec![Rc::new(coll_typed.clone()), Rc::new(body_typed.clone())]), + Rc::new(vec![coll_typed.clone(), body_typed.clone()]), body_typed.inferred.clone(), span.clone(), node_name_span(texpr.clone()), @@ -4966,10 +5023,10 @@ match bare_s { let base_expr = index_base(texpr.clone()); let idx_key = index_expr(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let index_result = infer_expr(idx_key, scope.clone(), None); - let index_typed = (*index_result.typed).clone(); + let index_typed = index_result.typed.clone(); let index_diags = index_result.diagnostics.clone(); let index_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -4982,19 +5039,17 @@ match bare_s { index_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), _ => None, }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - index_typed.inferred.clone() - } - _ => base_typed.inferred.clone(), - }; + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), + _ => base_typed.inferred.clone(), + }; let idx_inferred = match index_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5009,7 +5064,7 @@ match bare_s { }; let idx_texpr = make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![Rc::new(base_typed.clone()), Rc::new(index_typed.clone())]), + Rc::new(vec![base_typed.clone(), index_typed.clone()]), idx_inferred, span.clone(), ); @@ -5027,13 +5082,13 @@ match bare_s { let start_expr = slice_start(texpr.clone()); let end_expr = slice_end(texpr.clone()); let base_result = infer_expr(base_expr, scope.clone(), None); - let base_typed = (*base_result.typed).clone(); + let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let start_result = infer_expr(start_expr, scope.clone(), None); - let start_typed = (*start_result.typed).clone(); + let start_typed = start_result.typed.clone(); let start_diags = start_result.diagnostics.clone(); let end_result = infer_expr(end_expr, scope.clone(), None); - let end_typed = (*end_result.typed).clone(); + let end_typed = end_result.typed.clone(); let end_diags = end_result.diagnostics.clone(); let slice_check = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { @@ -5049,7 +5104,7 @@ match bare_s { end_type.clone(), span.clone(), scope.module_name.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) } _ => None, @@ -5058,18 +5113,18 @@ match bare_s { }, _ => None, }; - let access_failure_inferred = - match base_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - match start_typed.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: _, .. }) => { - end_typed.inferred.clone() - } - _ => start_typed.inferred.clone(), + let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { node: _, .. }) => { + match start_typed.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: _, .. }) => { + end_typed.inferred.clone() } + _ => start_typed.inferred.clone(), } - _ => base_typed.inferred.clone(), - }; + } + _ => base_typed.inferred.clone(), + }; let slc_inferred = match slice_check.clone() { Some(checked) => checked.inferred.clone(), None => Some(inferred_or_error( @@ -5085,9 +5140,9 @@ match bare_s { let slc_texpr = make_expr_node( Rc::new(ExprData::ExprSlice), Rc::new(vec![ - Rc::new(base_typed.clone()), - Rc::new(start_typed.clone()), - Rc::new(end_typed.clone()), + base_typed.clone(), + start_typed.clone(), + end_typed.clone(), ]), slc_inferred, span.clone(), @@ -5107,7 +5162,7 @@ match bare_s { let ret_texpr = make_expr_node( Rc::new(ExprData::ExprReturn), Rc::new(vec![inner_result.typed.clone()]), - (*inner_result.typed).clone().inferred.clone(), + inner_result.typed.clone().inferred.clone(), span.clone(), ); Rc::new(InferResult { @@ -5144,7 +5199,7 @@ pub fn infer_variant_constructor_call( match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { None => None, Some(parent_enum) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match lookup_type_by_name(scope.type_env.clone(), parent_enum.clone()) { Some(parent_node) => { match find_child_named(parent_node.clone(), func_name.clone(), si.clone()) { @@ -5226,8 +5281,7 @@ pub fn infer_variant_constructor_call( } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) - { + if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { if (((n.connective.clone() == Connective::NoConnective) @@ -5300,11 +5354,13 @@ pub fn peel_alias_once_for_field_access( mut module_name: String, ) -> Rc { loop { - let once = (*resolve_node(n, env.clone(), module_name.clone()).resolved).clone(); + let once = resolve_node(n, env.clone(), module_name.clone()) + .resolved + .clone(); if ((once.connective.clone() == Connective::Conj) || (once.connective.clone() == Connective::Disj)) { - break Rc::new(once.clone()); + break once.clone(); } else { if (((once.connective.clone() == Connective::NoConnective) && ((once.children.clone().len() as i64) > 0)) @@ -5312,11 +5368,11 @@ pub fn peel_alias_once_for_field_access( { { let __tco_0 = once.clone(); - n = Rc::new(__tco_0); + n = __tco_0; continue; } } else { - break Rc::new(once.clone()); + break once.clone(); } } } @@ -5589,13 +5645,17 @@ pub fn expand_alias_chain_for_field_access( } } -pub fn expand_type_for_field_access_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: parallel alias/inferred chase to expand_type_for_field_access — unify with 04_resolve.dag resolve_scrutinee_type_node once regen lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn expand_type_for_field_access( + n: Rc, + env: Rc, + module_name: String, +) -> Rc { + expand_type_for_field_access_with_seen( + n, + env, + module_name, + v1_rt::rc_empty_map::(), + ) } pub fn expand_type_for_field_access_with_seen( @@ -5607,33 +5667,18 @@ pub fn expand_type_for_field_access_with_seen( if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() } else { - { - let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); - expand_alias_chain_for_field_access( - n.clone(), - env.clone(), - module_name, - origin_name, - seen, - false, - ) - } + let origin_name = authored_name_at(env.source_indices.clone(), n.clone()); + expand_alias_chain_for_field_access( + n.clone(), + env.clone(), + module_name, + origin_name, + seen, + false, + ) } } -pub fn expand_type_for_field_access( - n: Rc, - env: Rc, - module_name: String, -) -> Rc { - expand_type_for_field_access_with_seen( - n, - env, - module_name, - v1_rt::rc_empty_map::(), - ) -} - pub fn record_lit_alias_struct_fields( type_name: String, scope: Rc, @@ -5673,7 +5718,7 @@ pub fn record_lit_construction_field_names( scope: Rc, ) -> Option>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match lookup_type_by_name(scope.type_env.clone(), type_name) { Some(decl) => { if ((((decl.params.clone().len() as i64) == 0) @@ -5698,44 +5743,67 @@ pub fn record_lit_construction_field_names( pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); - match variant_owner_node(scope.clone(), type_name.clone()) { - Some(owner) => { - let mut __found = false; - for arm in owner.children.clone().iter().cloned() { - if if (authored_name_at(si.clone(), arm.clone()) == type_name.clone()) { + let si = scope.type_env.clone().source_indices.clone(); + { + let mut __found = false; + for binding in Rc::new(v1_rt::map_values(&flatten_visible_bindings( + scope.type_env.clone(), + ))) + .iter() + .cloned() + { + if { + let node = binding.resolved.clone(); + if (node.connective.clone() == Connective::Disj) { { - let ea = expand_type_for_field_access( - arm.clone(), - scope.type_env.clone(), - scope.module_name.clone(), - ); - let fields = if (ea.connective.clone() == Connective::Conj) { - ea.children.clone() - } else { - arm.children.clone() - }; - { - let mut __found = false; - for f in fields.clone().iter().cloned() { - if (authored_name_at(si.clone(), f.clone()) == field.clone()) { - __found = true; - break; + let mut __found = false; + for arm in node.children.clone().iter().cloned() { + if if (authored_name_at(si.clone(), arm.clone()) + == type_name.clone()) + { + { + let ea = expand_type_for_field_access( + arm.clone(), + scope.type_env.clone(), + scope.module_name.clone(), + ); + let fields = if (ea.connective.clone() == Connective::Conj) + { + ea.children.clone() + } else { + arm.children.clone() + }; + { + let mut __found = false; + for f in fields.clone().iter().cloned() { + if (authored_name_at(si.clone(), f.clone()) + == field.clone()) + { + __found = true; + break; + } + } + __found + } } + } else { + false + } { + __found = true; + break; } - __found } + __found } } else { false - } { - __found = true; - break; } + } { + __found = true; + break; } - __found } - None => false, + __found } } } @@ -5765,28 +5833,38 @@ pub fn infer_record_lit( expected: Option>, ) -> Rc { { + // HAND-PATCH (§1c): the unconditional whole-env scan-first rung is + // deleted; the ladder is instantiate -> expected -> declaration/ + // binding-edge only. Regen replaces this with the dag source's true + // emission. let struct_fields = match type_name.clone() { - Some(tn) => match record_lit_instantiated_fields( - type_name.clone(), - expected.clone(), - scope.clone(), - ) { - Some(fields) => fields.clone(), - None => match record_lit_fields_from_expected( + Some(tn) => { + match record_lit_instantiated_fields( type_name.clone(), expected.clone(), scope.clone(), ) { Some(fields) => fields.clone(), - None => match expected.clone() { - Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), - None => match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { - Some(fields) => fields.clone(), - None => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => match record_lit_fields_from_expected( + type_name.clone(), + expected.clone(), + scope.clone(), + ) { + Some(fields) => fields.clone(), + None => match expected.clone() { + Some(_) => record_lit_expected_fields(type_name.clone(), scope.clone()), + None => { + match record_lit_alias_struct_fields(tn.clone(), scope.clone()) { + Some(fields) => fields.clone(), + None => { + record_lit_expected_fields(type_name.clone(), scope.clone()) + } + } + } }, }, - }, - }, + } + } None => match record_lit_instantiated_fields( type_name.clone(), expected.clone(), @@ -5817,7 +5895,7 @@ pub fn infer_record_lit( __result.push({ let fi_name = field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let unknown_field_diags = match construction_field_names.clone() { Some(names) => { @@ -5853,7 +5931,7 @@ pub fn infer_record_lit( let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), sf.clone(), ) == fi_name.clone()) { @@ -5870,8 +5948,8 @@ pub fn infer_record_lit( Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => field_node_type_expr(sf.clone()), }; - if (((ft.ident_span.clone() != None) - || type_node_is_callable(ft.clone())) + if ((ft.ident_span.clone() != None) + || type_node_is_callable(ft.clone()) || field_type_is_optional_coproduct( ft.clone(), scope.type_env.clone(), @@ -5889,38 +5967,36 @@ pub fn infer_record_lit( scope.clone(), field_expected.clone(), ); - let ar_typed = (*ar.typed).clone(); + let ar_typed = ar.typed.clone(); let ar_diags = ar.diagnostics.clone(); let field_type_diags = match field_expected.clone() { Some(expected_node) => { - let got_node = resolved_type(Rc::new(ar_typed.clone())); + let got_node = resolved_type(ar_typed.clone()); if rejects_string_for_optional_coproduct_field( expected_node.clone(), got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), scope.type_env.clone(), ) { - { - let expected_for_shape = match lookup_type_for( - scope.type_env.clone(), - with_required_cardinality(expected_node.clone()), - ) { - Some(resolved) => resolved.clone(), - None => expected_node.clone(), - }; - Rc::new(vec![type_mismatch_error( - node_type_shape( - expected_for_shape.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - node_type_shape( - got_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - ), - ar_typed.span.clone(), - scope.module_name.clone(), - )]) - } + let expected_for_shape = match lookup_type_for( + scope.type_env.clone(), + with_required_cardinality(expected_node.clone()), + ) { + Some(resolved) => resolved.clone(), + None => expected_node.clone(), + }; + Rc::new(vec![type_mismatch_error( + node_type_shape( + expected_for_shape, + scope.type_env.clone().source_indices.clone(), + ), + node_type_shape( + got_node.clone(), + scope.type_env.clone().source_indices.clone(), + ), + ar_typed.span.clone(), + scope.module_name.clone(), + )]) } else { Rc::new(vec![]) } @@ -5930,7 +6006,7 @@ pub fn infer_record_lit( Rc::new(FieldInferResult { typed_field: make_field_init_node( fi_name.clone(), - Rc::new(ar_typed.clone()), + ar_typed.clone(), fi.span.clone(), node_name_span(fi.clone()), ), @@ -5947,7 +6023,7 @@ pub fn infer_record_lit( let typed_fields = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - __result.push((*fir.typed_field).clone()); + __result.push(fir.typed_field.clone()); } __result }); @@ -5966,14 +6042,14 @@ pub fn infer_record_lit( __result.push(Rc::new(Node { name: field_init_node_name_at( fir.typed_field.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), - span: (*fir.typed_field).clone().span.clone(), - ident_span: (*fir.typed_field).clone().ident_span.clone(), + span: fir.typed_field.clone().span.clone(), + ident_span: fir.typed_field.clone().ident_span.clone(), children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: (*fir.infer_result.clone().typed).clone().inferred.clone(), + inferred: fir.infer_result.clone().typed.clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: None, @@ -6055,7 +6131,7 @@ pub fn infer_record_lit( for fir in fi_infer_results.clone().iter().cloned() { if (field_init_node_name_at( fir.typed_field.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "value".to_string()) { __result.push(fir); @@ -6075,6 +6151,9 @@ pub fn infer_record_lit( } else { raw_resolved }; + // HAND-PATCH (§1c): unbound constructor literal is the typed + // UnresolvedType diagnostic, not a generic InternalError message. + // Regen replaces this with the dag source's true emission. let type_diags = match effective_lookup.clone() { Some(_) => Rc::new(vec![]), None => Rc::new(vec![make_error_node( @@ -6173,7 +6252,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); @@ -6183,7 +6262,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) { Some(_) => Some(Rc::new(SizeExpr::ParamSize { @@ -6211,7 +6290,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), lname) .as_deref() @@ -6260,7 +6339,7 @@ pub fn proportional_skip_alias_plus_literal( } => { let aname = expr_var_name_at( alias_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.size_aliases.clone(), aname) .as_deref() @@ -6325,7 +6404,7 @@ pub fn classify_collection_shrink( } => { let mname = expr_method_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { @@ -6336,7 +6415,7 @@ pub fn classify_collection_shrink( } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (rname == param_name.clone()) { { @@ -6381,10 +6460,7 @@ Rc::new(SubValueRelation::StrictSubValue { } => { let aname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env) - .clone() - .source_indices - .clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get( &ctx.size_aliases.clone(), @@ -6592,12 +6668,12 @@ pub fn build_per_field_for_let( match (*val.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6617,7 +6693,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6652,12 +6728,12 @@ pub fn build_per_field_for_let( .. } => { let callee = - expr_method_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { if ((sig.output_provenance.clone().len() as i64) > 1) { { - let return_type = (*sig.inferred).clone(); + let return_type = sig.inferred.clone(); let field_map = Rc::new( return_type .children @@ -6677,7 +6753,7 @@ pub fn build_per_field_for_let( let idx = pair.0.clone(); let field_node = pair.1.clone(); let fname = authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), field_node.clone(), ); maybe_insert_output_field_relation( @@ -6721,7 +6797,7 @@ pub fn resolve_collection_field( let base = field_access_base(expr.clone()); let fname = field_access_field_at( expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -6729,7 +6805,7 @@ pub fn resolve_collection_field( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -6795,7 +6871,7 @@ pub fn resolve_collection_field( binding_kind: _, .. } => { let rname = - expr_var_name_at(expr.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_var_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { SubValueRelation::StrictSubValue { field: f, .. } => { @@ -6831,10 +6907,8 @@ pub fn resolve_collection_field( method_semantics: _, .. } => { - let inner_mname = expr_method_name_at( - expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let inner_mname = + expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); let is_collection_preserving = (((((inner_mname.clone() == "enumerate".to_string()) || (inner_mname.clone() == "skip".to_string())) @@ -6863,10 +6937,8 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { - let vname = expr_var_name_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let vname = + expr_var_name_at(val.clone(), scope.type_env.clone().source_indices.clone()); match v1_rt::map_get(&scope.locals.clone(), vname) { Some(binding) => binding.provenance.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), @@ -6874,24 +6946,22 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc { let base = field_access_base(val.clone()); - let field = field_access_field_at( - val.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let field = + field_access_field_at(val.clone(), scope.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { let bname = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&scope.locals.clone(), bname) { Some(binding) => { let fields = inductive_fields_for( scope.type_env.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), ); @@ -6928,8 +6998,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { - let vname = - expr_var_name_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + let vname = expr_var_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => None, @@ -6941,15 +7010,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let base = field_access_base(val.clone()); let field = - field_access_field_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + field_access_field_at(val.clone(), ctx.type_env.clone().source_indices.clone()); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); let from_per_field = match v1_rt::map_get(&ctx.per_field_vars.clone(), bname.clone()) { Some(field_map) => v1_rt::map_get(&field_map, field.clone()), @@ -6961,7 +7028,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), None => match v1_rt::map_get( @@ -7010,7 +7077,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let callee = - expr_call_func_at(val.clone(), (*ctx.type_env).clone().source_indices.clone()); + expr_call_func_at(val.clone(), ctx.type_env.clone().source_indices.clone()); let from_provenance = match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { Some(sig) => match sig.output_provenance.clone().first().cloned() { Some(param_map) => { @@ -7037,7 +7104,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let iname = expr_var_name_at( inner.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let inner_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -7113,13 +7180,13 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { if is_container_type(authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), rt.clone(), )) { { let elem = match rt.children.clone().first().cloned() { Some(c) => authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), c.clone(), ), None => "".to_string(), @@ -7177,7 +7244,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) != None) @@ -7224,7 +7291,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7248,7 +7315,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let lname = expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((v1_rt::map_get( &ctx.param_names.clone(), @@ -7309,7 +7376,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at( val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let is_collection_preserving = (((((mname.clone() == "skip".to_string()) @@ -7367,7 +7434,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env) + ctx.type_env .clone() .source_indices .clone(), @@ -7437,7 +7504,7 @@ pub fn classify_call_via_provenance( v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(aname) => { v1_rt::rc_map_insert(acc.clone(), aname.clone(), arg_value(arg_node.clone())) @@ -7484,7 +7551,7 @@ pub fn classify_call_arg_provenance( } => { let name = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { Some(Rc::new(SubValueRelation::PreservedValue)) @@ -7527,7 +7594,7 @@ pub fn classify_argument( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) @@ -7542,7 +7609,7 @@ pub fn classify_argument( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -7550,7 +7617,7 @@ pub fn classify_argument( } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let type_name = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -7609,24 +7676,22 @@ pub fn classify_argument( SubValueRelation::PreservedValue => { let callee = expr_call_func_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); - let from_provenance = match lookup_func_sig( - ctx.func_env.clone(), - callee.clone(), - ) { - Some(sig) => { - match sig.output_provenance.clone().first().cloned() { - Some(param_map) => classify_call_via_provenance( - arg_expr.clone(), - param_map.clone(), - ctx.clone(), - ), - None => None, + let from_provenance = + match lookup_func_sig(ctx.func_env.clone(), callee.clone()) { + Some(sig) => { + match sig.output_provenance.clone().first().cloned() { + Some(param_map) => classify_call_via_provenance( + arg_expr.clone(), + param_map.clone(), + ctx.clone(), + ), + None => None, + } } - } - None => None, - }; + None => None, + }; match from_provenance { Some(prov_rel) => prov_rel.clone(), None => { @@ -7720,13 +7785,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7764,13 +7829,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7782,13 +7847,13 @@ pub fn classify_argument( } => { ((expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( inner_left.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), ) != None)) } @@ -7885,7 +7950,7 @@ pub fn read_arg_provenance( } => { let vname = expr_var_name_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.scope_locals.clone(), vname) { Some(binding) => match (*binding.provenance.clone()).clone() { @@ -7901,16 +7966,14 @@ pub fn read_arg_provenance( let base = field_access_base(arg_expr.clone()); let field = field_access_field_at( arg_expr.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at( - base.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let bname = + expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { Some(binding) => match (*binding.provenance.clone()).clone() { SubValueRelation::SubValueUnknown => { @@ -7920,7 +7983,7 @@ pub fn read_arg_provenance( let fields = inductive_fields_for( ctx.type_env.clone(), authored_name_at( - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), binding.resolved.clone(), ), ); @@ -7992,7 +8055,7 @@ pub fn build_call_evidence( let arg_node = pair.1.clone(); let aname = arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match aname.clone() { Some(pname) => v1_rt::rc_map_insert( @@ -8011,7 +8074,7 @@ pub fn build_call_evidence( for arg_node in call_node.children.clone().iter().cloned() { if (arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) == None) { __result.push(arg_node); @@ -8080,7 +8143,7 @@ pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc { let vname = expr_var_name_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), vname) { Some(t) => t.clone(), @@ -8118,7 +8181,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { { let lparams = lambda_param_names_at( arg_val.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let p1 = match lparams.clone().first().cloned() { Some(n) => n.clone(), @@ -8211,7 +8274,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent( arg_val.clone(), @@ -8225,7 +8288,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8236,7 +8299,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { _ => make_arg_node( arg_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), @@ -8279,7 +8342,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let sname = expr_var_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.param_names.clone(), sname.clone()) { Some(t) => t.clone(), @@ -8306,7 +8369,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let base = field_access_base(scrut.clone()); let fname = field_access_field_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8314,7 +8377,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get(&ctx.param_names.clone(), bname.clone()) { @@ -8352,7 +8415,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } => { let mname = expr_method_name_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if ((mname.clone() == "first".to_string()) || (mname.clone() == "last".to_string())) @@ -8376,7 +8439,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( scrut.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match lookup_func_sig(ctx.func_env.clone(), callee) { Some(sig) => { @@ -8427,7 +8490,7 @@ let arm_ctx = match variant_arm_ctx.clone() { MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { let inner_ind_fields = inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); inner_bindings.clone().iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { - let inner_field_name = field_binding_name_at(inner_fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let inner_field_name = field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), @@ -8464,7 +8527,7 @@ match inner_matching.clone() { None => { let ind_fields = inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { - let field_name = field_binding_name_at(fb.clone(), (*ctx.type_env).clone().source_indices.clone()); + let field_name = field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), @@ -8560,10 +8623,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } ExprData::ExprLet => { let val = let_value(body.clone()); - let binding_name = let_binding_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let binding_name = + let_binding_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let val_relation = classify_let_value(val.clone(), ctx.clone()); let size_alias = classify_size_expr(val.clone(), ctx.clone()); let inner_size_aliases = match size_alias { @@ -8681,7 +8742,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let val = let_value(child.clone()); let bname = let_binding_name_at( child.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); let sa = classify_size_expr(val.clone(), acc.ctx.clone()); @@ -8795,10 +8856,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota method_semantics: ms, .. } => { - let mname = expr_method_name_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let mname = + expr_method_name_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let elem_position = method_callback_element_position(ms.clone()); if (elem_position.clone() != None) { { @@ -8810,7 +8869,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let inner_mname = expr_method_name_at( raw_receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) @@ -8825,7 +8884,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let base = field_access_base(receiver.clone()); let fname = field_access_field_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match (*base.expr_data.clone()).clone() { ExprData::ExprVar { @@ -8833,7 +8892,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let bname = expr_var_name_at( base.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let base_type = match v1_rt::map_get( &ctx.param_names.clone(), @@ -8888,7 +8947,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => { let rname = expr_var_name_at( receiver.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); match v1_rt::map_get(&ctx.sub_value_vars.clone(), rname) { Some(rel) => match (*rel.clone()).clone() { @@ -8931,7 +8990,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota let lambda_node = arg_value(la.clone()); let lparams = lambda_param_names_at( lambda_node, - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); lparams .clone() @@ -9007,7 +9066,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9020,7 +9079,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota make_arg_node( match arg_name_at( arg_node.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => None, @@ -9067,10 +9126,8 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota ExprData::ExprForEach => { let coll = foreach_collection(body.clone()); let fe_body = foreach_body(body.clone()); - let fe_var = foreach_variable_at( - body.clone(), - (*ctx.type_env).clone().source_indices.clone(), - ); + let fe_var = + foreach_variable_at(body.clone(), ctx.type_env.clone().source_indices.clone()); let coll_field = resolve_collection_field(coll.clone(), ctx.clone()); let inner_ctx = match coll_field { Some(ind_field) => Rc::new(DescentContext { @@ -9759,10 +9816,10 @@ pub fn classify_body_per_field( ) -> Rc>>>> { { let unwrapped = unwrap_body_terminal(expr, let_prov, type_env.clone()); - let terminal = (*unwrapped.expr).clone(); + let terminal = unwrapped.expr.clone(); let terminal_prov = unwrapped.let_prov.clone(); classify_terminal_per_field( - Rc::new(terminal), + terminal, param_names, param_types, type_env.clone(), @@ -9805,15 +9862,11 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - match (*(*arm_unwrapped.expr).clone().expr_data.clone()).clone() { + match (*arm_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*arm_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() + for fi in + arm_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), @@ -9840,16 +9893,10 @@ pub fn classify_terminal_per_field( let_prov.clone(), type_env.clone(), ); - let then_result = match (*(*then_unwrapped.expr).clone().expr_data.clone()).clone() { + let then_result = match (*then_unwrapped.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ let mut __result = Vec::new(); - for fi in (*then_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { + for fi in then_unwrapped.expr.clone().children.clone().iter().cloned() { __result.push(classify_body_provenance( field_init_node_value(fi.clone()), param_names.clone(), @@ -9867,30 +9914,24 @@ pub fn classify_terminal_per_field( Some(else_expr) => { let else_unwrapped = unwrap_body_terminal(else_expr.clone(), let_prov.clone(), type_env.clone()); - let else_result = - match (*(*else_unwrapped.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ - let mut __result = Vec::new(); - for fi in (*else_unwrapped.expr) - .clone() - .children - .clone() - .iter() - .cloned() - { - __result.push(classify_body_provenance( - field_init_node_value(fi.clone()), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_env.clone(), - else_unwrapped.let_prov.clone(), - )); - } - __result - }), - _ => Rc::new(vec![]), - }; + let else_result = match (*else_unwrapped.expr.clone().expr_data.clone()).clone() + { + ExprData::ExprRecordLit { parent_enum: _, .. } => Rc::new({ + let mut __result = Vec::new(); + for fi in else_unwrapped.expr.clone().children.clone().iter().cloned() { + __result.push(classify_body_provenance( + field_init_node_value(fi.clone()), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_env.clone(), + else_unwrapped.let_prov.clone(), + )); + } + __result + }), + _ => Rc::new(vec![]), + }; meet_per_field_results(Rc::new(vec![then_result, else_result])) } None => then_result, @@ -10058,13 +10099,13 @@ pub fn arm_ctx_from_variant_provenance( } => match v1_rt::map_get(&sig.variant_provenance.clone(), vname.clone()) { Some(variant_field_map) => { let call_args = - call_args_by_name(scrut, (*ctx.type_env).clone().source_indices.clone()); + call_args_by_name(scrut, ctx.type_env.clone().source_indices.clone()); let extended = bindings.clone().iter().cloned().fold( ctx.clone(), |c: Rc, fb: Rc| { let field_label = field_binding_name_at( fb.clone(), - (*ctx.type_env).clone().source_indices.clone(), + ctx.type_env.clone().source_indices.clone(), ); let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), @@ -10077,13 +10118,13 @@ pub fn arm_ctx_from_variant_provenance( } else { match v1_rt::map_get(&variant_field_map, field_label.clone()) { Some(param_map) => { - let composed = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(compose_callee_param_map))))))))))))))))))))))))))))))( + let composed = compose_callee_param_map( param_map.clone(), call_args.clone(), c.param_order.clone(), c.param_names.clone(), - (*c.type_env).clone(), - (*c.func_env).clone(), + c.type_env.clone(), + c.func_env.clone(), v1_rt::rc_empty_map::< String, Rc>>, @@ -10715,36 +10756,34 @@ pub fn populate_output_provenance( locals.clone(), working_env.clone(), ); - let variant_prov = match item.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { - node: rt, .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, + let variant_prov = + match item.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: rt, + .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, + >, >, >, >, - >, - >( - ), - }; + >( + ), + }; let has_scalar = ((provenance.clone().len() as i64) > 0); let has_variant = @@ -10925,7 +10964,7 @@ pub fn infer_auth_source_properties( __result.push( if (field_init_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "svc_auth_source".to_string()) { { @@ -11044,7 +11083,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc children: Rc::new({ let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { - __result.push((*infer_item(c.clone(), scope.clone()).item).clone()); + __result.push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11076,7 +11115,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc s, resource_use_name_at( u.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), resource_use_resource(u.clone()), Rc::new(SubValueRelation::SubValueUnknown), @@ -11093,7 +11132,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), fn_return_expected, ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let inferred_ret = if (item.inferred.clone() != None) { item.inferred.clone() @@ -11101,27 +11140,27 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc body_typed.inferred.clone() }; let is_recursive = expr_has_self_call( - Rc::new(body_typed.clone()), + body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let annotated_body = if is_recursive.clone() { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(annotate_descent_evidence))))))))))))))))))))))))))))))( + annotate_descent_evidence( body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), item.params.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), fn_scope.locals.clone(), - (*scope.func_env).clone(), + scope.func_env.clone(), ) } else { - Rc::new(body_typed.clone()) + body_typed.clone() }; Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11132,7 +11171,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result - .push((*infer_item(c.clone(), scope.clone()).item).clone()); + .push(infer_item(c.clone(), scope.clone()).item.clone()); } __result }), @@ -11147,13 +11186,13 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno, is_self_recursive: is_recursive.clone(), has_non_tail_self_call: expr_has_non_tail_self_call( - Rc::new(body_typed.clone()), + body_typed.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), item.clone(), ), true, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), match_pattern: None, expr_data: Rc::new(ExprData::NoExprData), @@ -11176,7 +11215,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc fn_scope.clone(), Some(resolved_type(item.clone())), ); - let body_typed = (*body_result.typed).clone(); + let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11188,7 +11227,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(body_typed.clone())), + body: Some(body_typed.clone()), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11206,8 +11245,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { { let data_expected = if (item.type_annotation.clone() != None) { Some(item.type_annotation.clone().clone().unwrap()) @@ -11219,7 +11257,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc scope.clone(), data_expected, ); - let val_typed = (*val_result.typed).clone(); + let val_typed = val_result.typed.clone(); let val_diags = val_result.diagnostics.clone(); let inferred_ret = if (item.type_annotation.clone() != None) { Some(Rc::new(InferredNode::Resolved { @@ -11238,7 +11276,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: inferred_ret, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: Some(Rc::new(val_typed.clone())), + body: Some(val_typed.clone()), connective: Connective::NoConnective, transport: typed_transport, properties: typed_properties, @@ -11256,8 +11294,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) - && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -11268,8 +11305,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11305,8 +11341,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let mut __result = Vec::new(); for c in item.children.clone().iter().cloned() { __result.push( - (*infer_item(c.clone(), scope.clone()).item) - .clone(), + infer_item(c.clone(), scope.clone()).item.clone(), ); } __result @@ -11501,13 +11536,13 @@ pub fn unify_record_lit_field_walk( .cloned() .fold(acc, |st: Rc>>, sf: Rc| { let field_name = - authored_name_at((*scope.type_env).clone().source_indices.clone(), sf.clone()); + authored_name_at(scope.type_env.clone().source_indices.clone(), sf.clone()); match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { if (field_init_node_name_at( fi.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == field_name.clone()) { __result.push(fi); @@ -11537,7 +11572,7 @@ pub fn unify_record_lit_field_walk( field_formal.clone(), resolved_type(actual_value.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), st.clone(), ) } @@ -11558,7 +11593,7 @@ pub fn unify_record_lit_generics( { let formal_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let is_generic_slot = { let mut __found = false; @@ -11575,7 +11610,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } else { @@ -11583,7 +11618,7 @@ pub fn unify_record_lit_generics( { let record_type_name = type_node_label( record.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((record_type_name.clone() != "".to_string()) && (formal_name.clone() == record_type_name.clone())) @@ -11603,7 +11638,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11613,7 +11648,7 @@ pub fn unify_record_lit_generics( formal.clone(), resolved_type(record.clone()), generic_names.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc, ) } @@ -11623,7 +11658,7 @@ pub fn unify_record_lit_generics( { let type_name = type_node_label( formal.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); unify_record_lit_field_walk( record_lit_expected_fields(Some(type_name), scope.clone()), @@ -11763,9 +11798,9 @@ pub fn deps_excluding_leaf_self( ) -> Rc> { { let deps0 = node_type_deps(b.resolved.clone(), source_indices); - let is_bare_self = (((((*b.resolved).clone().connective.clone() + let is_bare_self = ((((b.resolved.clone().connective.clone() == Connective::NoConnective) - && (((*b.resolved).clone().children.clone().len() as i64) == 0)) + && ((b.resolved.clone().children.clone().len() as i64) == 0)) && ((deps0.clone().len() as i64) == 1)) && { let mut __found = false; @@ -11832,6 +11867,14 @@ pub fn union_parent_type_env_caches( resolved_imports: Rc>>, parent_index: Rc>>, ) -> Rc { + if resolved_imports.len() == 1 { + if let Some(imp) = resolved_imports.first().cloned() { + if let Some(parent) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + return parent.type_env_cache.clone(); + } + } + return empty_type_env_cache(); + } resolved_imports.iter().cloned().fold( empty_type_env_cache(), |acc: Rc, imp: Rc| match v1_rt::map_get( @@ -11844,29 +11887,58 @@ pub fn union_parent_type_env_caches( ) } -pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { - match env.parents.clone().last().cloned() { - Some(kernel) => Rc::new({ - let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&kernel.bindings.clone())) - .iter() - .cloned() - .collect(); - __sorted.sort_by(|a: &Rc, b: &Rc| { - let __ka = (|b: Rc| b.name.clone())(a.clone()); - let __kb = (|b: Rc| b.name.clone())(b.clone()); - __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) - }); - __sorted - }) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - let is_coproduct = - ((*binding.resolved).clone().connective.clone() == Connective::Disj); - if is_coproduct.clone() { - (*binding.resolved) +pub fn union_parent_variant_locals( + resolved_imports: Rc>>, + parent_index: Rc>>, +) -> Rc>> { + resolved_imports.iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, imp: Rc| match v1_rt::map_get( + &parent_index, + imp.module_path.clone(), + ) { + Some(parent) => v1_rt::rc_map_merge( + acc.clone(), + parent.type_env_cache.clone().variant_locals.clone(), + ), + None => acc.clone(), + }, + ) +} + +pub fn fold_local_coproduct_variant_locals( + bindings: Rc>>, + imported_variants: Rc>, + source_indices: Rc>>, + init_locals: Rc>>, +) -> Rc { + Rc::new({ + let mut __sorted: Vec<_> = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .cloned() + .collect(); + __sorted.sort_by(|a: &Rc, b: &Rc| { + let __ka = (|b: Rc| b.name.clone())(a.clone()); + let __kb = (|b: Rc| b.name.clone())(b.clone()); + __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) + }); + __sorted + }) + .iter() + .cloned() + .fold( + Rc::new(VariantFoldState { + locals: init_locals, + collision_errors: Rc::new(vec![]), + }), + |acc: Rc, binding: Rc| { + let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); + if is_coproduct.clone() { + { + let binding_enum_name = + authored_name_at(source_indices.clone(), binding.resolved.clone()); + binding + .resolved .clone() .children .clone() @@ -11874,28 +11946,70 @@ pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>>, child: Rc| { + |vacc: Rc, child: Rc| { let child_name = - authored_name_at(env.source_indices.clone(), child.clone()); - match v1_rt::map_get(&vacc, child_name.clone()) { - Some(_prev) => vacc.clone(), - None => v1_rt::rc_map_insert( - vacc.clone(), - child_name.clone(), - Rc::new(TypeBinding { - name: child_name.clone(), - resolved: binding.resolved.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), + authored_name_at(source_indices.clone(), child.clone()); + let curr_child_is_imported = is_imported_variant_owned_by( + imported_variants.clone(), + child_name.clone(), + binding_enum_name.clone(), + ); + match v1_rt::map_get(&vacc.locals.clone(), child_name.clone()) { + Some(_prev) => { + if curr_child_is_imported.clone() { + Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }) + } else { + vacc.clone() + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + vacc.locals.clone(), + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: binding.resolved.clone(), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + collision_errors: vacc.collision_errors.clone(), + }), } }, ) - } else { - acc.clone() } - }, - ), + } else { + acc.clone() + } + }, + ) +} + +pub fn kernel_coproduct_variant_locals(env: Rc) -> Rc>> { + match env.parents.clone().last().cloned() { + Some(kernel) => fold_local_coproduct_variant_locals( + kernel.bindings.clone(), + v1_rt::rc_empty_map::(), + env.source_indices.clone(), + v1_rt::rc_empty_map::>(), + ) + .locals + .clone(), None => v1_rt::rc_empty_map::>(), } } @@ -11952,26 +12066,9 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), - |acc: Rc>>, name: String| { - if is_type_variable_name(name.clone()) { - acc.clone() - } else { - match v1_rt::map_get(&parent_env.str_bindings.clone(), name.clone()) { - Some(binding) => { - v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) - } - None => acc.clone(), - } - } - }, - ); - let filtered_ancestry = - Rc::new(v1_rt::map_keys(&parent_env.ancestry_str_bindings.clone())) + Rc::new(TypeEnv { + bindings: filtered, + str_bindings: Rc::new(v1_rt::map_keys(&parent_env.str_bindings.clone())) .iter() .cloned() .fold( @@ -11980,10 +12077,8 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc v1_rt::rc_map_insert( acc.clone(), name.clone(), @@ -11993,11 +12088,30 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc>(), + |acc: Rc>>, name: String| { + if is_type_variable_name(name.clone()) { + acc.clone() + } else { + match v1_rt::map_get( + &parent_env.ancestry_str_bindings.clone(), + name.clone(), + ) { + Some(binding) => { + v1_rt::rc_map_insert(acc.clone(), name.clone(), binding.clone()) + } + None => acc.clone(), + } + } + }, + ), parents: parent_env.parents.clone(), recursive_types: parent_env.recursive_types.clone(), recursive_type_set: parent_env.recursive_type_set.clone(), @@ -12011,257 +12125,270 @@ pub fn type_env_for_import(module_path: String, parent_env: Rc) -> Rc, - parent_index: Rc>>, +pub fn compiler_kernel_type_env( source_indices: Rc>>, intern_table: Rc, -) -> Rc { - { - let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let source_indices = Rc::new(vec![ - "Optional".to_string(), - "Present".to_string(), - "Absent".to_string(), - "value".to_string(), - "none".to_string(), - ]) +) -> Rc { + let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - source_indices.clone(), - |acc: Rc>>, name: String| { + v1_rt::rc_empty_map::>(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - build_newline_index( - v1_rt::concat( - v1_rt::concat("".to_string(), - ), - name.clone(), - ), - ) - }, - ); - let intern_table = seed_kernel_intern_table(intern_table.clone()); - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { + intern(intern_table.clone(), name.clone()).id.clone(), + Rc::new(TypeBinding { + name: name.clone(), + resolved: Rc::new(Node { name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: kernel_span(name.clone()), + ident_span: Some(kernel_span(name.clone())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ); + let unit_span = kernel_span("Unit".to_string()); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings_base, + intern(intern_table.clone(), "Unit".to_string()).id.clone(), + Rc::new(TypeBinding { + name: "Unit".to_string(), + resolved: Rc::new(Node { name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), + span: unit_span.clone(), + ident_span: Some(unit_span.clone()), + children: Rc::new(vec![]), + connective: Connective::Conj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let present_value_field = Rc::new(Node { + name: "value".to_string(), + span: kernel_span("value".to_string()), + ident_span: Some(kernel_span("value".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::TypeVariable { + id: "present_value".to_string(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let present_variant = Rc::new(Node { + name: "Present".to_string(), + span: kernel_span("Present".to_string()), + ident_span: Some(kernel_span("Present".to_string())), + children: Rc::new(vec![present_value_field]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let absent_variant = Rc::new(Node { + name: "Absent".to_string(), + span: kernel_span("Absent".to_string()), + ident_span: Some(kernel_span("Absent".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_optional = Rc::new(Node { + name: "Optional".to_string(), + span: kernel_span("Optional".to_string()), + ident_span: Some(kernel_span("Optional".to_string())), + children: Rc::new(vec![present_variant, absent_variant]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + intern(intern_table.clone(), "Optional".to_string()) + .id + .clone(), + Rc::new(TypeBinding { name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), + resolved: kernel_optional, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); + let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); + let kernel_recursive_types = Rc::new({ + let mut __result = Vec::new(); + for name in v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let kernel_recursive_type_set = v1_rt::sorted_map_keys(&compiler_recursive_types()) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + Rc::new(TypeEnv { + bindings: kernel_bindings.clone(), + str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), + ancestry_str_bindings: v1_rt::rc_empty_map::>(), + parents: Rc::new(vec![]), + recursive_types: kernel_recursive_types, + recursive_type_set: kernel_recursive_type_set, + inductive_fields: node_fields, + source_indices: source_indices.clone(), + intern_table: intern_table.clone(), + }) +} + +pub fn build_type_env( + module: Rc, + parent_index: Rc>>, + source_indices: Rc>>, + intern_table: Rc, +) -> Rc { + record_build_type_env_call(); + { + let source_indices = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + source_indices.clone(), + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), ) }, ); - let kernel = Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices.clone(), - intern_table: intern_table.clone(), - }); + let source_indices = Rc::new(vec![ + "Optional".to_string(), + "Present".to_string(), + "Absent".to_string(), + "value".to_string(), + "none".to_string(), + ]) + .iter() + .cloned() + .fold( + source_indices.clone(), + |acc: Rc>>, name: String| { + v1_rt::rc_map_insert( + acc, + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + build_newline_index( + v1_rt::concat( + v1_rt::concat("".to_string(), + ), + name.clone(), + ), + ) + }, + ); + let intern_table = seed_kernel_intern_table(intern_table.clone()); + let kernel = compiler_kernel_type_env(source_indices.clone(), intern_table.clone()); + let kernel_cache = type_env_cache_from_bindings( + kernel.bindings.clone(), + source_indices.clone(), + compiler_recursive_name_set(), + ); let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let import_parents = Rc::new({ let mut __result = Vec::new(); @@ -12280,7 +12407,7 @@ pub fn build_type_env( } __result }); - let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel])); + let scope_parents = v1_rt::concat(import_parents, Rc::new(vec![kernel.clone()])); let import_diags = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12531,15 +12658,10 @@ pub fn build_type_env( }, ); let all_local_bindings = v1_rt::rc_map_merge(local_bindings.clone(), param_bindings); - let kernel_cache = type_env_cache_from_bindings( - kernel_bindings.clone(), - source_indices.clone(), - compiler_recursive_name_set(), - ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -12580,25 +12702,22 @@ pub fn build_type_env( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); - } - __result - }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { + __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + } + __result + }); + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { @@ -12609,24 +12728,26 @@ pub fn build_type_env( cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -12650,7 +12771,7 @@ pub fn build_type_env( local_name_set, all_deps_map.clone(), ); - let resolved_env_out = (*resolved.env).clone(); + let resolved_env_out = resolved.env.clone(); let resolved_diags = resolved.diagnostics.clone(); let final_env = Rc::new(TypeEnv { bindings: resolved_env_out.bindings.clone(), @@ -12683,6 +12804,7 @@ pub fn build_type_env_unresolved( source_indices: Rc>>, intern_table: Rc, ) -> Rc { + record_build_type_env_call(); { let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() @@ -12987,8 +13109,8 @@ pub fn build_type_env_unresolved( ); let import_cache = union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache + let ancestry_cache = if module.resolved_imports.clone().len() == 1 { + import_cache.clone() } else { merge_type_env_cache(import_cache, kernel_cache) }; @@ -13029,25 +13151,22 @@ pub fn build_type_env_unresolved( ); let cycle_set = Rc::new({ let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&cycle_set_str)).iter().cloned() { + for name in v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned() { __result.push(intern(intern_table.clone(), name.clone()).id.clone()); } __result }); - let cross_type_set = Rc::new(v1_rt::map_keys(&cycle_set_str)) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - let cycle_set_for_inductive = Rc::new(v1_rt::map_keys(&cycle_set_str)) + let cross_type_set = v1_rt::sorted_map_keys(&cycle_set_str).iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + v1_rt::rc_map_insert( + acc, + intern(intern_table.clone(), name.clone()).id.clone(), + true, + ) + }, + ); + let cycle_set_for_inductive = v1_rt::sorted_map_keys(&cycle_set_str) .iter() .cloned() .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { @@ -13058,24 +13177,26 @@ pub fn build_type_env_unresolved( cycle_set_for_inductive, source_indices.clone(), ); - let parent_inductive_fields = scope_parents.clone().iter().cloned().fold( + let import_inductive_fields = scope_parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, parent: Rc| { merge_inductive_fields(acc, parent.inductive_fields.clone()) }, ); let merged_inductive_fields = - merge_inductive_fields(parent_inductive_fields, local_inductive_fields); - let ancestry_str_bindings = if ((module.resolved_imports.clone().len() as i64) == 1) { - match module.resolved_imports.clone().first().cloned() { - Some(imp) => match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(parent_mod) => v1_rt::rc_map_merge( - (*parent_mod.type_env).clone().ancestry_str_bindings.clone(), - (*parent_mod.type_env).clone().str_bindings.clone(), - ), - None => ancestry_cache.str_bindings.clone(), - }, - None => ancestry_cache.str_bindings.clone(), + merge_inductive_fields(import_inductive_fields, local_inductive_fields); + let ancestry_str_bindings = if module.resolved_imports.clone().len() == 1 { + if let Some(imp) = module.resolved_imports.clone().first().cloned() { + if let Some(parent_mod) = v1_rt::map_get(&parent_index, imp.module_path.clone()) { + v1_rt::rc_map_merge( + parent_mod.type_env.ancestry_str_bindings.clone(), + parent_mod.type_env.str_bindings.clone(), + ) + } else { + ancestry_cache.str_bindings.clone() + } + } else { + ancestry_cache.str_bindings.clone() } } else { ancestry_cache.str_bindings.clone() @@ -13191,7 +13312,7 @@ pub fn build_item_info( pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); - let ritem = (*resolved.item).clone(); + let ritem = resolved.item.clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) && (ritem.inferred.clone() != None)) @@ -13199,12 +13320,12 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let func_sig = if (is_func || is_zero_arg_func) { { let declared_rt = if (ritem.inferred.clone() != None) { - Some(resolved_type(Rc::new(ritem.clone()))) + Some(resolved_type(ritem.clone())) } else { None }; Some(Rc::new(DeclaredFuncSig { - name: authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), + name: authored_name_at(env.source_indices.clone(), ritem.clone()), params: ritem.params.clone(), inferred: declared_rt, is_async: ((ritem.uses.clone().len() as i64) > 0), @@ -13218,512 +13339,324 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc } else { None }; - let svc_entries = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(service_op_entry(c.clone(), env.source_indices.clone())); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = if ((ritem.transport.clone() != None) - && ((ritem.children.clone().len() as i64) > 0)) - { - { - let root = namespace_root_from_properties( - ritem.properties.clone(), - authored_name_at(env.source_indices.clone(), Rc::new(ritem.clone())), - env.source_indices.clone(), - ); - Some(nominal_type_binding(root)) - } - } else { - None - }; - Rc::new(ItemContribution { - resolved_item: Rc::new(ritem.clone()), - resolve_diagnostics: resolved.diagnostics.clone(), - func_sig: func_sig, - svc_entries: svc_entries, - svc_local: svc_local, - item_info: build_item_info( - Rc::new(ritem.clone()), - env.source_indices.clone(), - module_name.clone(), - ), - }) - } -} - -pub fn fold_module_contributions( - mut remaining: Rc>>, - mut resolved_items: Rc>>, - mut func_sigs: Rc>>, - mut svc_registry: Rc>>>>, - mut svc_locals: Rc>>, - mut item_registry: Rc>>, - mut diag_chunks: Rc>>>>, - mut source_indices: Rc>>, -) -> Rc { - loop { - match remaining.clone().first().cloned() { - None => { - break Rc::new(LocalContributionState { - resolved_items: resolved_items, - func_sigs: func_sigs, - svc_registry: svc_registry, - svc_locals: svc_locals, - item_registry: item_registry, - diag_chunks: diag_chunks, - }); - } - Some(contribution) => { - let next_func_sigs = match contribution.func_sig.clone() { - Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), - None => func_sigs, - }; - let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { - v1_rt::rc_map_insert( - svc_registry, - authored_name_at( - source_indices.clone(), - contribution.resolved_item.clone(), - ), - contribution.svc_entries.clone(), - ) - } else { - svc_registry - }; - let next_svc_locals = match contribution.svc_local.clone() { - Some(binding) => { - v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) - } - None => svc_locals, - }; - { - let __tco_0 = Rc::new( - remaining - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ); - let __tco_1 = - v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); - let __tco_2 = next_func_sigs; - let __tco_3 = next_svc_registry; - let __tco_4 = next_svc_locals; - let __tco_5 = v1_rt::rc_map_insert( - item_registry, - contribution.item_info.clone().name.clone(), - contribution.item_info.clone(), - ); - let __tco_6 = - v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); - remaining = __tco_0; - resolved_items = __tco_1; - func_sigs = __tco_2; - svc_registry = __tco_3; - svc_locals = __tco_4; - item_registry = __tco_5; - diag_chunks = __tco_6; - continue; - } - } - } - } -} - -pub fn constructor_binding_authority() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): a module's constructor namespace is FLAT — its own coproduct declarations plus its DIRECT imports' contributions, never transitive ancestry. Each arm name binds to its owning coproduct NODE (the binding edge carries the owner; no name re-lookup, so the owner need not be name-visible). One arm name bound to two DIFFERENT owners in one file = VariantCollision at env construction (the per-file wall); the same declaration reached via two import paths is one owner, not a collision. Kernel coproduct arms (Optional/Witness/...) merge low-priority afterwards, prelude semantics.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn insert_variant_owner_checked( - state: Rc, - arm_name: String, - owner: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { - Some(prev) => { - let prev_name = authored_name_at(source_indices.clone(), prev.resolved.clone()); - let owner_name = authored_name_at(source_indices.clone(), owner.clone()); - let same_owner = (((prev_name.clone() == owner_name.clone()) - && ((*prev.resolved).clone().span.clone().file.clone() - == owner.span.clone().file.clone())) - && ((*prev.resolved).clone().span.clone().start.clone() - == owner.span.clone().start.clone())); - if same_owner { - state.clone() - } else { - Rc::new(VariantFoldState { - locals: state.locals.clone(), - collision_errors: v1_rt::concat( - state.collision_errors.clone(), - Rc::new(vec![make_error_node( - Rc::new(CompilerDiagnostic::VariantCollision { - variant: arm_name.clone(), - enum1: prev_name.clone(), - enum2: owner_name.clone(), - span: owner.span.clone(), - }), - module_name, - )]), - ), - }) - } - } - None => Rc::new(VariantFoldState { - locals: v1_rt::rc_map_insert( - state.locals.clone(), - arm_name.clone(), - Rc::new(TypeBinding { - name: arm_name.clone(), - resolved: owner.clone(), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ), - collision_errors: state.collision_errors.clone(), - }), - } -} - -pub fn bind_coproduct_item_arms( - state: Rc, - item: Rc, - source_indices: Rc>>, - module_name: String, -) -> Rc { - item.children.clone().iter().cloned().fold( - state, - |vacc: Rc, child: Rc| { - insert_variant_owner_checked( - vacc, - authored_name_at(source_indices.clone(), child.clone()), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - }, - ) -} - -pub fn build_local_variants( - items: Rc>>, - source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { - items - .iter() - .cloned() - .fold(init, |acc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - acc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - acc.clone() - } - }) -} - -pub fn reexport_chain_authority() -> String { - thread_local! { - static CACHED: String = { - "A module re-exports its specific-name imports (get_exported_names in v1.compiler.resolve), so `import proxy { B }` where proxy itself imports B is an EXPLICIT import under the §1c ruling — the binder follows the specific-name chain to the defining module's coproduct (the import DAG is acyclic, so the recursion terminates; a chain hop that dead-ends binds nothing and the use site fails closed as UnresolvedType). Glob (is_all) imports bind the target's OWN coproduct arms only — glob re-export pass-through is not modeled here, matching get_exported_names which excludes is_all imports from the export surface.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn owner_of_exported_arm( - mut module_path: String, - mut arm_name: String, - mut parent_index: Rc>>, - mut source_indices: Rc>>, -) -> Option> { - loop { - match v1_rt::map_get(&parent_index, module_path) { - None => { - break None; - } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for c in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()) - == arm_name.clone()) - { - __found = true; - break; - } - } - __found - } { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); - } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == arm_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } - } + let svc_entries = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(service_op_entry(c.clone(), env.source_indices.clone())); } + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = + if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { + { + let root = namespace_root_from_properties( + ritem.properties.clone(), + authored_name_at(env.source_indices.clone(), ritem.clone()), + env.source_indices.clone(), + ); + Some(nominal_type_binding(root)) } - } - } + } else { + None + }; + Rc::new(ItemContribution { + resolved_item: ritem.clone(), + resolve_diagnostics: resolved.diagnostics.clone(), + func_sig: func_sig, + svc_entries: svc_entries, + svc_local: svc_local, + item_info: build_item_info( + ritem.clone(), + env.source_indices.clone(), + module_name.clone(), + ), + }) } } -pub fn exported_coproduct_item( - mut module_path: String, - mut enum_name: String, - mut parent_index: Rc>>, +pub fn fold_module_contributions( + mut remaining: Rc>>, + mut resolved_items: Rc>>, + mut func_sigs: Rc>>, + mut svc_registry: Rc>>>>, + mut svc_locals: Rc>>, + mut item_registry: Rc>>, + mut diag_chunks: Rc>>>>, mut source_indices: Rc>>, -) -> Option> { +) -> Rc { loop { - match v1_rt::map_get(&parent_index, module_path) { + match remaining.clone().first().cloned() { None => { - break None; + break Rc::new(LocalContributionState { + resolved_items: resolved_items, + func_sigs: func_sigs, + svc_registry: svc_registry, + svc_locals: svc_locals, + item_registry: item_registry, + diag_chunks: diag_chunks, + }); } - Some(tm) => { - let own = Rc::new({ - let mut __result = Vec::new(); - for item in Rc::new({ - let mut __result = Vec::new(); - for item in tm.items.clone().iter().cloned() { - if (item.connective.clone() == Connective::Disj) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - { - if (authored_name_at(source_indices.clone(), item.clone()) - == enum_name.clone()) - { - __result.push(item); - } - } - __result - }) - .first() - .cloned(); - match own { - Some(item) => { - break Some(item.clone()); + Some(contribution) => { + let next_func_sigs = match contribution.func_sig.clone() { + Some(sig) => v1_rt::rc_map_insert(func_sigs, sig.name.clone(), sig.clone()), + None => func_sigs, + }; + let next_svc_registry = if ((contribution.svc_entries.clone().len() as i64) > 0) { + v1_rt::rc_map_insert( + svc_registry, + authored_name_at( + source_indices.clone(), + contribution.resolved_item.clone(), + ), + contribution.svc_entries.clone(), + ) + } else { + svc_registry + }; + let next_svc_locals = match contribution.svc_local.clone() { + Some(binding) => { + v1_rt::rc_map_insert(svc_locals, binding.name.clone(), binding.clone()) } - None => { - let reexport = Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { - if !import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) + None => svc_locals, + }; + { + let __tco_0 = Rc::new( + remaining .iter() .cloned() - { - if { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone() == enum_name.clone()) { - __found = true; - break; - } - } - __found - } { - __result.push(imp); - } - } - __result - }) - .first() - .cloned(); - match reexport { - Some(imp) => { - let __tco_0 = authored_name_at(source_indices.clone(), imp.clone()); - module_path = __tco_0; - continue; - } - None => { - break None; - } + .skip(1 as usize) + .collect::>(), + ); + let __tco_1 = + v1_rt::rc_list_push(resolved_items, contribution.resolved_item.clone()); + let __tco_2 = next_func_sigs; + let __tco_3 = next_svc_registry; + let __tco_4 = next_svc_locals; + let __tco_5 = v1_rt::rc_map_insert( + item_registry, + contribution.item_info.clone().name.clone(), + contribution.item_info.clone(), + ); + let __tco_6 = + v1_rt::rc_list_push(diag_chunks, contribution.resolve_diagnostics.clone()); + remaining = __tco_0; + resolved_items = __tco_1; + func_sigs = __tco_2; + svc_registry = __tco_3; + svc_locals = __tco_4; + item_registry = __tco_5; + diag_chunks = __tco_6; + continue; + } + } + } + } +} + +pub fn enum_parents_for_variant_in_items( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (item.connective.clone() == Connective::Disj) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + { + if { + let mut __found = false; + for child in item.children.clone().iter().cloned() { + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) + { + __found = true; + break; } } + __found + } { + __result.push(item); } } + __result + }) + .iter() + .cloned() + { + __result.push(authored_name_at(source_indices.clone(), item.clone())); + } + __result + }) +} + +pub fn unique_imported_variant_owner( + variant_name: String, + items: Rc>>, + source_indices: Rc>>, +) -> Option { + { + let parents = enum_parents_for_variant_in_items(variant_name, items, source_indices); + if ((parents.clone().len() as i64) == 1) { + parents.clone().first().cloned() + } else { + None } } } +pub fn is_imported_variant_owned_by( + imported_variants: Rc>, + variant_name: String, + enum_name: String, +) -> bool { + match v1_rt::map_get(&imported_variants, variant_name) { + Some(unique_parent) => (unique_parent.clone() == enum_name), + None => false, + } +} + pub fn build_imported_variants( resolved_imports: Rc>>, parent_index: Rc>>, source_indices: Rc>>, - module_name: String, - init: Rc, -) -> Rc { +) -> Rc> { resolved_imports.iter().cloned().fold( - init, - |acc: Rc, imp: Rc| { - let with_glob = if imp.is_all.clone() { - { - let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) - { - Some(parent_tm) => parent_tm.items.clone(), - None => Rc::new(vec![]), - }; - source_items.clone().iter().cloned().fold( - acc.clone(), - |iacc: Rc, item: Rc| { - let item_is_coproduct = (item.connective.clone() == Connective::Disj); - if item_is_coproduct.clone() { - bind_coproduct_item_arms( - iacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), - ) - } else { - iacc.clone() - } - }, - ) - } - } else { - acc.clone() - }; + v1_rt::rc_empty_map::(), + |acc: Rc>, imp: Rc| { imp.specific_names.clone().iter().cloned().fold( - with_glob.clone(), - |nacc: Rc, name: String| { - let after_enum = match exported_coproduct_item( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(item) => bind_coproduct_item_arms( - nacc.clone(), - item.clone(), - source_indices.clone(), - module_name.clone(), + acc, + |inner: Rc>, variant_name: String| { + if v1_rt::map_contains_key(&inner, variant_name.clone()) { + inner.clone() + } else { + { + let source_items = + match v1_rt::map_get(&parent_index, imp.module_path.clone()) { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + match unique_imported_variant_owner( + variant_name.clone(), + source_items.clone(), + source_indices.clone(), + ) { + Some(parent) => v1_rt::rc_map_insert( + inner.clone(), + variant_name.clone(), + parent.clone(), + ), + None => inner.clone(), + } + } + } + }, + ) + }, + ) +} + +// HAND-PATCH (constructor-owner ruling §1c; seed two-step): re-export chain +// followers — a module re-exports its specific-name imports, so the binder +// walks the acyclic import chain to the defining module's coproduct. Replaced +// by regen's true emission in the convergence commit. +pub fn owner_of_exported_arm( + module_path: String, + arm_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && item + .children + .iter() + .cloned() + .any(|c| authored_name_at(source_indices.clone(), c) == arm_name) + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == arm_name) + }); + match reexport { + Some(imp) => owner_of_exported_arm( + authored_name_at(source_indices.clone(), imp), + arm_name, + parent_index, + source_indices, ), - None => nacc.clone(), - }; - match owner_of_exported_arm( - imp.module_path.clone(), - name.clone(), - parent_index.clone(), - source_indices.clone(), - ) { - Some(owner) => insert_variant_owner_checked( - after_enum.clone(), - name.clone(), - owner.clone(), - source_indices.clone(), - module_name.clone(), + None => None, + } + } + } + } + } +} + +pub fn exported_coproduct_item( + module_path: String, + enum_name: String, + parent_index: Rc>>, + source_indices: Rc>>, +) -> Option> { + match v1_rt::map_get(&parent_index, module_path) { + None => None, + Some(tm) => { + let own = tm.items.iter().cloned().find(|item| { + item.connective.clone() == Connective::Disj + && authored_name_at(source_indices.clone(), item.clone()) == enum_name + }); + match own { + Some(item) => Some(item), + None => { + let reexport = module_imports(tm.module.clone()) + .iter() + .cloned() + .find(|imp| { + !import_is_all(imp.clone()) + && import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .any(|n| *n == enum_name) + }); + match reexport { + Some(imp) => exported_coproduct_item( + authored_name_at(source_indices.clone(), imp), + enum_name, + parent_index, + source_indices, ), - None => after_enum.clone(), + None => None, } - }, - ) - }, - ) + } + } + } + } } pub fn build_module_context( @@ -13744,21 +13677,134 @@ pub fn build_module_context( Rc::new(vec![]), env.source_indices.clone(), ); - let local_variant_fold = build_local_variants( - local.resolved_items.clone(), - env.source_indices.clone(), - module_name.clone(), + // HAND-PATCH (constructor-owner ruling §1c; seed two-step): functional + // realization of the new v1.compiler.infer dag source — replaced + // wholesale by regen output in the convergence commit. Constructor + // namespace is FLAT: local coproduct arms + direct imports' + // contributions; the binding carries the owner NODE; one arm name + // bound to two different owners = VariantCollision (per-file wall). + let insert_variant_owner_checked = |state: Rc, + arm_name: String, + owner: Rc| + -> Rc { + match v1_rt::map_get(&state.locals.clone(), arm_name.clone()) { + Some(prev) => { + let prev_name = + authored_name_at(env.source_indices.clone(), prev.resolved.clone()); + let owner_name = authored_name_at(env.source_indices.clone(), owner.clone()); + let same_owner = prev_name == owner_name + && prev.resolved.span.file == owner.span.file + && prev.resolved.span.start == owner.span.start; + if same_owner { + state + } else { + Rc::new(VariantFoldState { + locals: state.locals.clone(), + collision_errors: v1_rt::concat( + state.collision_errors.clone(), + Rc::new(vec![make_error_node( + Rc::new(CompilerDiagnostic::VariantCollision { + variant: arm_name, + enum1: prev_name, + enum2: owner_name, + span: owner.span.clone(), + }), + module_name.clone(), + )]), + ), + }) + } + } + None => Rc::new(VariantFoldState { + locals: v1_rt::rc_map_insert( + state.locals.clone(), + arm_name.clone(), + Rc::new(TypeBinding { + name: arm_name, + resolved: owner, + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ), + collision_errors: state.collision_errors.clone(), + }), + } + }; + let bind_coproduct_item_arms = + |state: Rc, item: Rc| -> Rc { + item.children + .clone() + .iter() + .cloned() + .fold(state, |vacc, child| { + insert_variant_owner_checked( + vacc, + authored_name_at(env.source_indices.clone(), child.clone()), + item.clone(), + ) + }) + }; + let local_variant_fold = local.resolved_items.clone().iter().cloned().fold( Rc::new(VariantFoldState { locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), + |acc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(acc, item) + } else { + acc + } + }, ); - let variant_fold = build_imported_variants( - resolved_imports.clone(), - parent_index.clone(), - env.source_indices.clone(), - module_name.clone(), + let variant_fold = resolved_imports.clone().iter().cloned().fold( local_variant_fold, + |acc: Rc, imp: Rc| { + // Glob (is_all) imports bind the target's OWN coproduct arms only. + let with_glob = if imp.is_all { + let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) + { + Some(parent_tm) => parent_tm.items.clone(), + None => Rc::new(vec![]), + }; + source_items.iter().cloned().fold( + acc, + |iacc: Rc, item: Rc| { + if item.connective.clone() == Connective::Disj { + bind_coproduct_item_arms(iacc, item) + } else { + iacc + } + }, + ) + } else { + acc + }; + // Specific names resolve through the re-export chain to the + // defining module (owner_of_exported_arm / exported_coproduct_item). + imp.specific_names.iter().cloned().fold( + with_glob, + |nacc: Rc, name: String| { + let after_enum = match exported_coproduct_item( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(item) => bind_coproduct_item_arms(nacc, item), + None => nacc, + }; + match owner_of_exported_arm( + imp.module_path.clone(), + name.clone(), + parent_index.clone(), + env.source_indices.clone(), + ) { + Some(owner) => insert_variant_owner_checked(after_enum, name, owner), + None => after_enum, + } + }, + ) + }, ); let variant_collision_errors = variant_fold.collision_errors.clone(); let env_variant_locals = @@ -13775,7 +13821,7 @@ pub fn build_module_context( for imp in resolved_imports.clone().iter().cloned() { __result.extend( (*match v1_rt::map_get(&parent_index, imp.module_path.clone()) { - Some(typed_parent) => Rc::new(vec![(*typed_parent.func_env).clone()]), + Some(typed_parent) => Rc::new(vec![typed_parent.func_env.clone()]), None => Rc::new(vec![]), }) .iter() @@ -13788,7 +13834,7 @@ pub fn build_module_context( local.func_sigs.clone(), parent_envs, local.resolved_items.clone(), - module_name.clone(), + module_name, env.source_indices.clone(), ); let all_locals = Rc::new(v1_rt::map_values(&merged_scope.svc_locals.clone())) @@ -13843,7 +13889,7 @@ pub fn typecheck_module( source_indices.clone(), intern_table, ); - let env = (*env_result.env).clone(); + let env = env_result.env.clone(); let env_cache = env_result.cache.clone(); let env_diags = env_result.diagnostics.clone(); let env_errors = Rc::new({ @@ -13861,7 +13907,7 @@ pub fn typecheck_module( typed: Rc::new(TypedModule { module: resolved.module.clone(), items: Rc::new(vec![]), - type_env: Rc::new(env.clone()), + type_env: env.clone(), type_env_cache: env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { local: v1_rt::rc_empty_map::>(), @@ -13879,7 +13925,7 @@ pub fn typecheck_module( for item in module_items(resolved.module.clone()).iter().cloned() { __result.push(analyze_item( item.clone(), - Rc::new(env.clone()), + env.clone(), resolved_module_name.clone(), )); } @@ -13889,7 +13935,7 @@ pub fn typecheck_module( contributions, parent_index.clone(), resolved.resolved_imports.clone(), - Rc::new(env.clone()), + env.clone(), resolved_module_name.clone(), ); let data_locals = ctx.resolved_items.clone().iter().cloned().fold( @@ -13914,7 +13960,7 @@ pub fn typecheck_module( }, ); let infer_scope = Rc::new(InferScope { - type_env: Rc::new(env.clone()), + type_env: env.clone(), func_env: ctx.func_env.clone(), locals: data_locals.clone(), match_bound_names: v1_rt::rc_empty_map::(), @@ -13927,7 +13973,7 @@ pub fn typecheck_module( let typed_items = Rc::new({ let mut __result = Vec::new(); for tir in typed_item_results.clone().iter().cloned() { - __result.push((*tir.item).clone()); + __result.push(tir.item.clone()); } __result }); @@ -13938,9 +13984,9 @@ pub fn typecheck_module( } __result }); - let updated_func_env = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(populate_output_provenance))))))))))))))))))))))))))))))( + let updated_func_env = populate_output_provenance( typed_items.clone(), - (*ctx.func_env).clone(), + ctx.func_env.clone(), env.clone(), data_locals.clone(), ); @@ -13960,9 +14006,9 @@ pub fn typecheck_module( uses: item.uses.clone(), body: Some(annotate_descent_evidence( item.body.clone().clone().unwrap(), - authored_name_at(source_indices.clone(), Rc::new(item.clone())), + authored_name_at(source_indices.clone(), item.clone()), item.params.clone(), - Rc::new(env.clone()), + env.clone(), data_locals.clone(), updated_func_env.clone(), )), @@ -13977,7 +14023,7 @@ pub fn typecheck_module( ident: None, }) } else { - Rc::new(item.clone()) + item.clone() }, ); } @@ -13987,17 +14033,17 @@ pub fn typecheck_module( resolved_module_name.clone(), module_imports(resolved.module.clone()), ctx.resolved_items.clone(), - (*resolved.module).clone().span.clone(), + resolved.module.clone().span.clone(), ); let typed_module = Rc::new(Node { - ident_span: (*resolved.module).clone().ident_span.clone(), + ident_span: resolved.module.clone().ident_span.clone(), ..(*typed_base).clone() }); Rc::new(TypecheckModuleResult { typed: Rc::new(TypedModule { module: typed_module, items: reannotated_items, - type_env: Rc::new(env.clone()), + type_env: env.clone(), type_env_cache: Rc::new(TypeEnvCache { deps_map: env_cache.deps_map.clone(), str_bindings: env_cache.str_bindings.clone(), @@ -14141,12 +14187,12 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); + let pre = binding.resolved.clone(); let result = - resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))))))))))))))))))( + resolve_node(pre.clone(), env.clone(), module_name.clone()); + let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14164,7 +14210,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14205,11 +14251,11 @@ pub fn topo_resolve_types( let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { - let pre = (*binding.resolved).clone(); - let result = resolve_node(Rc::new(pre.clone()), env.clone(), module_name.clone()); - let resolved = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(preserve_nominal_brand_on_resolve))))))))))))))))))))))))))))))( + let pre = binding.resolved.clone(); + let result = resolve_node(pre.clone(), env.clone(), module_name.clone()); + let resolved = preserve_nominal_brand_on_resolve( pre.clone(), - (*result.resolved).clone(), + result.resolved.clone(), binding.name.clone(), env.source_indices.clone(), ); @@ -14227,7 +14273,7 @@ pub fn topo_resolve_types( str_bindings: v1_rt::rc_map_insert( acc.str_bindings.clone(), name.clone(), - updated_binding.clone(), + updated_binding, ), diagnostics: v1_rt::concat( acc.diagnostics.clone(), @@ -14359,7 +14405,7 @@ pub fn build_fielded_variants( v1_rt::rc_empty_set::<_>(), |acc: _, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items .clone() .iter() @@ -14424,7 +14470,7 @@ pub fn build_positional_payload_variants( v1_rt::rc_empty_set::(), |acc: Rc>, m: Rc| { let items = m.items.clone(); - let si = (*m.type_env).clone().source_indices.clone(); + let si = m.type_env.clone().source_indices.clone(); items.clone().iter().cloned().fold( acc, |inner: Rc>, item: Rc| { @@ -14479,11 +14525,9 @@ pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { for m in modules.iter().cloned() { if { let mut __found = false; - for k in Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().source_indices.clone(), - )) - .iter() - .cloned() + for k in Rc::new(v1_rt::map_keys(&m.type_env.clone().source_indices.clone())) + .iter() + .cloned() { if (v1_rt::contains(k.clone(), "/v1/".to_string()) || v1_rt::contains(k.clone(), "src/v1".to_string())) @@ -14522,7 +14566,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), |acc: _, m: Rc| { Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().recursive_type_set.clone(), + &m.type_env.clone().recursive_type_set.clone(), )) .iter() .cloned() .fold(acc, |inner: _, ident: i64| { v1_rt::rc_set_insert( inner, - intern_str((*m.type_env).clone().intern_table.clone(), ident.clone()), + intern_str(m.type_env.clone().intern_table.clone(), ident.clone()), ) }) }, @@ -14562,8 +14606,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, @@ -14681,490 +14723,192 @@ pub fn typecheck_modules( v1_rt::rc_list_push(diag_chunks, parent_result.diagnostics.clone()), tc_diags, ); - remaining = __tco_0; - modules = __tco_1; - module_index = __tco_2; - item_registry = __tco_3; - diag_chunks = __tco_4; - continue; - } - } - } - } -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct StrBindingsRewireAccum { - pub str_bindings: Rc>>, - pub ancestry_str_bindings: Rc>>, -} - -pub fn import_module_path_at( - imp: Rc, - source_indices: Rc>>, -) -> String { - authored_name_at(source_indices, imp) -} - -pub fn local_authority_binding(owner: Rc, name: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values( - &(*owner.type_env).clone().bindings.clone(), - )) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .first() - .cloned() - { - Some(binding) => Some(binding.clone()), - None => None, - } -} - -pub fn global_type_exporter_count(modules: Rc>>, name: String) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if module_exports_type_name(m.clone(), name.clone()) { - __result.push(m); - } - } - __result - }) - .len() as i64) -} - -pub fn local_authority_for_name_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: single-exporter rewire canonical picks last TypedModule in compilation list (filter then last); multi-exporter names skip rewire and defer to merge_type_env_cache overlay-wins — ground on import-order authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn local_authority_for_name( - modules: Rc>>, - name: String, -) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for m in modules.iter().cloned() { - if ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) - { - __result.push(m); - } - } - __result - }) - .last() - .cloned() - { - Some(owner) => Some(owner.clone()), - None => None, - } -} - -pub fn module_exports_type_name(m: Rc, name: String) -> bool { - ((Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - { - if (b.name.clone() == name.clone()) { - __result.push(b); - } - } - __result - }) - .len() as i64) - > 0) -} - -pub fn direct_import_exporter_count( - m: Rc, - name: String, - index: Rc>>, - source_indices: Rc>>, -) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(m.module.clone()).iter().cloned() { - if { - let path = import_module_path_at(imp.clone(), source_indices.clone()); - match v1_rt::map_get(&index, path.clone()) { - Some(parent) => module_exports_type_name(parent.clone(), name.clone()), - None => false, - } - } { - __result.push(imp); - } - } - __result - }) - .len() as i64) -} - -pub fn rewire_inherited_str_binding( - modules: Rc>>, - module_index: Rc>>, - consumer: Rc, - source_indices: Rc>>, - local_names: Rc>, - str_bindings: Rc>>, - ancestry_str_bindings: Rc>>, - name: String, -) -> Rc { - if ((v1_rt::set_contains(&local_names, name.clone()) - || (direct_import_exporter_count(consumer, name.clone(), module_index, source_indices) - > 1)) - || (global_type_exporter_count(modules.clone(), name.clone()) > 1)) - { - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } else { - match local_authority_for_name(modules.clone(), name.clone()) { - Some(owner) => match local_authority_binding(owner.clone(), name.clone()) { - Some(canonical) => { - let ancestry_str_bindings = v1_rt::rc_map_insert( - ancestry_str_bindings.clone(), - name.clone(), - canonical.clone(), - ); - let str_bindings = match v1_rt::map_get(&str_bindings, name.clone()) { - Some(_) => v1_rt::rc_map_insert( - str_bindings.clone(), - name.clone(), - canonical.clone(), - ), - None => str_bindings.clone(), - }; - Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }) - } - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - }, - None => Rc::new(StrBindingsRewireAccum { - str_bindings: str_bindings.clone(), - ancestry_str_bindings: ancestry_str_bindings.clone(), - }), - } - } -} - -pub fn rewire_type_env_import_str_binding_identity( - modules: Rc>>, - source_indices: Rc>>, -) -> Rc>> { - { - let index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { - v1_rt::rc_map_insert( - acc, - authored_name_at(source_indices.clone(), m.module.clone()), - m.clone(), - ) - }, - ); - Rc::new({ - let mut __result = Vec::new(); - for m in modules.clone().iter().cloned() { - __result.push({ - let local_names = - Rc::new(v1_rt::map_values(&(*m.type_env).clone().bindings.clone())) - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, b: Rc| { - v1_rt::rc_set_insert(acc, b.name.clone()) - }); - let ancestry_keys = Rc::new(v1_rt::map_keys( - &(*m.type_env).clone().ancestry_str_bindings.clone(), - )); - let str_keys = - Rc::new(v1_rt::map_keys(&(*m.type_env).clone().str_bindings.clone())); - let inherited_keys = v1_rt::concat(ancestry_keys.clone(), str_keys.clone()); - let rewired = inherited_keys.clone().iter().cloned().fold( - Rc::new(StrBindingsRewireAccum { - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - }), - |acc: Rc, name: String| { - rewire_inherited_str_binding( - modules.clone(), - index.clone(), - m.clone(), - source_indices.clone(), - local_names.clone(), - acc.str_bindings.clone(), - acc.ancestry_str_bindings.clone(), - name.clone(), - ) - }, - ); - Rc::new(TypedModule { - module: m.module.clone(), - items: m.items.clone(), - type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: rewired.str_bindings.clone(), - ancestry_str_bindings: rewired.ancestry_str_bindings.clone(), - parents: (*m.type_env).clone().parents.clone(), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), - }), - type_env_cache: m.type_env_cache.clone(), - func_env: m.func_env.clone(), - item_registry: m.item_registry.clone(), - }) - }); + remaining = __tco_0; + modules = __tco_1; + module_index = __tco_2; + item_registry = __tco_3; + diag_chunks = __tco_4; + continue; + } } - __result - }) + } } } -pub fn compiler_kernel_type_env( +pub fn import_module_path_at( + imp: Rc, source_indices: Rc>>, - intern_table: Rc, -) -> Rc { - { - let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) +) -> String { + authored_name_at(source_indices, imp) +} + +pub fn rewire_type_env_import_str_binding_identity( + modules: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + record_rewire_type_env_import_str_binding_call(); + fn local_authority_binding(owner: Rc, name: String) -> Option> { + owner + .type_env + .bindings + .values() + .find(|b| b.name.clone() == name) + .cloned() + } + + fn global_type_exporter_count(modules: Rc>>, name: &str) -> usize { + modules + .iter() + .filter(|m| module_exports_type_name((**m).clone(), name)) + .count() + } + + fn local_authority_for_name( + modules: Rc>>, + name: String, + ) -> Option> { + // 🟡 dissolve-on: local_authority_for_name_dissolution_trigger (04_infer.dag) + modules .iter() + .rev() + .find(|m| m.type_env.bindings.values().any(|b| b.name.clone() == name)) .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - Rc::new(TypeBinding { - name: name.clone(), - resolved: Rc::new(Node { - name: name.clone(), - span: kernel_span(name.clone()), - ident_span: Some(kernel_span(name.clone())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ) - }, - ); - let unit_span = kernel_span("Unit".to_string()); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings_base, - intern(intern_table.clone(), "Unit".to_string()).id.clone(), - Rc::new(TypeBinding { - name: "Unit".to_string(), - resolved: Rc::new(Node { - name: "Unit".to_string(), - span: unit_span.clone(), - ident_span: Some(unit_span.clone()), - children: Rc::new(vec![]), - connective: Connective::Conj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let present_value_field = Rc::new(Node { - name: "value".to_string(), - span: kernel_span("value".to_string()), - ident_span: Some(kernel_span("value".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: Some(Rc::new(InferredNode::TypeVariable { - id: "present_value".to_string(), - })), - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let present_variant = Rc::new(Node { - name: "Present".to_string(), - span: kernel_span("Present".to_string()), - ident_span: Some(kernel_span("Present".to_string())), - children: Rc::new(vec![present_value_field]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let absent_variant = Rc::new(Node { - name: "Absent".to_string(), - span: kernel_span("Absent".to_string()), - ident_span: Some(kernel_span("Absent".to_string())), - children: Rc::new(vec![]), - connective: Connective::NoConnective, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_optional = Rc::new(Node { - name: "Optional".to_string(), - span: kernel_span("Optional".to_string()), - ident_span: Some(kernel_span("Optional".to_string())), - children: Rc::new(vec![present_variant, absent_variant]), - connective: Connective::Disj, - params: Rc::new(vec![]), - inferred: None, - return_cardinality: Cardinality::Required, - uses: Rc::new(vec![]), - body: None, - transport: None, - properties: Rc::new(vec![]), - type_annotation: None, - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }); - let kernel_bindings = v1_rt::rc_map_insert( - kernel_bindings.clone(), - intern(intern_table.clone(), "Optional".to_string()) - .id - .clone(), - Rc::new(TypeBinding { - name: "Optional".to_string(), - resolved: kernel_optional, - provenance: Rc::new(SubValueRelation::SubValueUnknown), - }), - ); - let node_fields = inductive_fields_list_to_map(compiler_inductive_fields()); - let kernel_recursive_types = Rc::new({ - let mut __result = Vec::new(); - for name in Rc::new(v1_rt::map_keys(&compiler_recursive_types())) + } + + fn module_exports_type_name(m: Rc, name: &str) -> bool { + m.type_env + .bindings + .values() + .any(|b| b.name.as_str() == name) + } + + fn direct_import_exporter_count( + m: Rc, + name: &str, + index: &HashMap>, + source_indices: Rc>>, + ) -> usize { + module_imports(m.module.clone()) + .iter() + .filter(|imp| { + let path = import_module_path_at((*imp).clone(), source_indices.clone()); + index.get(&path).map_or(false, |parent| { + module_exports_type_name(parent.clone(), name) + }) + }) + .count() + } + + let index = modules.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, m: Rc| { + v1_rt::rc_map_insert( + acc, + authored_name_at(source_indices.clone(), m.module.clone()), + m.clone(), + ) + }, + ); + + Rc::new({ + let mut __result = Vec::new(); + for m in modules.clone().iter().cloned() { + let local_names: std::collections::HashSet = m + .type_env + .bindings + .values() + .map(|b| b.name.clone()) + .collect(); + let mut str_bindings = m.type_env.str_bindings.clone(); + let mut ancestry_str_bindings = m.type_env.ancestry_str_bindings.clone(); + let mut inherited_names: Vec = Rc::new(v1_rt::map_keys(&ancestry_str_bindings)) .iter() + .chain(Rc::new(v1_rt::map_keys(&str_bindings)).iter()) .cloned() - { - __result.push(intern(intern_table.clone(), name.clone()).id.clone()); + .filter(|name| !local_names.contains(name)) + .collect(); + inherited_names.sort(); + for name in inherited_names { + if direct_import_exporter_count( + m.clone(), + name.as_str(), + &index, + source_indices.clone(), + ) > 1 + || global_type_exporter_count(modules.clone(), name.as_str()) > 1 + { + continue; + } + if let Some(owner) = local_authority_for_name(modules.clone(), name.clone()) { + if let Some(canonical) = local_authority_binding(owner, name.clone()) { + if match v1_rt::map_get(&ancestry_str_bindings, name.clone()) { + Some(existing) => { + Rc::ptr_eq(&existing.resolved, &canonical.resolved) + && existing.name == canonical.name + } + None => false, + } { + continue; + } + ancestry_str_bindings = v1_rt::rc_map_insert( + ancestry_str_bindings, + name.clone(), + canonical.clone(), + ); + if v1_rt::map_contains_key(&str_bindings, name.clone()) { + str_bindings = + v1_rt::rc_map_insert(str_bindings, name.clone(), canonical); + } + } + } } - __result - }); - let kernel_recursive_type_set = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert( - acc, - intern(intern_table.clone(), name.clone()).id.clone(), - true, - ) - }, - ); - Rc::new(TypeEnv { - bindings: kernel_bindings.clone(), - str_bindings: str_bindings_from_bindings(kernel_bindings.clone()), - ancestry_str_bindings: v1_rt::rc_empty_map::>(), - parents: Rc::new(vec![]), - recursive_types: kernel_recursive_types, - recursive_type_set: kernel_recursive_type_set, - inductive_fields: node_fields, - source_indices: source_indices, - intern_table: intern_table.clone(), - }) - } + __result.push(Rc::new(TypedModule { + module: m.module.clone(), + items: m.items.clone(), + type_env: Rc::new(TypeEnv { + bindings: m.type_env.bindings.clone(), + str_bindings, + ancestry_str_bindings, + parents: m.type_env.parents.clone(), + recursive_types: m.type_env.recursive_types.clone(), + recursive_type_set: m.type_env.recursive_type_set.clone(), + inductive_fields: m.type_env.inductive_fields.clone(), + source_indices: m.type_env.source_indices.clone(), + intern_table: m.type_env.intern_table.clone(), + }), + type_env_cache: m.type_env_cache.clone(), + func_env: m.func_env.clone(), + item_registry: m.item_registry.clone(), + })); + } + __result + }) } pub fn rewire_type_env_parent_links( modules: Rc>>, source_indices: Rc>>, ) -> Rc>> { + record_rewire_type_env_parent_links_call(); { + let intern_table = modules + .first() + .map(|m| m.type_env.intern_table.clone()) + .unwrap_or_else(empty_intern_table); + let shared_kernel = modules + .iter() + .find_map(|m| { + m.type_env.parents.last().and_then(|kernel| { + if kernel.bindings.is_empty() { + None + } else { + Some(kernel.clone()) + } + }) + }) + .unwrap_or_else(|| { + compiler_kernel_type_env(source_indices.clone(), intern_table.clone()) + }); let index = modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { @@ -15175,25 +14919,6 @@ pub fn rewire_type_env_parent_links( ) }, ); - let shared_kernel = match modules.clone().iter().cloned().fold( - None, - |acc, m: Rc| match acc.clone() { - Some(_) => acc.clone(), - None => match (*m.type_env).clone().parents.clone().last().cloned() { - Some(kernel) => Some(kernel.clone()), - None => None, - }, - }, - ) { - Some(kernel) => kernel.clone(), - None => match modules.clone().first().cloned() { - Some(m) => compiler_kernel_type_env( - source_indices.clone(), - (*m.type_env).clone().intern_table.clone(), - ), - None => compiler_kernel_type_env(source_indices.clone(), crate::v1_std_core::empty_intern_table()), - }, - }; Rc::new({ let mut __result = Vec::new(); for m in modules.clone().iter().cloned() { @@ -15219,25 +14944,20 @@ pub fn rewire_type_env_parent_links( } __result }); + let kernel_parent = Rc::new(vec![shared_kernel.clone()]); Rc::new(TypedModule { module: m.module.clone(), items: m.items.clone(), type_env: Rc::new(TypeEnv { - bindings: (*m.type_env).clone().bindings.clone(), - str_bindings: (*m.type_env).clone().str_bindings.clone(), - ancestry_str_bindings: (*m.type_env) - .clone() - .ancestry_str_bindings - .clone(), - parents: v1_rt::concat( - import_parents.clone(), - Rc::new(vec![shared_kernel.clone()]), - ), - recursive_types: (*m.type_env).clone().recursive_types.clone(), - recursive_type_set: (*m.type_env).clone().recursive_type_set.clone(), - inductive_fields: (*m.type_env).clone().inductive_fields.clone(), - source_indices: (*m.type_env).clone().source_indices.clone(), - intern_table: (*m.type_env).clone().intern_table.clone(), + bindings: m.type_env.clone().bindings.clone(), + str_bindings: m.type_env.clone().str_bindings.clone(), + ancestry_str_bindings: m.type_env.clone().ancestry_str_bindings.clone(), + parents: v1_rt::concat(import_parents.clone(), kernel_parent.clone()), + recursive_types: m.type_env.clone().recursive_types.clone(), + recursive_type_set: m.type_env.clone().recursive_type_set.clone(), + inductive_fields: m.type_env.clone().inductive_fields.clone(), + source_indices: m.type_env.clone().source_indices.clone(), + intern_table: m.type_env.clone().intern_table.clone(), }), type_env_cache: m.type_env_cache.clone(), func_env: m.func_env.clone(), @@ -15277,7 +14997,7 @@ pub fn rewire_func_env_parent_links( let path = import_module_path_at(imp.clone(), source_indices.clone()); match v1_rt::map_get(&index, path.clone()) { - Some(parent) => Rc::new(vec![(*parent.func_env).clone()]), + Some(parent) => Rc::new(vec![parent.func_env.clone()]), None => Rc::new(vec![]), } }) @@ -15293,7 +15013,7 @@ pub fn rewire_func_env_parent_links( type_env: m.type_env.clone(), type_env_cache: m.type_env_cache.clone(), func_env: Rc::new(ResolvedFuncEnv { - local: (*m.func_env).clone().local.clone(), + local: m.func_env.clone().local.clone(), parents: parents.clone(), }), item_registry: m.item_registry.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 80801b55852..0dc55228a93 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -229,10 +229,11 @@ pub fn detect_type_cycles_kahn( ) -> Rc> { { let all_names = Rc::new({ - let mut __result = Vec::new(); - for b in Rc::new(v1_rt::map_values(&bindings)).iter().cloned() { - __result.push(b.name.clone()); - } + let mut __result: Vec = Rc::new(v1_rt::map_values(&bindings)) + .iter() + .map(|b| b.name.clone()) + .collect(); + __result.sort(); __result }); let name_set = all_names diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b8089770e47..8dc46a13d29 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,8 +83,6 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, - pub move_sites_index: Rc>>>, - pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -106,8 +104,6 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), @@ -452,7 +448,8 @@ pub fn build_field_type_map( ) -> Rc> { children.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| match child.inferred + |acc: Rc>, child: Rc| match child + .inferred .clone() .as_deref() .cloned() diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 77676a00023..dc7b6acbab3 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -17,12 +17,82 @@ use crate::NonEmptyVec; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +use std::sync::atomic::{AtomicU64, Ordering}; + +// 🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0). +static FLATTEN_VISIBLE_PARENT_RECURSES: AtomicU64 = AtomicU64::new(0); +static BUILD_TYPE_ENV_CALLS: AtomicU64 = AtomicU64::new(0); +static MERGE_TYPE_ENV_CACHE_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_PARENT_LINKS_CALLS: AtomicU64 = AtomicU64::new(0); +static REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS: AtomicU64 = AtomicU64::new(0); + +pub fn flatten_visible_parent_recurses() -> u64 { + FLATTEN_VISIBLE_PARENT_RECURSES.load(Ordering::Relaxed) +} + +pub fn build_type_env_calls() -> u64 { + BUILD_TYPE_ENV_CALLS.load(Ordering::Relaxed) +} + +pub fn merge_type_env_cache_calls() -> u64 { + MERGE_TYPE_ENV_CACHE_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_parent_links_calls() -> u64 { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.load(Ordering::Relaxed) +} + +pub fn rewire_type_env_import_str_binding_calls() -> u64 { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.load(Ordering::Relaxed) +} + +pub fn reset_flatten_visible_profile() { + FLATTEN_VISIBLE_PARENT_RECURSES.store(0, Ordering::Relaxed); +} + +pub fn reset_type_env_lookup_profile() { + reset_flatten_visible_profile(); + BUILD_TYPE_ENV_CALLS.store(0, Ordering::Relaxed); + MERGE_TYPE_ENV_CACHE_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.store(0, Ordering::Relaxed); + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.store(0, Ordering::Relaxed); +} + +pub fn maybe_print_type_env_lookup_profile() { + if std::env::var("GUNBC_TYPE_ENV_PROFILE").ok().as_deref() == Some("1") { + eprintln!( + "type_env profile: flatten_parent_recurses={} build_type_env_calls={} merge_cache_calls={} rewire_parent_links={} rewire_import_str={}", + flatten_visible_parent_recurses(), + build_type_env_calls(), + merge_type_env_cache_calls(), + rewire_type_env_parent_links_calls(), + rewire_type_env_import_str_binding_calls(), + ); + } +} + +pub fn record_flatten_visible_parent_recurse() { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_build_type_env_call() { + BUILD_TYPE_ENV_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_parent_links_call() { + REWIRE_TYPE_ENV_PARENT_LINKS_CALLS.fetch_add(1, Ordering::Relaxed); +} + +pub fn record_rewire_type_env_import_str_binding_call() { + REWIRE_TYPE_ENV_IMPORT_STR_BINDING_CALLS.fetch_add(1, Ordering::Relaxed); +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeEnv { pub bindings: Rc>>, pub str_bindings: Rc>>, pub ancestry_str_bindings: Rc>>, + #[serde(skip, default = "empty_type_env_parents")] pub parents: Rc>>, pub recursive_types: Rc>, pub recursive_type_set: Rc>, @@ -31,6 +101,10 @@ pub struct TypeEnv { pub intern_table: Rc, } +fn empty_type_env_parents() -> Rc>> { + Rc::new(vec![]) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { pub name: String, @@ -46,60 +120,6 @@ pub struct TypeEnvCache { pub variant_locals: Rc>>, } -pub fn type_env_compositional_authority_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: compositional TypeEnv.parents + ancestry_str_bindings rewire passes in stage0 — ground in v2 std.type_env when PerformanceReceipt subsumes type_env_work_count_profiling_dissolution_trigger.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: host atomic profiling until PerformanceReceipt carrier lands (realization-measurement-loop Phase 0).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_work_count_profiling_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: build_type_env + merge_type_env_cache + rewire pass counters — fold into PerformanceReceipt at realization-measurement-loop Phase 0.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_parallel_repr_dissolution_trigger() -> String { - thread_local! { - static CACHED: String = { - "🟡 dissolve-on: TypeEnvCache String-keyed str_bindings and cycle_set_str parallel to TypeEnv Int-keyed bindings and recursive_type_set — fold into single authority at v2 regen.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn type_env_cache_key_determinism_authority() -> String { - thread_local! { - static CACHED: String = { - "Cache-key determinism for resolved_graph disk tier: resolved_graph_cache::encode_cache_payload applies sort_json_value at serialization boundary (not merge_type_env_cache / build_type_env hot paths). B2 de-fork: Rust seed must match this .dag plain map_merge authority.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn flatten_visible_bindings_invariant() -> String { - thread_local! { - static CACHED: String = { - "B1 build_type_env populates ancestry_str_bindings for import chains; lookup_binding_by_name is fail-closed on miss (str_bindings then ancestry_str_bindings then intern+bindings only — no flatten_visible_bindings fallback; 6de571f3 reverted in 80ab63a). flatten_visible_bindings: parent fold map_merge(flatten(parent), acc) — earlier env.parents win over later on collision; local map_merge(ancestry_str_bindings, str_bindings) then map_merge(from_parents, local) — str_bindings wins ancestry, local wins parents. Parent-recurse counter is stub-only on import chains (witness flatten_visible_parent_recurses==0); merge_envs still calls flatten for one-shot env merge.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn empty_type_env_cache() -> Rc { Rc::new(TypeEnvCache { deps_map: v1_rt::rc_empty_map::>>(), @@ -109,34 +129,16 @@ pub fn empty_type_env_cache() -> Rc { }) } -pub fn build_type_env_calls() -> i64 { - 0 -} - -pub fn merge_type_env_cache_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_parent_links_calls() -> i64 { - 0 -} - -pub fn rewire_type_env_import_str_binding_calls() -> i64 { - 0 -} - -pub fn type_env_counter_dissolution() -> String { - thread_local! { - static CACHED: String = { - "The 2026-07-04 use-site inference pathology instrument (env-amplification counters) dissolves with the pathology it measured: the record_* statement calls and their stub fns are deleted (they were also the only corpus instances of a statement-then-expression block the Rust emitter mis-renders — that emitter deficiency is ledgered with the emit-stage work). The Int getter stubs below stay for API compatibility with the hand-maintained phase_profile heartbeat until that consumer drops them.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) +pub fn record_merge_type_env_cache_call() { + MERGE_TYPE_ENV_CACHE_CALLS.fetch_add(1, Ordering::Relaxed); } pub fn merge_type_env_cache(base: Rc, overlay: Rc) -> Rc { + record_merge_type_env_cache_call(); Rc::new(TypeEnvCache { deps_map: v1_rt::rc_map_merge(base.deps_map.clone(), overlay.deps_map.clone()), + // Match 04_env.dag authority (plain map_merge). Cache-key determinism lives at + // resolved_graph_cache::encode_cache_payload (sort_json_value), not here. str_bindings: v1_rt::rc_map_merge(base.str_bindings.clone(), overlay.str_bindings.clone()), cycle_set_str: v1_rt::rc_map_merge( base.cycle_set_str.clone(), @@ -162,21 +164,42 @@ pub fn lookup_binding_local_by_name(env: Rc, name: String) -> Option>>, ) -> Rc>> { - Rc::new(v1_rt::map_values(&bindings)).iter().cloned().fold( + let mut pairs: Vec<(String, Rc)> = bindings + .values() + .map(|binding| (binding.name.clone(), binding.clone())) + .collect(); + pairs.sort_by(|a, b| a.0.cmp(&b.0)); + pairs.into_iter().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, binding: Rc| { - v1_rt::rc_map_insert(acc, binding.name.clone(), binding.clone()) + |acc: Rc>>, (name, binding)| { + v1_rt::rc_map_insert(acc, name, binding) + }, + ) +} + +// Serialization-boundary canonicalization only (resolved_graph_cache::sort_json_value +// subsumes this for disk cache; do not call from build_type_env / merge_type_env_cache). +#[allow(dead_code)] +pub fn deterministic_str_binding_map( + m: Rc>>, +) -> Rc>> { + let mut keys: Vec = m.keys().cloned().collect(); + keys.sort(); + keys.iter().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, key: &String| { + v1_rt::rc_map_insert(acc, key.clone(), m.get(key).unwrap().clone()) }, ) } pub fn lookup_binding_by_name(env: Rc, name: String) -> Option> { - match v1_rt::map_get(&env.str_bindings.clone(), name.clone()) { + match v1_rt::map_get(&env.str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match v1_rt::map_get(&env.ancestry_str_bindings.clone(), name.clone()) { + None => match v1_rt::map_get(&env.ancestry_str_bindings, name.clone()) { Some(binding) => Some(binding.clone()), - None => match intern_find(env.intern_table.clone(), name.clone()) { - Some(id) => v1_rt::map_get(&env.bindings.clone(), id.clone()), + None => match intern_find(env.intern_table.clone(), name) { + Some(id) => v1_rt::map_get(&env.bindings, id), None => None, }, }, @@ -188,7 +211,7 @@ pub fn lookup_binding(env: Rc, ident: i64) -> Option> { Some(binding) => Some(binding.clone()), None => { let name = intern_str(env.intern_table.clone(), ident.clone()); - lookup_binding_by_name(env.clone(), name) + lookup_binding_by_name(env, name) } } } @@ -201,7 +224,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { - match intern_find(env.intern_table.clone(), name) { + match intern_find(env.intern_table.clone(), name.clone()) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, } @@ -240,26 +263,18 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let local = match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { - Some(fields) => fields.clone(), - None => Rc::new(vec![]), - }; - if ((local.clone().len() as i64) > 0) { - local.clone() - } else { - env.parents.clone().iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, parent: Rc| { - if ((acc.clone().len() as i64) > 0) { - acc.clone() - } else { - inductive_fields_for(parent.clone(), type_name.clone()) - } - }, - ) + match v1_rt::map_get(&env.inductive_fields.clone(), type_name.clone()) { + Some(fields) if !fields.is_empty() => fields.clone(), + _ => { + for parent in env.parents.iter() { + let fields = inductive_fields_for(parent.clone(), type_name.clone()); + if !fields.is_empty() { + return fields; + } + } + Rc::new(vec![]) } - }) + } } pub fn is_inductive_field( @@ -385,27 +400,12 @@ pub fn inductive_fields_list_to_map( ) } -pub fn flatten_visible_parent_recurses() -> i64 { - 0 -} - -pub fn reset_flatten_visible_profile() -> () { - {} -} - -pub fn reset_type_env_lookup_profile() -> () { - reset_flatten_visible_profile() -} - -pub fn maybe_print_type_env_lookup_profile() -> () { - {} -} - pub fn flatten_visible_bindings(env: Rc) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let from_parents = env.parents.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, parent: Rc| { + FLATTEN_VISIBLE_PARENT_RECURSES.fetch_add(1, Ordering::Relaxed); v1_rt::rc_map_merge(flatten_visible_bindings(parent.clone()), acc) }, ); @@ -469,7 +469,7 @@ pub fn merge_envs(envs: Rc>>) -> Rc { ); Rc::new(TypeEnv { bindings: merged_bindings_by_ident, - str_bindings: merged_bindings.clone(), + str_bindings: merged_bindings, ancestry_str_bindings: v1_rt::rc_empty_map::>(), parents: Rc::new(vec![]), recursive_types: merged_recursive, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 95a6d52a3d7..02b08953fa8 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -2,10 +2,12 @@ // Source module: v1.compiler.infer_items use self::ItemKind::*; +pub use crate::std_induction::SubValueRelation; +use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_emit_info::EmitGraphInfo; pub use crate::v1_compiler_infer_env::empty_type_env_cache; -pub use crate::v1_compiler_infer_env::{TypeEnv, TypeEnvCache}; +pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv, TypeEnvCache}; pub use crate::v1_compiler_infer_sigs::ResolvedFuncEnv; pub use crate::v1_compiler_infer_types::child_type_node; use crate::v1_rt; @@ -174,13 +176,10 @@ pub fn item_kind(item: Rc) -> ItemKind { if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) - { + if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { ItemKind::FnItem } else { - if ((item.body.clone() != None) - && (item.type_annotation.clone() != None)) - { + if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { ItemKind::DataItem } else { if (item.body.clone() != None) { @@ -197,6 +196,38 @@ pub fn item_kind(item: Rc) -> ItemKind { } } +pub fn variant_locals_from_items( + items: Rc>>, + init: Rc>>, + source_indices: Rc>>, +) -> Rc>> { + items.iter().cloned().fold( + init, + |acc: Rc>>, item: Rc| { + let is_coproduct = (item.connective.clone() == Connective::Disj); + if is_coproduct.clone() { + item.children.clone().iter().cloned().fold( + acc.clone(), + |vacc: Rc>>, child: Rc| { + let child_name = authored_name_at(source_indices.clone(), child.clone()); + v1_rt::rc_map_insert( + vacc, + child_name.clone(), + Rc::new(TypeBinding { + name: child_name.clone(), + resolved: item.clone(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ) + }, + ) + } else { + acc.clone() + } + }, + ) +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FnItem; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 58133bfe102..ac704dae929 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -126,12 +126,12 @@ pub fn lookup_field_type_node( None => nominal_type_ref("V".to_string()), }; Some( - (*make_container_type( + make_container_type( "Witness".to_string(), value_child, ) - .ty) - .clone(), + .ty + .clone(), ) } } else { @@ -217,14 +217,18 @@ pub fn resolve_method_receiver_type(receiver_type: Rc, env: Rc) - resolve_scrutinee_type_node(env.clone(), receiver_type.clone()), env.source_indices.clone(), ); - let resolved_name = authored_name_at(env.source_indices.clone(), resolved.clone()); - if ((resolved.connective.clone() == Connective::Conj) - || ((resolved_name.clone() != raw_name.clone()) - && is_declared_container_alias_spelling(resolved_name.clone()))) - { + if (resolved.connective.clone() == Connective::Conj) { resolved.clone() } else { - receiver_type.clone() + let resolved_name = + authored_name_at(env.source_indices.clone(), resolved.clone()); + if ((resolved_name.clone() != raw_name.clone()) + && is_declared_container_alias_spelling(resolved_name.clone())) + { + resolved.clone() + } else { + receiver_type.clone() + } } } } @@ -499,7 +503,11 @@ pub fn map_lookup_result_type( if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { Some(raw.clone()) } else { - Some(make_container_type("Witness".to_string(), raw.clone()).ty.clone()) + Some( + make_container_type("Witness".to_string(), raw.clone()) + .ty + .clone(), + ) } } None => None, @@ -579,8 +587,8 @@ pub fn lookup_structural_method( receiver_type.clone(), source_indices.clone(), ); - if (((*enriched.ty).clone().connective.clone() == Connective::Conj) - && (((*enriched.ty).clone().children.clone().len() as i64) > 0)) + if ((enriched.ty.clone().connective.clone() == Connective::Conj) + && ((enriched.ty.clone().children.clone().len() as i64) > 0)) { { let base_result = lookup_field_in_product( diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 7e4b3673ab3..96d9884ceb1 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -44,16 +44,18 @@ pub fn type_variable_node(id: String) -> Rc { } pub fn map_of_type_variables() -> Rc { - Rc::new((*make_map_type( + make_map_type( type_variable_node("map_key".to_string()), type_variable_node("map_value".to_string()), ) - .ty) - .clone()) + .ty + .clone() } pub fn list_of_type_variable(id: String) -> Rc { - make_container_type("List".to_string(), type_variable_node(id)).ty.clone() + make_container_type("List".to_string(), type_variable_node(id)) + .ty + .clone() } pub fn list_of_element(element: Rc) -> Rc { @@ -61,7 +63,9 @@ pub fn list_of_element(element: Rc) -> Rc { } pub fn witness_of_element(element: Rc) -> Rc { - make_container_type("Witness".to_string(), element).ty.clone() + make_container_type("Witness".to_string(), element) + .ty + .clone() } pub fn seed_node_map(key: String, value: Rc) -> Rc>> { @@ -123,15 +127,15 @@ pub fn builtin_function_registry() -> Rc>> { let m = v1_rt::rc_map_insert(m.clone(), "map_insert".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "map_merge".to_string(), map_of_type_variables()); let m = v1_rt::rc_map_insert(m.clone(), "with".to_string(), map_of_type_variables()); - let set_ty = (*make_container_type( + let set_ty = make_container_type( "Set".to_string(), type_variable_node("set_elem".to_string()), ) - .ty) - .clone(); - let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), Rc::new(set_ty.clone())); - let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), Rc::new(set_ty.clone())); - let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), Rc::new(set_ty.clone())); + .ty + .clone(); + let m = v1_rt::rc_map_insert(m.clone(), "empty_set".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "set_insert".to_string(), set_ty.clone()); + let m = v1_rt::rc_map_insert(m.clone(), "set_union".to_string(), set_ty.clone()); let m = v1_rt::rc_map_insert(m.clone(), "map_contains_key".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_has".to_string(), bool_type()); let m = v1_rt::rc_map_insert(m.clone(), "map_is_empty".to_string(), bool_type()); @@ -250,6 +254,41 @@ pub fn builtin_function_registry() -> Rc>> { int_type(), ); let m = v1_rt::rc_map_insert(m.clone(), "doc_graph_doc_count".to_string(), int_type()); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_loc".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_total_test_fns".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_module_names".to_string(), + list_of_type_variable("test_migration_debt_module_name_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_debt_known_covered_module_is_not_debt".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_holds".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "test_migration_delete_guard_uncovered_deletes".to_string(), + list_of_type_variable("test_migration_delete_guard_uncovered_delete_elem".to_string()), + ); let m = v1_rt::rc_map_insert( m.clone(), "inert_carrier_names_live".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 4e0bf90d8ff..1dd9fc95134 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -37,148 +37,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn generic_use_slot_bindings( - scrut_node: Rc, - env: Rc, -) -> Rc>> { - { - let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); - Rc::new( - decl.params - .clone() - .iter() - .cloned() - .enumerate() - .map(|(i, v)| (i as i64, v)) - .collect::>(), - ) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pair: (i64, Rc)| { - let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); - match scrut_node - .children - .clone() - .get(pair.0.clone() as usize) - .cloned() - { - Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), arg.clone()), - None => acc.clone(), - } - }, - ) - } -} - -pub fn expand_scrut_from_decl( - decl: Rc, - scrut_node: Rc, - name: String, - env: Rc, -) -> Rc { - { - let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = (((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)) - && ((decl.children.clone().len() as i64) == 0)); - if decl_is_disj { - decl.clone() - } else { - if has_inferred_alias { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let subst = generic_use_slot_bindings(scrut_node, env.clone()); - substitute_type_slots( - target.clone(), - subst, - name, - env.source_indices.clone(), - ) - } - _ => scrut_node, - } - } else { - scrut_node - } - } - } -} - -pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc { - { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_generic_use = (((scrut_node.connective.clone() == Connective::NoConnective) - && ((scrut_node.children.clone().len() as i64) > 0)) - && is_user_generic_use_site(scrut_node.clone(), env.clone())); - match lookup_type_by_name(env.clone(), name.clone()) { - Some(decl) => { - if is_generic_use { - expand_scrut_from_decl( - decl.clone(), - scrut_node.clone(), - name.clone(), - env.clone(), - ) - } else { - { - let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = ((decl.inferred.clone() != None) - && (decl.connective.clone() == Connective::NoConnective)); - if def_is_disj { - decl.clone() - } else { - if has_inferred_body { - match decl.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let target_is_disj = - (target.connective.clone() == Connective::Disj); - if target_is_disj { - target.clone() - } else { - scrut_node.clone() - } - } - _ => scrut_node.clone(), - } - } else { - scrut_node.clone() - } - } - } - } - } - None => scrut_node.clone(), - } - } -} - -pub fn expand_scrut_type_for_variant_lookup( - mut scrut_node: Rc, - mut env: Rc, -) -> Rc { - loop { - let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); - let is_disj = (scrut_node.connective.clone() == Connective::Disj); - let is_witness = is_witness_type_name(name); - if (is_disj || is_witness) { - break scrut_node.clone(); - } else { - match scrut_node.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - let __tco_0 = target.clone(); - scrut_node = __tco_0; - continue; - } - _ => { - break expand_scrut_from_type_name(scrut_node.clone(), env.clone()); - } - } - } - } -} - pub fn is_witness_type_name(name: String) -> bool { ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } @@ -469,6 +327,102 @@ pub fn variant_not_found_result( )])) } +pub fn generic_use_slot_bindings( + scrut_node: Rc, + env: Rc, +) -> Rc>> { + let decl = resolve_generic_use_decl(env.clone(), scrut_node.clone()); + Rc::new( + decl.params + .clone() + .iter() + .cloned() + .enumerate() + .map(|(i, v)| (i as i64, v)) + .collect::>(), + ) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pair: (i64, Rc)| { + let slot = generic_param_name_at(pair.1.clone(), env.source_indices.clone()); + match scrut_node + .children + .clone() + .get(pair.0.clone() as usize) + .cloned() + { + Some(arg) => v1_rt::rc_map_insert(acc, slot, arg), + None => acc, + } + }, + ) +} + +pub fn expand_scrut_type_for_variant_lookup(scrut_node: Rc, env: Rc) -> Rc { + let name = authored_name_at(env.source_indices.clone(), scrut_node.clone()); + if (scrut_node.connective.clone() == Connective::Disj) || is_witness_type_name(name.clone()) { + return scrut_node.clone(); + } + if (((scrut_node.connective.clone() == Connective::NoConnective) + && ((scrut_node.children.clone().len() as i64) > 0)) + && is_user_generic_use_site(scrut_node.clone(), env.clone())) + { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(decl) => { + if (((decl.inferred.clone() != None) + && ((decl.children.clone().len() as i64) == 0)) + && (decl.connective.clone() == Connective::NoConnective)) + { + match decl.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + let subst = generic_use_slot_bindings(scrut_node.clone(), env.clone()); + let expanded = substitute_type_slots( + target, + subst, + name.clone(), + env.source_indices.clone(), + ); + return expanded; + } + _ => scrut_node.clone(), + } + } else if (decl.connective.clone() == Connective::Disj) { + decl.clone() + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } else { + match lookup_type_by_name(env.clone(), name.clone()) { + Some(def) => { + if (def.connective.clone() == Connective::Disj) { + def.clone() + } else if ((def.inferred.clone() != None) + && (def.connective.clone() == Connective::NoConnective)) + { + match def.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: target, .. }) => { + if (target.connective.clone() == Connective::Disj) { + target + } else { + scrut_node.clone() + } + } + _ => scrut_node.clone(), + } + } else { + scrut_node.clone() + } + } + None => scrut_node.clone(), + } + } +} + pub fn lookup_variant_in_type( scrut: Rc, variant_name: String, diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 8fe704ae16a..84f1b36551f 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -9,8 +9,8 @@ use crate::std_syntax::LiteralValue::LitInt; pub use crate::std_types::container_param_name; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_env::{ - authored_name, is_recursive_type, is_recursive_type_by_name, is_recursive_type_for, - lookup_type, lookup_type_by_name, lookup_type_for, + authored_name, flatten_visible_bindings, is_recursive_type, is_recursive_type_by_name, + is_recursive_type_for, lookup_type, lookup_type_by_name, lookup_type_for, }; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_types::{ @@ -117,41 +117,24 @@ pub fn lookup_unit_variant_phantom_type( } } -pub fn phantom_match_flat_scope() -> String { - thread_local! { - static CACHED: String = { - "Constructor-owner ruling (§1c): the nullary-variant-as-type fallback searches the FLAT visible set — the module's own str_bindings plus its direct parents' str_bindings, one level, never the recursive ancestry flatten. Unique match resolves; anything else falls through to the UnresolvedType error at the caller (fail-closed).".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn collect_unit_variant_phantom_matches( env: Rc, variant_name: String, ) -> Rc>> { - { - let direct_bindings = env.parents.clone().iter().cloned().fold( - env.str_bindings.clone(), - |acc: Rc>>, parent: Rc| { - v1_rt::rc_map_merge(parent.str_bindings.clone(), acc) + Rc::new(v1_rt::map_values(&flatten_visible_bindings(env.clone()))) + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( + env.clone(), + structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), + variant_name.clone(), + ) { + Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), + None => acc.clone(), }, - ); - Rc::new(v1_rt::map_values(&direct_bindings)) - .iter() - .cloned() - .fold( - Rc::new(vec![]), - |acc: Rc>>, binding: Rc| match unit_variant_in_coproduct( - env.clone(), - structural_type_for_variant_lookup(env.clone(), binding.resolved.clone()), - variant_name.clone(), - ) { - Some(variant) => v1_rt::concat(acc.clone(), Rc::new(vec![variant.clone()])), - None => acc.clone(), - }, - ) - } + ) } pub fn is_width_nat_type_literal(n: Rc) -> bool { @@ -196,22 +179,13 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc String { - thread_local! { - static CACHED: String = { - "🟢 intentional: resolve-side predicate for kernel-type transparent alias RHS — skip nominal re-brand in preserve_nominal_brand_on_resolve / peel_nominal_alias_identity until ParamKind partition lands.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn is_transparent_primitive_alias_rhs( structural: Rc, source_indices: Rc>>, ) -> bool { (((structural.connective.clone() == Connective::NoConnective) && ((structural.children.clone().len() as i64) == 0)) - && is_kernel_type(authored_name_at(source_indices, structural.clone()))) + && is_kernel_type(authored_name_at(source_indices.clone(), structural.clone()))) } pub fn preserve_nominal_brand_on_resolve( @@ -220,9 +194,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if ((((brand_name.clone() != "".to_string()) + if (((brand_name.clone() != "".to_string()) && (brand_name.clone() != authored_name_at(source_indices.clone(), structural.clone()))) - && !is_declared_container_alias_spelling(brand_name.clone())) + && !is_declared_container_alias_spelling(brand_name.clone()) && !is_transparent_primitive_alias_rhs(structural.clone(), source_indices.clone())) { with_authored_identity(identity, structural.clone()) @@ -242,40 +216,38 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S && (resolved.inferred.clone() != None)) { match resolved.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: target, .. }) => { - (*resolve_node_bounded( - target.clone(), - env.clone(), - module_name.clone(), - 0, - ) - .resolved) - .clone() - } - _ => (*resolve_node_bounded( + Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( + target.clone(), + env.clone(), + module_name.clone(), + 0, + ) + .resolved + .clone(), + _ => resolve_node_bounded( resolved.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(), + .resolved + .clone(), } } else { - (*resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) - .resolved) + resolve_node_bounded(resolved.clone(), env.clone(), module_name.clone(), 0) + .resolved .clone() }; - if ((((brand.clone() != "".to_string()) + if (((brand.clone() != "".to_string()) && (brand.clone() - != authored_name_at(source_indices.clone(), Rc::new(structural.clone())))) - && !is_declared_container_alias_spelling(brand.clone())) + != authored_name_at(source_indices.clone(), structural.clone()))) + && !is_declared_container_alias_spelling(brand.clone()) && !is_transparent_primitive_alias_rhs( - Rc::new(structural.clone()), + structural.clone(), source_indices.clone(), )) { - with_authored_identity(n.clone(), Rc::new(structural.clone())) + with_authored_identity(n.clone(), structural.clone()) } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) @@ -283,15 +255,15 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - let target_resolved = (*resolve_node_bounded( + let target_resolved = resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), 0, ) - .resolved) - .clone(); - with_authored_identity(n.clone(), Rc::new(target_resolved)) + .resolved + .clone(); + with_authored_identity(n.clone(), target_resolved) } _ => resolved.clone(), } @@ -375,61 +347,6 @@ pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc String { - thread_local! { - static CACHED: String = { - "A use site WITH type arguments (children > 0) whose primary name lookup lands on a PARAMLESS decl is definitionally mis-resolved - type args imply a generic declaration. The concrete seam: the kernel prelude binding for a name (e.g. the kernel Optional) shadows an explicitly imported user generic of the same name in the ancestry rung, so v2's Optional consumers resolved the paramless kernel decl, is_user_generic_use_site went false, the sig return was never expanded, and pattern bindings went error-typed with zero diagnostics (the interpreted-parse cascade; pre-existing on main). Retry the DIRECT import parents (str_bindings) for a parameterized decl before accepting the paramless one - the params filter naturally excludes the kernel parent, and the ancestry rung itself carries the kernel-shadowed entry so it cannot serve as the retry source.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - -pub fn lookup_ancestry_parameterized_decl(env: Rc, brand: String) -> Option> { - match Rc::new({ - let mut __result = Vec::new(); - for parent in env.parents.clone().iter().cloned() { - if match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => (((*b.resolved).clone().params.clone().len() as i64) > 0), - None => false, - } { - __result.push(parent); - } - } - __result - }) - .first() - .cloned() - { - Some(parent) => match v1_rt::map_get(&parent.str_bindings.clone(), brand.clone()) { - Some(b) => Some(b.resolved.clone()), - None => None, - }, - None => None, - } -} - -pub fn resolve_paramless_generic_use_decl( - env: Rc, - n: Rc, - decl: Rc, - brand: String, -) -> Rc { - match ((n.children.clone().len() as i64) > 0) { - true => match lookup_ancestry_parameterized_decl(env.clone(), brand.clone()) { - Some(user_decl) => user_decl.clone(), - None => match ((n.name.clone() != "".to_string()) && (n.name.clone() != brand.clone())) - { - true => match lookup_type_by_name(env.clone(), n.name.clone()) { - Some(structural) => structural.clone(), - None => decl, - }, - false => decl, - }, - }, - false => decl, - } -} - pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { { let brand = authored_name(env.clone(), n.clone()); @@ -437,8 +354,45 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { Some(decl) => { if ((decl.params.clone().len() as i64) > 0) { decl.clone() + } else if ((n.children.clone().len() as i64) > 0) { + // HAND-PATCH (parameterized use site prefers parameterized + // decl; replaced at regen): a use site WITH type args whose + // primary lookup lands paramless (kernel prelude shadowing + // an imported user generic, e.g. Optional) retries the + // ancestry binding for a parameterized decl. + let ancestry_generic = env.parents.iter().fold( + None, + |acc: Option>, parent: &Rc| { + if acc.is_some() { + return acc; + } + match v1_rt::map_get(&parent.str_bindings, brand.clone()) { + Some(b) => { + if ((b.resolved.params.clone().len() as i64) > 0) { + Some(b.resolved.clone()) + } else { + acc + } + } + None => acc, + } + }, + ); + match ancestry_generic { + Some(user_decl) => user_decl, + None => { + if ((n.name.clone() != "".to_string()) && (n.name.clone() != brand)) { + match lookup_type_by_name(env.clone(), n.name.clone()) { + Some(structural) => structural.clone(), + None => decl.clone(), + } + } else { + decl.clone() + } + } + } } else { - resolve_paramless_generic_use_decl(env.clone(), n.clone(), decl.clone(), brand) + decl.clone() } } None => match lookup_type_by_name(env.clone(), n.name.clone()) { @@ -624,8 +578,9 @@ pub fn resolve_alias_target( ) -> Rc { match classify_alias(target.clone()) { AliasKind::AliasParameterized => { - Rc::new((*resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)).resolved) - .clone()) + resolve_node_bounded(target.clone(), env.clone(), module_name, (depth + 1)) + .resolved + .clone() } AliasKind::AliasLeaf => match lookup_type_by_name( env.clone(), @@ -670,7 +625,7 @@ pub fn resolve_nominal_alias_rhs( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -751,14 +706,14 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let base_resolved = (*base_result.resolved).clone(); + let base_resolved = base_result.resolved.clone(); let base_diags = base_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { name: n.name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: Rc::new(vec![Rc::new(base_resolved)]), + children: Rc::new(vec![base_resolved]), connective: n.connective.clone(), params: n.params.clone(), inferred: n.inferred.clone(), @@ -801,7 +756,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let rt_resolved = (*rt_result.resolved).clone(); + let rt_resolved = rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { resolved: Rc::new(Node { @@ -813,7 +768,7 @@ pub fn resolve_node_bounded( params: child.params.clone(), inferred: Some(Rc::new( InferredNode::Resolved { - node: Rc::new(rt_resolved.clone()), + node: rt_resolved.clone(), }, )), return_cardinality: child @@ -826,8 +781,7 @@ pub fn resolve_node_bounded( child.properties.clone(), rt_resolved.properties.clone(), ), - type_annotation: child.type_annotation - .clone(), + type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -844,7 +798,7 @@ pub fn resolve_node_bounded( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.resolved).clone()); + __result.push(cr.resolved.clone()); } __result }); @@ -893,10 +847,10 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let inner_resolved = (*inner_result.resolved).clone(); + let inner_resolved = inner_result.resolved.clone(); let inner_diags = inner_result.diagnostics.clone(); Rc::new(NodeResolveResult { - resolved: with_optional_cardinality(Rc::new(inner_resolved)), + resolved: with_optional_cardinality(inner_resolved), diagnostics: inner_diags, }) } @@ -912,8 +866,7 @@ pub fn resolve_node_bounded( variant_child.children.clone().iter().cloned() { __result.push( - if (field_child.inferred.clone() == None) - { + if (field_child.inferred.clone() == None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -954,7 +907,7 @@ pub fn resolve_node_bounded( ) }; let rt_resolved = - (*rt_result.resolved).clone(); + rt_result.resolved.clone(); let rt_diags = rt_result.diagnostics.clone(); Rc::new(NodeResolveResult { @@ -966,7 +919,7 @@ pub fn resolve_node_bounded( connective: field_child.connective.clone(), params: field_child.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(rt_resolved.clone()), + node: rt_resolved.clone(), })), return_cardinality: field_child.return_cardinality.clone(), uses: field_child.uses.clone(), @@ -991,7 +944,7 @@ pub fn resolve_node_bounded( let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.resolved).clone()); + __result.push(fr.resolved.clone()); } __result }); @@ -1038,7 +991,7 @@ pub fn resolve_node_bounded( let resolved_variants = Rc::new({ let mut __result = Vec::new(); for vr in variant_results.clone().iter().cloned() { - __result.push((*vr.resolved).clone()); + __result.push(vr.resolved.clone()); } __result }); @@ -1114,7 +1067,7 @@ pub fn resolve_node_bounded( let resolved_args = Rc::new({ let mut __result = Vec::new(); for ar in arg_results.clone().iter().cloned() { - __result.push((*ar.resolved).clone()); + __result.push(ar.resolved.clone()); } __result }); @@ -1177,7 +1130,7 @@ pub fn resolve_node_bounded( Some(arg) => v1_rt::rc_map_insert( acc.clone(), slot_name.clone(), - Rc::new(arg.clone()), + arg.clone(), ), None => acc.clone(), } @@ -1211,15 +1164,15 @@ pub fn resolve_node_bounded( name: type_name.clone(), span: n.span.clone(), ident_span: n.ident_span.clone(), - children: (*target_result.resolved).clone().children.clone(), - connective: (*target_result.resolved).clone().connective.clone(), + children: target_result.resolved.clone().children.clone(), + connective: target_result.resolved.clone().connective.clone(), params: Rc::new(vec![]), - inferred: (*target_result.resolved).clone().inferred.clone(), + inferred: target_result.resolved.clone().inferred.clone(), return_cardinality: n.return_cardinality.clone(), uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1241,7 +1194,7 @@ pub fn resolve_node_bounded( uses: n.uses.clone(), body: n.body.clone(), transport: n.transport.clone(), - properties: (*target_result.resolved).clone().properties.clone(), + properties: target_result.resolved.clone().properties.clone(), type_annotation: n.type_annotation.clone(), is_self_recursive: is_recursive.clone(), has_non_tail_self_call: n.has_non_tail_self_call.clone(), @@ -1344,7 +1297,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let key_resolved = (*key_result.resolved).clone(); + let key_resolved = key_result.resolved.clone(); let key_diags = key_result.diagnostics.clone(); let val_result = resolve_node_bounded( val_type, @@ -1352,7 +1305,7 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let val_resolved = (*val_result.resolved).clone(); + let val_resolved = val_result.resolved.clone(); let val_diags = val_result.diagnostics.clone(); let key_param_name = if (key_child_node.inferred.clone() != None) { authored_name(env.clone(), key_child_node.clone()) @@ -1378,7 +1331,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(key_resolved), + node: key_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1400,7 +1353,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(val_resolved), + node: val_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1451,10 +1404,9 @@ pub fn resolve_node_bounded( module_name.clone(), (depth.clone() + 1), ); - let el_resolved = (*el_result.resolved).clone(); + let el_resolved = el_result.resolved.clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = if (child_node.inferred.clone() - != None) + let el_param_name = if (child_node.inferred.clone() != None) { authored_name(env.clone(), child_node.clone()) } else { @@ -1473,7 +1425,7 @@ pub fn resolve_node_bounded( connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(el_resolved), + node: el_resolved, })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), @@ -1520,26 +1472,26 @@ pub fn resolve_node_bounded( } else { if ((n.children.clone().len() as i64) == 0) { { - let n_target_is_coproduct_container = match n.inferred - .clone() - .as_deref() - .cloned() - { - Some(InferredNode::Resolved { node: target, .. }) => { - ((((target.connective.clone() - == Connective::NoConnective) - && ((target.children.clone().len() as i64) > 0)) - && is_container_type(target.name.clone())) - && (resolve_generic_use_decl( - env.clone(), - target.clone(), - ) - .connective - .clone() - == Connective::Disj)) - } - _ => false, - }; + let n_target_is_coproduct_container = + match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: target, .. + }) => { + ((((target.connective.clone() + == Connective::NoConnective) + && ((target.children.clone().len() as i64) + > 0)) + && is_container_type(target.name.clone())) + && (resolve_generic_use_decl( + env.clone(), + target.clone(), + ) + .connective + .clone() + == Connective::Disj)) + } + _ => false, + }; if (is_recursive_type_for(env.clone(), n.clone()) || n_target_is_coproduct_container) { @@ -1558,7 +1510,8 @@ pub fn resolve_node_bounded( == 0)) && (resolved.inferred.clone() != None)) { - match resolved.inferred + match resolved + .inferred .clone() .as_deref() .cloned() @@ -1586,14 +1539,14 @@ pub fn resolve_node_bounded( .clone() == Connective::Disj)); if target_is_coproduct_use { - (*resolve_node_bounded( + resolve_node_bounded( target.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), ) - .resolved) - .clone() + .resolved + .clone() } else { target.clone() } @@ -1616,8 +1569,7 @@ pub fn resolve_node_bounded( }) } None => { - let n_is_error = if (n.inferred.clone() != None) - { + let n_is_error = if (n.inferred.clone() != None) { is_compiler_error( n.inferred.clone().clone().unwrap(), ) @@ -1626,14 +1578,14 @@ pub fn resolve_node_bounded( }; let n_is_callable = ((n.params.clone().len() as i64) > 0); - let n_is_type_var = - if (n.inferred.clone() != None) { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = if (n.inferred.clone() != None) + { + is_type_variable( + n.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if ((((is_width_nat_type_literal(n.clone()) || is_kernel_type(authored_name( env.clone(), @@ -1773,7 +1725,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = v1_rt::concat( type_result.diagnostics.clone(), missing_generic_args_diagnostics( @@ -1797,7 +1749,7 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc::new(FieldResult { field: make_field_node( field_node_name_at(field.clone(), env.source_indices.clone()), - Rc::new(type_resolved), + type_resolved, field_node_cardinality(field.clone()), match default_resolved.clone() { Some(result) => Some(result.expr.clone()), @@ -1816,7 +1768,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let rendered_type = if ((authored_type.children.clone().len() as i64) > 0) { Rc::new(Node { name: authored_type.name.clone(), @@ -1826,7 +1778,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> connective: authored_type.connective.clone(), params: authored_type.params.clone(), inferred: Some(Rc::new(InferredNode::Resolved { - node: Rc::new(type_resolved.clone()), + node: type_resolved.clone(), })), return_cardinality: authored_type.return_cardinality.clone(), uses: authored_type.uses.clone(), @@ -1841,7 +1793,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> ident: None, }) } else { - Rc::new(type_resolved.clone()) + type_resolved.clone() }; let type_diags = v1_rt::concat( type_result.diagnostics.clone(), @@ -1864,7 +1816,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> None => Rc::new(vec![]), }; let default_expr = match default_resolved.clone() { - Some(result) => Some((*result.expr).clone()), + Some(result) => Some(result.expr.clone()), None => None, }; Rc::new(ParamResult { @@ -1888,12 +1840,12 @@ pub fn resolve_resource_use( ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); - let type_resolved = (*type_result.resolved).clone(); + let type_resolved = type_result.resolved.clone(); let type_diags = type_result.diagnostics.clone(); Rc::new(ResourceUseResult { resource_use: make_resource_use_node( resource_use_name_at(ru.clone(), env.source_indices.clone()), - Rc::new(type_resolved), + type_resolved, ru.span.clone(), node_name_span(ru.clone()), ), @@ -1909,12 +1861,12 @@ pub fn resolve_named_arg( ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(NamedArgResolveResult { arg: make_arg_node( arg_name_at(arg.clone(), env.source_indices.clone()), - Rc::new(value_expr), + value_expr, arg.span.clone(), node_name_span(arg.clone()), ), @@ -1934,12 +1886,12 @@ pub fn resolve_field_init( env.clone(), module_name, ); - let value_expr = (*value_result.expr).clone(); + let value_expr = value_result.expr.clone(); let value_diags = value_result.diagnostics.clone(); Rc::new(FieldInitResolveResult { field_init: make_field_init_node( field_init_node_name_at(field_init.clone(), env.source_indices.clone()), - Rc::new(value_expr), + value_expr, field_init.span.clone(), node_name_span(field_init.clone()), ), @@ -1969,7 +1921,7 @@ pub fn resolve_match_arm( }; let body_result = resolve_expr_types(arm_body(arm.clone()), env.clone(), module_name.clone()); - let body_expr = (*body_result.expr).clone(); + let body_expr = body_result.expr.clone(); let body_diags = body_result.diagnostics.clone(); Rc::new(MatchArmResolveResult { arm: make_arm_node( @@ -1978,7 +1930,7 @@ pub fn resolve_match_arm( Some(result) => Some(result.expr.clone()), None => None, }, - Rc::new(body_expr), + body_expr, arm.span.clone(), ), diagnostics: v1_rt::concat(guard_diags, body_diags), @@ -2000,11 +1952,11 @@ pub fn resolve_string_part( }), StringPart::Interpolation { expr: expr, .. } => { let expr_result = resolve_expr_types(expr.clone(), env, module_name); - let resolved_expr = (*expr_result.expr).clone(); + let resolved_expr = expr_result.expr.clone(); let expr_diags = expr_result.diagnostics.clone(); Rc::new(StringPartResolveResult { part: Rc::new(StringPart::Interpolation { - expr: Rc::new(resolved_expr), + expr: resolved_expr, }), diagnostics: expr_diags, }) @@ -2049,7 +2001,7 @@ pub fn resolve_transport_binding( let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -2074,7 +2026,7 @@ pub fn resolve_transport_binding( let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.expr).clone()); + __result.push(cr.expr.clone()); } __result }); @@ -2188,7 +2140,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in arg_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2284,7 +2236,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in mc_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2421,7 +2373,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in match_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2467,12 +2419,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match er.clone() { - Some(r) => Rc::new(vec![ - (*cr.expr).clone(), - (*tr.expr).clone(), - (*r.expr).clone(), - ]), - None => Rc::new(vec![(*cr.expr).clone(), (*tr.expr).clone()]), + Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![cr.expr.clone(), tr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_expr_node( @@ -2508,8 +2456,8 @@ pub fn resolve_expr_types( None => None, }; let resolved_children = match br.clone() { - Some(r) => Rc::new(vec![(*vr.expr).clone(), (*r.expr).clone()]), - None => Rc::new(vec![(*vr.expr).clone()]), + Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), + None => Rc::new(vec![vr.expr.clone()]), }; Rc::new(ExprResolveResult { expr: make_named_expr_node( @@ -2558,7 +2506,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in fi_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2598,7 +2546,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in el_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2733,7 +2681,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in part_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2769,7 +2717,7 @@ pub fn resolve_expr_types( let resolved_children = Rc::new({ let mut __result = Vec::new(); for r in stmt_results.clone().iter().cloned() { - __result.push((*r.expr).clone()); + __result.push(r.expr.clone()); } __result }); @@ -2908,11 +2856,7 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![ - br.expr.clone(), - sr.expr.clone(), - er.expr.clone(), - ]), + Rc::new(vec![br.expr.clone(), sr.expr.clone(), er.expr.clone()]), texpr.inferred.clone(), texpr.span.clone(), ), @@ -3084,7 +3028,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) str_bindings: v1_rt::rc_map_insert( e.str_bindings.clone(), tp_name.clone(), - tp_binding.clone(), + tp_binding, ), ancestry_str_bindings: e.ancestry_str_bindings.clone(), parents: e.parents.clone(), @@ -3106,7 +3050,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_params = Rc::new({ let mut __result = Vec::new(); for pr in param_results.clone().iter().cloned() { - __result.push((*pr.param).clone()); + __result.push(pr.param.clone()); } __result }); @@ -3126,21 +3070,17 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) env.clone(), module_name.clone(), ), - _ => resolve_optional_node( - item.inferred.clone(), - env.clone(), - module_name.clone(), - ), + _ => resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()), } } else { resolve_optional_node(item.inferred.clone(), env.clone(), module_name.clone()) }; - let ret_resolved = (*ret_result.resolved).clone(); + let ret_resolved = ret_result.resolved.clone(); let ret_diags = ret_result.diagnostics.clone(); let resolved_ret = if (item.inferred.clone() == None) { None } else { - Some(Rc::new(InferredNode::Resolved { node: Rc::new(ret_resolved) })) + Some(Rc::new(InferredNode::Resolved { node: ret_resolved })) }; let use_results = Rc::new({ let mut __result = Vec::new(); @@ -3156,7 +3096,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_uses = Rc::new({ let mut __result = Vec::new(); for ur in use_results.clone().iter().cloned() { - __result.push((*ur.resource_use).clone()); + __result.push(ur.resource_use.clone()); } __result }); @@ -3182,7 +3122,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_body = if (item.body.clone() == None) { None } else { - Some((*body_resolved.expr).clone()) + Some(body_resolved.expr.clone()) }; let body_diags = if (item.body.clone() == None) { Rc::new(vec![]) @@ -3204,7 +3144,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_anno = if (item.type_annotation.clone() == None) { None } else { - Some((*anno_resolved.resolved).clone()) + Some(anno_resolved.resolved.clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); let transport_resolved = if (item.transport.clone() == None) { @@ -3222,7 +3162,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_transport = if (item.transport.clone() == None) { None } else { - Some((*transport_resolved.transport).clone()) + Some(transport_resolved.transport.clone()) }; let transport_diags = transport_resolved.diagnostics.clone(); let prop_results = Rc::new({ @@ -3239,7 +3179,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_props = Rc::new({ let mut __result = Vec::new(); for pr in prop_results.clone().iter().cloned() { - __result.push((*pr.field_init).clone()); + __result.push(pr.field_init.clone()); } __result }); @@ -3283,7 +3223,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: child.transport.clone(), properties: v1_rt::concat( child.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: child.type_annotation.clone(), is_self_recursive: false, @@ -3299,9 +3239,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) __result }) } else { - if ((item.connective.clone() == Connective::Disj) - && (item.transport.clone() == None)) - { + if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3341,7 +3279,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) transport: field.transport.clone(), properties: v1_rt::concat( field.properties.clone(), - (*tr.resolved).clone().properties.clone(), + tr.resolved.clone().properties.clone(), ), type_annotation: field.type_annotation.clone(), is_self_recursive: false, @@ -3359,7 +3297,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { - __result.push((*fr.item).clone()); + __result.push(fr.item.clone()); } __result }); @@ -3414,7 +3352,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) let resolved_children = Rc::new({ let mut __result = Vec::new(); for cr in child_results.clone().iter().cloned() { - __result.push((*cr.item).clone()); + __result.push(cr.item.clone()); } __result }); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 8d0917f731a..76923b77bc0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -210,7 +210,7 @@ pub fn expand_transitive_services_once( registry: Rc>>, ) -> Rc>> { modules.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, item: Rc| { - let item_name = authored_name_at((*m.type_env).clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at(m.type_env.clone().source_indices.clone(), item.clone()); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { let has_no_body = (item.body.clone() == None); @@ -218,7 +218,7 @@ if has_no_body.clone() { reg2.clone() } else { { - let called = collect_called_func_names(item.body.clone().clone().unwrap(), (*m.type_env).clone().source_indices.clone()); + let called = collect_called_func_names(item.body.clone().clone().unwrap(), m.type_env.clone().source_indices.clone()); let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(®2, callee_name.clone()) { Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 5d4fde8c998..ef23eba9abf 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -498,8 +498,7 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.clone().iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) - { + if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 968c11e800a..27e0642597b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -898,7 +898,7 @@ pub fn instantiate_algebra_type( let sb = instantiate_algebra_type(second.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))))))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -928,13 +928,13 @@ pub fn instantiate_algebra_type( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); let rb = instantiate_algebra_type(r.clone(), base.clone(), source_indices.clone()); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_callable_type))))))))))))))))))))))))))))))(param_nodes, (*rb.ty).clone()), + ty: make_callable_type(param_nodes, rb.ty.clone()), diagnostics: v1_rt::concat(param_diags, rb.diagnostics.clone()), }) } @@ -962,7 +962,7 @@ pub fn instantiate_algebra_field( let param_types = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -979,10 +979,10 @@ pub fn instantiate_algebra_field( source_indices.clone(), ); let field_ty = if ((param_types.clone().len() as i64) > 0) { - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(algebra_method_field))))))))))))))))))))))))))))))( + algebra_method_field( template.name.clone(), param_types.clone(), - (*return_b.ty).clone(), + return_b.ty.clone(), ) } else { algebra_value_field(template.name.clone(), return_b.ty.clone()) @@ -1017,7 +1017,7 @@ pub fn enrich_kernel_type( let fields = Rc::new({ let mut __result = Vec::new(); for b in field_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1527,7 +1527,7 @@ pub fn apply_type_substitution( source_indices.clone(), ); Rc::new(KernelTypeBuild { - ty: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(make_tuple_type))))))))))))))))))))))))))))))((*fb.ty).clone(), (*sb.ty).clone()), + ty: make_tuple_type(fb.ty.clone(), sb.ty.clone()), diagnostics: v1_rt::concat(fb.diagnostics.clone(), sb.diagnostics.clone()), }) } @@ -1551,7 +1551,7 @@ pub fn apply_type_substitution( let param_nodes = Rc::new({ let mut __result = Vec::new(); for b in param_bs.clone().iter().cloned() { - __result.push((*b.ty).clone()); + __result.push(b.ty.clone()); } __result }); @@ -1575,7 +1575,7 @@ pub fn apply_type_substitution( for pn in param_nodes.iter().cloned() { __result.push(make_param_node( "_".to_string(), - Rc::new(pn.clone()), + pn.clone(), None, no_span(), no_span(), @@ -2291,7 +2291,8 @@ pub fn node_type_equals_core( if (params_eq == false) { false } else { - match left.inferred + match left + .inferred .clone() .as_deref() .cloned() @@ -2299,7 +2300,8 @@ pub fn node_type_equals_core( Some(InferredNode::Resolved { node: left_ret, .. - }) => match right.inferred + }) => match right + .inferred .clone() .as_deref() .cloned() @@ -2639,11 +2641,7 @@ pub fn infer_binop_type_node( let is_product = (left_type.connective.clone() == Connective::Conj); if is_product { match first_matching_algebra_field(left_type.clone(), candidates, source_indices) { - Some(m) => match (*m.field_node).clone().inferred - .clone() - .as_deref() - .cloned() - { + Some(m) => match m.field_node.clone().inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if ((rt.params.clone().len() as i64) > 0) { match rt.inferred.clone().as_deref().cloned() { diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 5e140789267..0da15e2a8e5 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -194,10 +194,7 @@ pub fn normalize_graph( __result.extend( (*check_bare_containers( item.clone(), - authored_name_at( - source_indices.clone(), - m.module.clone(), - ), + authored_name_at(source_indices.clone(), m.module.clone()), source_indices.clone(), )) .iter() diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 0c41f844575..160e9fc850f 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,39 +690,14 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn whole_value_borrow_count(usage: Rc) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for c in usage.consumers.clone().iter().cloned() { - if match c.kind.clone() { - EdgeKind::Read => true, - EdgeKind::Threaded => true, - _ => false, - } { - __result.push(c); - } - } - __result - }) - .len() as i64) -} - -pub fn build_movable_set( - proof: Rc, - param_names: Rc>, -) -> Rc> { +pub fn build_movable_set(proof: Rc) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((match (*make_decision(usage.clone())).clone() { - OwnershipDecision::SoleOwner { .. } => true, - _ => false, - } && (whole_value_borrow_count(usage.clone()) == 0)) - && (is_owned_local(usage.binding_kind.clone()) - || v1_rt::set_contains(¶m_names, usage.name.clone()))) + if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) { __result.push(usage); } @@ -1258,337 +1233,6 @@ pub fn analyze_ownership( } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct LiveState { - pub name: String, - pub whole: bool, - pub any_field: bool, - pub fields: Rc>, -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct MoveLicenseAccum { - pub live: Rc>>, - pub licensed: Rc>, -} - -pub fn move_site_key(name: String, span_start: i64) -> String { - v1_rt::concat( - v1_rt::concat(name, "@".to_string()), - (span_start).to_string(), - ) -} - -pub fn empty_live_state(name: String) -> Rc { - Rc::new(LiveState { - name: name, - whole: false, - any_field: false, - fields: v1_rt::rc_empty_set::(), - }) -} - -pub fn live_state_of(acc: Rc, name: String) -> Rc { - match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st.clone(), - None => empty_live_state(name.clone()), - } -} - -pub fn record_whole_use_site( - acc: Rc, - name: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !st.any_field.clone()); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: true, - any_field: st.any_field.clone(), - fields: st.fields.clone(), - }), - ), - licensed: licensed, - }) - } -} - -pub fn record_field_use_site( - acc: Rc, - name: String, - field: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !v1_rt::set_contains(&st.fields.clone(), field.clone())); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: st.whole.clone(), - any_field: true, - fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), - }), - ), - licensed: licensed, - }) - } -} - -pub fn merge_live_states(a: Rc, b: Rc) -> Rc { - Rc::new(LiveState { - name: a.name.clone(), - whole: (a.whole.clone() || b.whole.clone()), - any_field: (a.any_field.clone() || b.any_field.clone()), - fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), - }) -} - -pub fn merge_branch_licenses(branches: Rc>>) -> Rc { - branches.iter().cloned().fold( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - |acc: Rc, br: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); - { - let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) - .iter() - .cloned() - .fold( - acc.live, - |lm: Rc>>, k: String| { - let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { - Some(s) => s.clone(), - None => empty_live_state(k.clone()), - }; - match v1_rt::map_get(&lm, k.clone()) { - Some(a_st) => v1_rt::rc_map_insert( - lm.clone(), - k.clone(), - merge_live_states(a_st.clone(), b_st.clone()), - ), - None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), - } - }, - ); - let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) - .iter() - .cloned() - .fold(acc.licensed, |l: Rc>, k: String| { - v1_rt::rc_map_insert(l, k.clone(), true) - }); - Rc::new(MoveLicenseAccum { - live: live_merged.clone(), - licensed: lic_merged.clone(), - }) - } - }, - ) -} - -pub fn license_walk( - acc: Rc, - texpr: Rc, - in_capture: bool, - si: Rc>>, -) -> Rc { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*texpr.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_whole_use_site( - acc.clone(), - expr_var_name_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - ExprData::ExprLiteral { value: _, .. } => acc.clone(), - ExprData::ExprFieldAccess { .. } => { - let base_node = field_access_base(texpr.clone()); - match (*base_node.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_field_use_site( - acc.clone(), - expr_var_name_at(base_node.clone(), si.clone()), - field_access_field_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - _ => license_walk( - acc.clone(), - base_node.clone(), - in_capture.clone(), - si.clone(), - ), - } - } - ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }), - ExprData::ExprMethodCall { .. } => { - let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }); - license_walk( - args_acc, - method_receiver(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprIf => { - let t_acc = license_walk( - acc.clone(), - if_then_branch(texpr.clone()), - in_capture.clone(), - si.clone(), - ); - let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => { - license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) - } - None => acc.clone(), - }; - let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); - license_walk( - merged, - if_condition(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprMatch => { - let branch_accs = Rc::new({ - let mut __result = Vec::new(); - for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { - __result.push(license_walk( - acc.clone(), - arm_body(arm_node.clone()), - in_capture.clone(), - si.clone(), - )); - } - __result - }); - let merged = merge_branch_licenses(branch_accs); - license_walk( - merged, - match_scrutinee(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprLet => { - let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), - None => acc.clone(), - }; - license_walk( - body_acc, - let_value(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprLambda => { - license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) - } - ExprData::ExprForEach => { - let body_acc = - license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); - license_walk( - body_acc, - foreach_collection(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, field: Rc| { - license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) - }), - _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - } - }) -} - -pub fn build_move_site_licenses( - body: Rc, - si: Rc>>, -) -> Rc> { - { - let walked = license_walk( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - body, - false, - si, - ); - walked.licensed.clone() - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 55472764352..b2340d2e960 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -23,7 +23,7 @@ use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; use crate::v1_std_core::Cardinality::{CardOptional, Required}; -use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError}; +use crate::v1_std_core::CompilerDiagnostic::ParseError; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, @@ -91,11 +91,7 @@ pub fn token_stream_position(stream: Rc) -> i64 { } pub fn token_stream_first(stream: Rc) -> Option> { - stream - .all - .clone() - .get((stream.pos.clone()) as usize) - .cloned() + stream.all.clone().get(stream.pos.clone() as usize).cloned() } pub fn token_stream_advance(stream: Rc, n: i64) -> Rc { @@ -3504,11 +3500,11 @@ pub fn parse_type_body_after_eq( err: r.err.clone(), }); } - let first_variant = (*r.variant).clone(); + let first_variant = r.variant.clone(); let rest = parse_more_variants_acc( r.tokens.clone(), r.ctx.clone(), - Rc::new(vec![Rc::new(first_variant)]), + Rc::new(vec![first_variant]), ); if has_err(rest.err.clone()) { return Rc::new(ItemResult { @@ -4303,7 +4299,7 @@ pub fn parse_positional_variant_type_fields( Cardinality::Required, None, None, - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), kernel_span("0".to_string()), ); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4714,8 +4710,8 @@ pub fn parse_callable_param_types( "".to_string(), r.type_expr.clone(), None, - (*r.type_expr).clone().span.clone(), - (*r.type_expr).clone().span.clone(), + r.type_expr.clone().span.clone(), + r.type_expr.clone().span.clone(), ); acc = v1_rt::rc_list_push(acc.clone(), param); match (*eat(r.tokens.clone(), Rc::new(ExpectedToken::ExpectComma))).clone() { @@ -4762,9 +4758,9 @@ pub fn finish_type_expr_from_name( if has_err(r.err.clone()) { return r.clone(); } - let first_arg = (*r.type_expr).clone(); + let first_arg = r.type_expr.clone(); let type_args = - collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![Rc::new(first_arg)])); + collect_type_args(r.tokens.clone(), r.ctx.clone(), Rc::new(vec![first_arg])); if has_err(type_args.err.clone()) { return Rc::new(TypeResult { type_expr: dummy_te.clone(), @@ -5094,7 +5090,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { let f = make_field_node( name, - Rc::new(te.clone()), + te.clone(), te.return_cardinality.clone(), None, from_key, @@ -5337,7 +5333,7 @@ pub fn parse_fn_after_kw( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5347,7 +5343,7 @@ pub fn parse_fn_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5439,7 +5435,7 @@ pub fn parse_fn_body_from_prefix( err: body_result.err.clone(), }); } - let body = (*body_result.expr).clone(); + let body = body_result.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5449,7 +5445,7 @@ pub fn parse_fn_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5671,7 +5667,7 @@ pub fn parse_block_item_after_kw( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5681,7 +5677,7 @@ pub fn parse_block_item_after_kw( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5741,7 +5737,7 @@ pub fn parse_block_body_from_prefix( err: r.err.clone(), }); } - let body = (*r.expr).clone(); + let body = r.expr.clone(); let item = Rc::new(Node { name: name.clone(), span: start_span.clone(), @@ -5751,7 +5747,7 @@ pub fn parse_block_body_from_prefix( inferred: inferred, return_cardinality: Cardinality::Required, uses: uses, - body: Some(Rc::new(body)), + body: Some(body), connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), @@ -5936,23 +5932,23 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); endpoint = __tco_0; continue; } "auth" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth = __tco_0; continue; } "auth_input" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_input = __tco_0; continue; } "auth_source" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); auth_source = __tco_0; continue; } "rate_limit" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); rate_limit = __tco_0; continue; } "retry" => { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); retry = __tco_0; continue; } @@ -6879,49 +6875,49 @@ pub fn parse_rest_fields( ctx = r3.ctx.clone(); if (fname.clone() == transport_url_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { if (fname.clone() == transport_method_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { if (fname.clone() == transport_path_template_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { if (fname.clone() == transport_query_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { if (fname.clone() == transport_body_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { if (fname.clone() == transport_response_format_key()) { { - let __tco_0 = Some((*r3.expr).clone()); + let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { if (fname.clone() == transport_headers_key()) { - let h = match (*(*r3.expr).clone().expr_data.clone()).clone() { - ExprData::ExprRecordLit { .. } => (*r3.expr).clone().children.clone(), + let h = match (*r3.expr.clone().expr_data.clone()).clone() { + ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { transport: dummy.clone(), tokens: tokens.clone(), @@ -7060,7 +7056,7 @@ pub fn parse_shell_fields( }; { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; stdin = __tco_1; continue; @@ -7166,7 +7162,7 @@ pub fn parse_file_fields( if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); - let __tco_1 = Some((*r3.expr).clone()); + let __tco_1 = Some(r3.expr.clone()); ctx = __tco_0; base_path = __tco_1; continue; @@ -7670,7 +7666,7 @@ pub fn parse_op_body_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = Some((*r.transport).clone()); + let __tco_2 = Some(r.transport.clone()); tokens = __tco_0; ctx = __tco_1; transport = __tco_2; @@ -8136,7 +8132,7 @@ pub fn parse_exit_entries_acc( err: r.err.clone(), }); } - let code = (*r.expr).clone(); + let code = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(ExitEntriesResult { @@ -8164,7 +8160,7 @@ pub fn parse_exit_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let code_str = status_expr_to_str(Rc::new(code), ctx.source_indices.clone()); + let code_str = status_expr_to_str(code, ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("exit_".to_string(), code_str); let entry = make_field_init_node( @@ -8174,10 +8170,10 @@ pub fn parse_exit_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8463,7 +8459,7 @@ pub fn parse_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(RespEntriesResult { @@ -8482,7 +8478,7 @@ pub fn parse_response_entries_acc( err: r3.err.clone(), }); } - let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let status_str = status_expr_to_str(status, ctx.source_indices.clone()); let type_name = node_to_name_str(r3.type_expr.clone(), ctx.source_indices.clone()); let prop_name = v1_rt::concat("response_".to_string(), status_str); let entry = make_field_init_node( @@ -8492,10 +8488,10 @@ pub fn parse_response_entries_acc( Rc::new(ExprData::ExprVar { binding_kind: None }), Rc::new(vec![]), None, - (*r3.type_expr).clone().span.clone(), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), + r3.type_expr.clone().span.clone(), ), - (*r3.type_expr).clone().span.clone(), + r3.type_expr.clone().span.clone(), no_span(), ); let e = eat(r3.tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); @@ -8612,7 +8608,7 @@ pub fn parse_mock_response_entries_acc( err: r.err.clone(), }); } - let status = (*r.expr).clone(); + let status = r.expr.clone(); let r2 = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectFatArrow)); if has_err(r2.err.clone()) { return Rc::new(MockEntriesResult { @@ -8631,7 +8627,7 @@ pub fn parse_mock_response_entries_acc( err: r3.err.clone(), }); } - let body = (*r3.expr).clone(); + let body = r3.expr.clone(); let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok { Some(t) => Some(t.shape.clone()), @@ -8641,9 +8637,9 @@ pub fn parse_mock_response_entries_acc( Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), _ => r3.tokens.clone(), }; - let status_str = status_expr_to_str(Rc::new(status), ctx.source_indices.clone()); + let status_str = status_expr_to_str(status, ctx.source_indices.clone()); let prop_name = v1_rt::concat("mock_".to_string(), status_str); - let entry = make_field_init_node(prop_name, Rc::new(body), make_span(0, 0), make_span(0, 0)); + let entry = make_field_init_node(prop_name, body, make_span(0, 0), make_span(0, 0)); let e = eat(desc_tokens.clone(), Rc::new(ExpectedToken::ExpectComma)); tokens = skip_newlines(match (*e).clone() { EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), @@ -8862,8 +8858,7 @@ pub fn parse_resource_entries( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = - v1_rt::rc_list_push(capabilities, r.capability.clone()); + let __tco_2 = v1_rt::rc_list_push(capabilities, r.capability.clone()); tokens = __tco_0; ctx = __tco_1; capabilities = __tco_2; @@ -9479,7 +9474,7 @@ pub fn parse_data_after_kw( err: r.err.clone(), }); } - let te = (*r.type_expr).clone(); + let te = r.type_expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectEq)); if has_err(r.err.clone()) { return Rc::new(ItemResult { @@ -9511,7 +9506,7 @@ pub fn parse_data_after_kw( connective: Connective::NoConnective, transport: None, properties: Rc::new(vec![]), - type_annotation: Some(Rc::new(te)), + type_annotation: Some(te), is_self_recursive: false, has_non_tail_self_call: false, match_pattern: None, @@ -9676,7 +9671,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { - let p = make_param_node(name, Rc::new(type_expr), None, start_span.clone(), name_span); + let p = make_param_node(name, type_expr, None, start_span.clone(), name_span); Rc::new(ParamResult { param: p, tokens: tokens.clone(), @@ -10038,7 +10033,7 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc Some((*r3.expr).clone()), + EatResult::EatConsumed { .. } => Some(r3.expr.clone()), EatResult::EatUnchanged { tokens: _, .. } => None, }; let node = Rc::new(Node { @@ -10169,8 +10164,8 @@ pub fn parse_expr_bp( if has_err(r.err.clone()) { return r.clone(); } - let lhs = (*r.expr).clone(); - parse_expr_loop(r.tokens.clone(), r.ctx.clone(), Rc::new(lhs), min_bp) + let lhs = r.expr.clone(); + parse_expr_loop(r.tokens.clone(), r.ctx.clone(), lhs, min_bp) } } @@ -10204,10 +10199,10 @@ pub fn parse_expr_loop( { let __tco_0 = post.tokens.clone(); let __tco_1 = post.ctx.clone(); - let __tco_2 = (*post.expr).clone(); + let __tco_2 = post.expr.clone(); tokens = __tco_0; ctx = __tco_1; - lhs = Rc::new(__tco_2); + lhs = __tco_2; continue; } } else { @@ -10275,10 +10270,10 @@ pub fn parse_expr_loop( { let __tco_0 = r.tokens.clone(); let __tco_1 = r.ctx.clone(); - let __tco_2 = (*r.expr).clone(); + let __tco_2 = r.expr.clone(); tokens = __tco_0; ctx = __tco_1; - lhs = Rc::new(__tco_2); + lhs = __tco_2; continue; } } else { @@ -11396,7 +11391,7 @@ pub fn parse_index_or_slice( err: r.err.clone(), }); } - let first_expr = (*r.expr).clone(); + let first_expr = r.expr.clone(); let tokens = r.tokens.clone(); let ctx = r.ctx.clone(); if tok_is_dot_dot(token_stream_first(tokens.clone())) { @@ -11410,7 +11405,7 @@ pub fn parse_index_or_slice( err: r.err.clone(), }); } - let end_expr = (*r.expr).clone(); + let end_expr = r.expr.clone(); let r = expect(r.tokens.clone(), Rc::new(ExpectedToken::ExpectRBracket)); if has_err(r.err.clone()) { return Rc::new(ExprResult { @@ -11423,7 +11418,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprSlice), - Rc::new(vec![base, Rc::new(first_expr), Rc::new(end_expr)]), + Rc::new(vec![base, first_expr, end_expr]), None, span, ), @@ -11446,7 +11441,7 @@ pub fn parse_index_or_slice( Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIndex), - Rc::new(vec![base, Rc::new(first_expr)]), + Rc::new(vec![base, first_expr]), None, span, ), @@ -11581,8 +11576,7 @@ pub fn parse_single_arg(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprIf), - Rc::new(vec![Rc::new(condition), Rc::new(then_branch)]), + Rc::new(vec![condition, then_branch]), None, span, ), @@ -12869,7 +12863,7 @@ pub fn parse_for(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index d3042fd1aa4..a0826e3e1bf 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -229,6 +229,12 @@ pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() } +pub fn sorted_map_keys(m: &HashMap) -> Vec { + let mut keys = map_keys(m); + keys.sort(); + keys +} + pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() } @@ -329,6 +335,40 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. +// take_owned_counted: the fail-closed replacement for the silent +// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: +// a failure arm must refuse or be counted, never silently widen). The ownership +// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose +// per-site frequency must stay observable, so the clone arm counts per emitted +// site (site = ":" of the use-site the emitter rewrote). +thread_local! { + static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = + std::cell::RefCell::new(HashMap::new()); +} + +pub fn take_owned_counted(x: Rc, site: &'static str) -> T { + Rc::try_unwrap(x).unwrap_or_else(|rc| { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); + (*rc).clone() + }) +} + +pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| { + let mut v: Vec<(String, u64)> = m + .borrow() + .iter() + .map(|(site, n)| (site.to_string(), *n)) + .collect(); + v.sort(); + v + }) +} + +pub fn reset_take_owned_clone_fallbacks() { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); +} + pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); From e97eea1ad087794452086ffe4f7ebd252361ca94 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:03:45 +0000 Subject: [PATCH 22/27] Restore sibling-lane files swept by the stale scaffolding-restore merge (to origin/main versions) Co-Authored-By: Claude Fable 5 --- ROADMAP.md | 18 ++-- dag/gunbc/roadmap_authority.dag | 18 ++-- dag/test/claim/roadmap_authority_test.dag | 8 +- .../map_lookup_dual_dispatch_retired.dag | 10 ++ dag/test/retirement/model.dag | 10 ++ src/v1/tests/src/lib.rs | 2 - .../src/map_lookup_dual_dispatch_test.rs | 92 ------------------- .../tests/src/measure_grounded_deref_test.rs | 1 + 8 files changed, 43 insertions(+), 116 deletions(-) create mode 100644 dag/test/retirement/map_lookup_dual_dispatch_retired.dag create mode 100644 dag/test/retirement/model.dag delete mode 100644 src/v1/tests/src/map_lookup_dual_dispatch_test.rs diff --git a/ROADMAP.md b/ROADMAP.md index 578ba2175d5..c0b8e7ae15f 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -10,21 +10,21 @@ Legend: `[x]` done · `[ ]` todo · **indentation = depends on the item it sits Anchor (do not flip-flop): `.dag` = truth; v2 emits its own seed (no stage0 hand-edits); the trust chain is discharged by execution; then the hand-written seed is deleted. Terminal is **hand-written compiler logic → 0**, not zero bytes of Rust: a pinned v2-emitted bootstrap kernel (~8–15k LOC — `claim_executor`, evaluator host-physics, the regen oracle) survives as the content-addressed seed. → [plan](docs/plans/v2-self-hosting.md) · [de-fork audit](docs/plans/dag-v2-defork-audit.md) · [seed census](docs/plans/seed-shrink-census.md) -Ground truth (2026-07-01): `src/v1` = ~174k hand-written `.rs` LOC (the ~154k figure in older docs is stale) + 44 `.dag` files of v1's own modeling; `src/v2` = 839 `.dag`, zero `.rs`. HAND_MAINTAINED roster is down 24 → 9 files + `module_path_index` (~20.6k LOC); `patch_*` 3 → 1. The regen gate proves byte-identity per the COMMITTED seed (two-generation): emitter improvements are latent until a cutover, and the cargo-green receipt is episodic (`#[ignore]`, ~3–5min), not continuous — today's continuous walls are byte-identity + the interim fixpoint + well-typed emit. +Ground truth (2026-07-05): `src/v1` = ~174k hand-written `.rs` LOC (the ~154k figure in older docs is stale) + 44 `.dag` files of v1's own modeling; `src/v2` = 874 `.dag`, zero `.rs`. HAND_MAINTAINED roster is down 24 → 7 files + `module_path_index` (~22.3k LOC: the three lens projections drained #6158/#6211/#6212; `phase_profile.rs` ADDED 2026-07-04 with its own dissolution trigger); `patch_*` is fully dead in-tree. The regen gate proves byte-identity per the COMMITTED seed (two-generation): emitter improvements are latent until a cutover, and the cargo-green receipt is episodic (`#[ignore]`, ~3–5min), not continuous — today's walls are byte-identity + the full 92-file byte fixed point (#6218) + well-typed emit. INTERIM (operator-accepted, 2026-07-05): the CI floor cannot complete inside its 10-minute budget (#6232) while batch-1 compile-clean runs ~40+min, so these walls are proven by LOCAL execution with documented receipts, not by CI, until the §2 compile-clean work lands. -**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473) · emitted crate cargo-green, 0 rustc errors ✓ (#5777/#5873, re-verified #6099) · `regen --verify` in CI ✓ (#5873) · interim fixpoint gate, 2-of-92 roster ✓ (#6009) → **▸ NOW: regen-cutover cadence · HAND queue drain · full-roster real fixed point** → seed-honesty (DDC) → **TERMINAL: `src/v1` deleted** +**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473) · emitted crate cargo-green, 0 rustc errors ✓ (#5777/#5873, re-verified #6099 — for the THEN-seed; fresh emit is red today, see NOW) · `regen --verify` in CI ✓ (#5873) · interim fixpoint gate, 2-of-92 roster ✓ (#6009) · full-roster 92-file byte-fold + host-grounded digest ✓ (#6218) · v1 self-resolution: #6235 arm fixed ✓ (#6250), #6241 `get`-registry arm → #6255 in flight (operator-resolved collision: register the builtin, preserving P2's O(1) token access) → **▸ NOW: emitter restoration to fresh-emit cargo-green (#6243 C8 tail + residue — cutover #1 is BLOCKED on it; 1667 rustc errors measured 2026-07-05) · HAND queue drain · fixed-point residue (Node-level compare + placeholder hashes)** → seed-honesty (DDC) → **TERMINAL: `src/v1` deleted** -- [ ] **regen-cutover cadence** — absorb latent emitter fixes into the committed seed (#6099 merged with the `machine_width` emit test still ignored: two-generation regen means every emitter improvement is invisible until a cutover). Each cutover un-ignores its witnesses; a stale seed hides emitter regressions. - - [ ] **real fixed point** — `content_hash` stage1==stage2 over the FULL seed: host-ground `source_text_code_unit_digest`, widen the `SelfHostRealizedComparisonGate` byte-fold from its 2-file roster (`lib.rs`, `v1_rt.rs`) to all 92 GENERATED files, dissolve the `bootstrap.dag` placeholder hashes. The #6009 gate is INTERIM by its own disposition; this milestone gates the bulk cutover-delete, seed-honesty, and the shelved TS self-host. - - [ ] **seed-honesty discharge** (Diverse Double-Compiling) — modeled in `bootstrap.dag` (`SeedHonestyDischarge`), no execution exists; needs a reproducible artifact to double-compile. Design proposal (second-compiler candidate `ddc_reference_compiler` + computed fixed-point digest, reusing `self_host.dag`'s `canonical_emitted_bytes_digest`; flags open for operator sign-off): [seed-honesty discharge design](docs/plans/seed-honesty-discharge-design.md) +- [ ] **regen-cutover cadence** — absorb latent emitter fixes into the committed seed (#6099 merged with the `machine_width` emit test still ignored: two-generation regen means every emitter improvement is invisible until a cutover). Each cutover un-ignores its witnesses; a stale seed hides emitter regressions. RECEIPT (2026-07-05, local, #6253 — measured on a tree with the `get` sites resolvable; numbers independent of which #6241-gap fix lands, #6255 is the operator-chosen one): regen write-mode completes and materializes the latent backlog — 40 generated files / ~4.3k lines of drift since their last per-file writes — but the fresh crate is cargo-RED: 1667 rustc errors (E0282/E0308/E0425/E0614/E0631; dominant class = #6243's deref-boxing + alias-brand C8 tail). Cutover #1 is BLOCKED on emitter restoration to fresh-emit cargo-green; until it lands, `regen --verify` is red on that drift by construction and every emitter fix stays latent (the broken cutover was measured and NOT committed). + - [ ] **real fixed point** — `content_hash` stage1==stage2 over the FULL seed. LANDED (#6218): `source_text_code_unit_digest` host-grounded on `atom_identity_hash`, and the `SelfHostRealizedComparisonGate` byte-fold widened from the 2-file roster to all 92 GENERATED files via the regen manifest (self-updating roster; the gate's INTERIM disposition deleted). REMAINING: the Node-level comparison — emitted compiler Node vs emitted bytes (`generate_stage_candidate_from_ingest` has zero consumers today) — dissolve the `bootstrap.dag` placeholder hashes, and widen the provenance witness off its 1-file roster. This milestone gates the bulk cutover-delete, seed-honesty, and the shelved TS self-host. + - [ ] **seed-honesty discharge** (Diverse Double-Compiling) — modeled in `bootstrap.dag` (`SeedHonestyDischarge`), no execution exists; worse, the modeled witness is fail-open by construction (its evidence argument is the same atom it checks against — Holds trivially, no red case constructible) until Stage 3's executing consumer lands. Needs a reproducible artifact to double-compile. Design proposal (second-compiler candidate `ddc_reference_compiler` + computed fixed-point digest, reusing `self_host.dag`'s `canonical_emitted_bytes_digest`; FLAGs A–D open for operator sign-off): [seed-honesty discharge design](docs/plans/seed-honesty-discharge-design.md) - [ ] **TERMINAL — collapse `src/v1`**: one atomic regen cutover-delete of the 92 GENERATED files (~117k of stage0's ~137k LOC) + per-module test deletes as migration lands + pin the terminal kernel. Requires: HAND queue empty · real fixed point · test-migration green · seed-honesty. -- [ ] **drain the HAND_MAINTAINED queue** (9 files + `module_path_index`, ~20.6k LOC) + kill the last `patch_*` (`patch_complexity_linearity_audit_mod`) — order: `main.rs` flip-back → the three lens projections → `coproduct_reflection` (de-fork-coupled) → `v1_interpreter` pure-eval emit (kernel D [plan](docs/plans/interpreter-kernel-d.md)) → `cli_run.rs` (largest, ~9.2k LOC; #6046 hard-gates net-new logic INTO it — verified pure-projection HAND folds carved out per #6211/#6212/#6217). Host-physics files (`recorded_fixture` · `resolved_graph_cache`) are terminal-kernel pins, not dissolution targets. - - [ ] **no-dual-representation-test lens rebuilt pure-v2** (#6104) — lens verdict moves off v1 Rust, the lens-E retirement pattern continued (in flight) — ⏳ awaiting sign-off +- [ ] **drain the HAND_MAINTAINED queue** (7 files + `module_path_index`, ~22.3k LOC; three lens projections drained ✓ #6158/#6211/#6212 · last `patch_*` dead in-tree ✓ · `phase_profile.rs` added 2026-07-04, dissolution trigger `realization_measurement_loop` Phase 0) — remaining dissolution order: `main.rs` flip-back (attempted #6226, self-reverted — the emitter lost Ci-subcommand/`extract_module_path` emission in #6053's dag_collect split; restore the emit gaps first) → `coproduct_reflection` (de-fork-coupled) → `v1_interpreter` pure-eval emit (kernel D [plan](docs/plans/interpreter-kernel-d.md); model+witness landed #6229, phase ModelAndWitnessOnly, blocked on emit_host transport wiring) → `cli_run.rs` (largest, ~12.1k LOC — grew as the absorption point for the drained projections' pure folds per #6211/#6212/#6217; #6046 hard-gates net-new logic INTO it). Host-physics files (`recorded_fixture` · `resolved_graph_cache`) are terminal-kernel pins, not dissolution targets. + - [ ] **no-dual-representation-test lens rebuilt pure-v2** (#6104) — lens verdict moves off v1 Rust, the lens-E retirement pattern continued (landed #6104) — ⏳ awaiting sign-off - [ ] **de-fork dag ↔ v2 grounding cluster** (one std authority — the fixed point must be well-defined over ONE algebra): `algebra` first (LIVE fail-open, 75 floor entries) → effects/float/integer/logic → `nat` LAST. Operator rulings stand: coproduct = structural authority; grounded-realization wins. The cost of not de-forking is no longer theoretical: the `extdeps.shell` dag↔v2 fork silently shadowed `shell.Which` in the two-root module index and kept main red from #6097 until the de-fork hotfix. [brief](docs/plans/dag-v2-defork-audit.md) - [ ] **Root B repoints** — def-unification (coproduct authority + aliases) → repoints (algebra/nat/integer/float/logic/effects/verification) → 🟡-marker dissolution (keystone #5552 merged) - [ ] v1-coupled `coercion`/`node` renames — deferred to v1-delete -- [ ] **test-migration lane** — ~90 v1 test modules / ~939 `#[test]` fns move to floor `*_test.dag` witnesses before their module deletes (hard gate per module, bulk-delete forbidden); ~71 modules have NO floor equivalent today (census §5B: infer_semantics 51 · source_audit 41 · effects 36 · pipeline.rs 418 concern-level only). Parallelizable now; gates the terminal collapse per module. -- [ ] **make cargo-green continuous (or cheap)** — `route_a_emit_fresh_cargo_green_test` is ignored (~3–5min); an emitter regression that keeps bytes stable per the old seed but breaks a fresh build surfaces late. Decide: fold into `RegenVerifyGate` (doubles its cost) or a scheduled receipt. +- [ ] **test-migration lane** — live debt per the `v2.lens.test_migration_debt` shrink-only ratchet: 73 v1 test modules / 731 `#[test]` fns / ~23k LOC with no exact-stem floor witness (baselines 77/912/28546 set 2026-07-02; `pipeline.rs` alone is 417 fns, the dominant unit); the delete-guard blocks removing a v1 test module without its floor witness (hard gate per module, bulk-delete forbidden). **Scrutinize before migrating (operator, 2026-07-05): tests are not inherently valuable — triage each module first (migrate · delete-as-redundant · delete-as-low-value); the guard currently requires an exact-stem witness for ANY delete, so the lane's first deliverable is a typed retirement path through the guard, never a bypass.** Parallelizable now; gates the terminal collapse per module. NOTE: migrated witnesses run on the local discovery path — CI enrollment is opt-in (#6232) until affected-set selection lands. +- [ ] **make cargo-green continuous (or cheap)** — `route_a_emit_fresh_cargo_green_test` is ignored (~3–5min); an emitter regression that keeps bytes stable per the old seed but breaks a fresh build surfaces late. Decide: fold into `RegenVerifyGate` (doubles its cost) or a scheduled receipt. (This exact failure mode materialized 2026-07-05: fresh emit = 1667 rustc errors, accumulated invisibly while the byte wall was dark — see the regen-cutover receipt.) ## 2. Compute fabric — own the infra (CI · deploy · control plane) diff --git a/dag/gunbc/roadmap_authority.dag b/dag/gunbc/roadmap_authority.dag index f7455a7c82d..e405fd9ff45 100644 --- a/dag/gunbc/roadmap_authority.dag +++ b/dag/gunbc/roadmap_authority.dag @@ -99,21 +99,21 @@ fn section_1() -> RoadmapSection { title: "1. Get off v1 — v2 self-hosts (TERMINAL: `src/v1` deleted)", elements: [ section_prose(content: "Anchor (do not flip-flop): `.dag` = truth; v2 emits its own seed (no stage0 hand-edits); the trust chain is discharged by execution; then the hand-written seed is deleted. Terminal is **hand-written compiler logic → 0**, not zero bytes of Rust: a pinned v2-emitted bootstrap kernel (~8–15k LOC — `claim_executor`, evaluator host-physics, the regen oracle) survives as the content-addressed seed. → [plan](docs/plans/v2-self-hosting.md) · [de-fork audit](docs/plans/dag-v2-defork-audit.md) · [seed census](docs/plans/seed-shrink-census.md)"), - section_prose(content: "Ground truth (2026-07-01): `src/v1` = ~174k hand-written `.rs` LOC (the ~154k figure in older docs is stale) + 44 `.dag` files of v1's own modeling; `src/v2` = 839 `.dag`, zero `.rs`. HAND_MAINTAINED roster is down 24 → 9 files + `module_path_index` (~20.6k LOC); `patch_*` 3 → 1. The regen gate proves byte-identity per the COMMITTED seed (two-generation): emitter improvements are latent until a cutover, and the cargo-green receipt is episodic (`#[ignore]`, ~3–5min), not continuous — today's continuous walls are byte-identity + the interim fixpoint + well-typed emit."), - section_prose(content: "**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473) · emitted crate cargo-green, 0 rustc errors ✓ (#5777/#5873, re-verified #6099) · `regen --verify` in CI ✓ (#5873) · interim fixpoint gate, 2-of-92 roster ✓ (#6009) → **▸ NOW: regen-cutover cadence · HAND queue drain · full-roster real fixed point** → seed-honesty (DDC) → **TERMINAL: `src/v1` deleted**"), + section_prose(content: "Ground truth (2026-07-05): `src/v1` = ~174k hand-written `.rs` LOC (the ~154k figure in older docs is stale) + 44 `.dag` files of v1's own modeling; `src/v2` = 874 `.dag`, zero `.rs`. HAND_MAINTAINED roster is down 24 → 7 files + `module_path_index` (~22.3k LOC: the three lens projections drained #6158/#6211/#6212; `phase_profile.rs` ADDED 2026-07-04 with its own dissolution trigger); `patch_*` is fully dead in-tree. The regen gate proves byte-identity per the COMMITTED seed (two-generation): emitter improvements are latent until a cutover, and the cargo-green receipt is episodic (`#[ignore]`, ~3–5min), not continuous — today's walls are byte-identity + the full 92-file byte fixed point (#6218) + well-typed emit. INTERIM (operator-accepted, 2026-07-05): the CI floor cannot complete inside its 10-minute budget (#6232) while batch-1 compile-clean runs ~40+min, so these walls are proven by LOCAL execution with documented receipts, not by CI, until the §2 compile-clean work lands."), + section_prose(content: "**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473) · emitted crate cargo-green, 0 rustc errors ✓ (#5777/#5873, re-verified #6099 — for the THEN-seed; fresh emit is red today, see NOW) · `regen --verify` in CI ✓ (#5873) · interim fixpoint gate, 2-of-92 roster ✓ (#6009) · full-roster 92-file byte-fold + host-grounded digest ✓ (#6218) · v1 self-resolution: #6235 arm fixed ✓ (#6250), #6241 `get`-registry arm → #6255 in flight (operator-resolved collision: register the builtin, preserving P2's O(1) token access) → **▸ NOW: emitter restoration to fresh-emit cargo-green (#6243 C8 tail + residue — cutover #1 is BLOCKED on it; 1667 rustc errors measured 2026-07-05) · HAND queue drain · fixed-point residue (Node-level compare + placeholder hashes)** → seed-honesty (DDC) → **TERMINAL: `src/v1` deleted**"), section_group( label: "", nodes: [ - authored_wi(id: "5-regen-cutover", done: false, content: "**regen-cutover cadence** — absorb latent emitter fixes into the committed seed (#6099 merged with the `machine_width` emit test still ignored: two-generation regen means every emitter improvement is invisible until a cutover). Each cutover un-ignores its witnesses; a stale seed hides emitter regressions.", intricacy: IntricacyMedium, volume: VolumeMedium, repo: "gunbc"), - authored(id: "5-real-fixpoint", done: false, content: "**real fixed point** — `content_hash` stage1==stage2 over the FULL seed: host-ground `source_text_code_unit_digest`, widen the `SelfHostRealizedComparisonGate` byte-fold from its 2-file roster (`lib.rs`, `v1_rt.rs`) to all 92 GENERATED files, dissolve the `bootstrap.dag` placeholder hashes. The #6009 gate is INTERIM by its own disposition; this milestone gates the bulk cutover-delete, seed-honesty, and the shelved TS self-host."), - authored(id: "5-dissolve-patches", done: false, content: "**drain the HAND_MAINTAINED queue** (9 files + `module_path_index`, ~20.6k LOC) + kill the last `patch_*` (`patch_complexity_linearity_audit_mod`) — order: `main.rs` flip-back → the three lens projections → `coproduct_reflection` (de-fork-coupled) → `v1_interpreter` pure-eval emit (kernel D [plan](docs/plans/interpreter-kernel-d.md)) → `cli_run.rs` (largest, ~9.2k LOC; #6046 hard-gates net-new logic INTO it — verified pure-projection HAND folds carved out per #6211/#6212/#6217). Host-physics files (`recorded_fixture` · `resolved_graph_cache`) are terminal-kernel pins, not dissolution targets."), - derivable(id: "5-dual-rep-lens", prs: [6104], title: "**no-dual-representation-test lens rebuilt pure-v2**", description: "— lens verdict moves off v1 Rust, the lens-E retirement pattern continued (in flight)"), + authored_wi(id: "5-regen-cutover", done: false, content: "**regen-cutover cadence** — absorb latent emitter fixes into the committed seed (#6099 merged with the `machine_width` emit test still ignored: two-generation regen means every emitter improvement is invisible until a cutover). Each cutover un-ignores its witnesses; a stale seed hides emitter regressions. RECEIPT (2026-07-05, local, #6253 — measured on a tree with the `get` sites resolvable; numbers independent of which #6241-gap fix lands, #6255 is the operator-chosen one): regen write-mode completes and materializes the latent backlog — 40 generated files / ~4.3k lines of drift since their last per-file writes — but the fresh crate is cargo-RED: 1667 rustc errors (E0282/E0308/E0425/E0614/E0631; dominant class = #6243's deref-boxing + alias-brand C8 tail). Cutover #1 is BLOCKED on emitter restoration to fresh-emit cargo-green; until it lands, `regen --verify` is red on that drift by construction and every emitter fix stays latent (the broken cutover was measured and NOT committed).", intricacy: IntricacyMedium, volume: VolumeMedium, repo: "gunbc"), + authored(id: "5-real-fixpoint", done: false, content: "**real fixed point** — `content_hash` stage1==stage2 over the FULL seed. LANDED (#6218): `source_text_code_unit_digest` host-grounded on `atom_identity_hash`, and the `SelfHostRealizedComparisonGate` byte-fold widened from the 2-file roster to all 92 GENERATED files via the regen manifest (self-updating roster; the gate's INTERIM disposition deleted). REMAINING: the Node-level comparison — emitted compiler Node vs emitted bytes (`generate_stage_candidate_from_ingest` has zero consumers today) — dissolve the `bootstrap.dag` placeholder hashes, and widen the provenance witness off its 1-file roster. This milestone gates the bulk cutover-delete, seed-honesty, and the shelved TS self-host."), + authored(id: "5-dissolve-patches", done: false, content: "**drain the HAND_MAINTAINED queue** (7 files + `module_path_index`, ~22.3k LOC; three lens projections drained ✓ #6158/#6211/#6212 · last `patch_*` dead in-tree ✓ · `phase_profile.rs` added 2026-07-04, dissolution trigger `realization_measurement_loop` Phase 0) — remaining dissolution order: `main.rs` flip-back (attempted #6226, self-reverted — the emitter lost Ci-subcommand/`extract_module_path` emission in #6053's dag_collect split; restore the emit gaps first) → `coproduct_reflection` (de-fork-coupled) → `v1_interpreter` pure-eval emit (kernel D [plan](docs/plans/interpreter-kernel-d.md); model+witness landed #6229, phase ModelAndWitnessOnly, blocked on emit_host transport wiring) → `cli_run.rs` (largest, ~12.1k LOC — grew as the absorption point for the drained projections' pure folds per #6211/#6212/#6217; #6046 hard-gates net-new logic INTO it). Host-physics files (`recorded_fixture` · `resolved_graph_cache`) are terminal-kernel pins, not dissolution targets."), + derivable(id: "5-dual-rep-lens", prs: [6104], title: "**no-dual-representation-test lens rebuilt pure-v2**", description: "— lens verdict moves off v1 Rust, the lens-E retirement pattern continued (landed #6104)"), authored(id: "5-defork", done: false, content: "**de-fork dag ↔ v2 grounding cluster** (one std authority — the fixed point must be well-defined over ONE algebra): `algebra` first (LIVE fail-open, 75 floor entries) → effects/float/integer/logic → `nat` LAST. Operator rulings stand: coproduct = structural authority; grounded-realization wins. The cost of not de-forking is no longer theoretical: the `extdeps.shell` dag↔v2 fork silently shadowed `shell.Which` in the two-root module index and kept main red from #6097 until the de-fork hotfix. [brief](docs/plans/dag-v2-defork-audit.md)"), authored(id: "5-root-b", done: false, content: "**Root B repoints** — def-unification (coproduct authority + aliases) → repoints (algebra/nat/integer/float/logic/effects/verification) → 🟡-marker dissolution (keystone #5552 merged)"), authored(id: "5-v1coupled", done: false, content: "v1-coupled `coercion`/`node` renames — deferred to v1-delete"), - authored_wi(id: "5-test-migration", done: false, content: "**test-migration lane** — ~90 v1 test modules / ~939 `#[test]` fns move to floor `*_test.dag` witnesses before their module deletes (hard gate per module, bulk-delete forbidden); ~71 modules have NO floor equivalent today (census §5B: infer_semantics 51 · source_audit 41 · effects 36 · pipeline.rs 418 concern-level only). Parallelizable now; gates the terminal collapse per module.", intricacy: IntricacyMedium, volume: VolumeLarge, repo: "gunbc"), - authored(id: "5-cargo-green-continuous", done: false, content: "**make cargo-green continuous (or cheap)** — `route_a_emit_fresh_cargo_green_test` is ignored (~3–5min); an emitter regression that keeps bytes stable per the old seed but breaks a fresh build surfaces late. Decide: fold into `RegenVerifyGate` (doubles its cost) or a scheduled receipt."), - authored(id: "5-seed-honesty", done: false, content: "**seed-honesty discharge** (Diverse Double-Compiling) — modeled in `bootstrap.dag` (`SeedHonestyDischarge`), no execution exists; needs a reproducible artifact to double-compile. Design proposal (second-compiler candidate `ddc_reference_compiler` + computed fixed-point digest, reusing `self_host.dag`'s `canonical_emitted_bytes_digest`; flags open for operator sign-off): [seed-honesty discharge design](docs/plans/seed-honesty-discharge-design.md)"), + authored_wi(id: "5-test-migration", done: false, content: "**test-migration lane** — live debt per the `v2.lens.test_migration_debt` shrink-only ratchet: 73 v1 test modules / 731 `#[test]` fns / ~23k LOC with no exact-stem floor witness (baselines 77/912/28546 set 2026-07-02; `pipeline.rs` alone is 417 fns, the dominant unit); the delete-guard blocks removing a v1 test module without its floor witness (hard gate per module, bulk-delete forbidden). **Scrutinize before migrating (operator, 2026-07-05): tests are not inherently valuable — triage each module first (migrate · delete-as-redundant · delete-as-low-value); the guard currently requires an exact-stem witness for ANY delete, so the lane's first deliverable is a typed retirement path through the guard, never a bypass.** Parallelizable now; gates the terminal collapse per module. NOTE: migrated witnesses run on the local discovery path — CI enrollment is opt-in (#6232) until affected-set selection lands.", intricacy: IntricacyMedium, volume: VolumeLarge, repo: "gunbc"), + authored(id: "5-cargo-green-continuous", done: false, content: "**make cargo-green continuous (or cheap)** — `route_a_emit_fresh_cargo_green_test` is ignored (~3–5min); an emitter regression that keeps bytes stable per the old seed but breaks a fresh build surfaces late. Decide: fold into `RegenVerifyGate` (doubles its cost) or a scheduled receipt. (This exact failure mode materialized 2026-07-05: fresh emit = 1667 rustc errors, accumulated invisibly while the byte wall was dark — see the regen-cutover receipt.)"), + authored(id: "5-seed-honesty", done: false, content: "**seed-honesty discharge** (Diverse Double-Compiling) — modeled in `bootstrap.dag` (`SeedHonestyDischarge`), no execution exists; worse, the modeled witness is fail-open by construction (its evidence argument is the same atom it checks against — Holds trivially, no red case constructible) until Stage 3's executing consumer lands. Needs a reproducible artifact to double-compile. Design proposal (second-compiler candidate `ddc_reference_compiler` + computed fixed-point digest, reusing `self_host.dag`'s `canonical_emitted_bytes_digest`; FLAGs A–D open for operator sign-off): [seed-honesty discharge design](docs/plans/seed-honesty-discharge-design.md)"), authored(id: "5-collapse-v1", done: false, content: "**TERMINAL — collapse `src/v1`**: one atomic regen cutover-delete of the 92 GENERATED files (~117k of stage0's ~137k LOC) + per-module test deletes as migration lands + pin the terminal kernel. Requires: HAND queue empty · real fixed point · test-migration green · seed-honesty."), ], edges: [ diff --git a/dag/test/claim/roadmap_authority_test.dag b/dag/test/claim/roadmap_authority_test.dag index d798ee114e6..485165d28f3 100644 --- a/dag/test/claim/roadmap_authority_test.dag +++ b/dag/test/claim/roadmap_authority_test.dag @@ -75,14 +75,14 @@ fn witness_a_prose_verbatim() -> Bool { fn witness_b_ordered_interleaving() -> Bool { let o = out() - string_contains(s: o, pattern: "[seed census](docs/plans/seed-shrink-census.md)\n\nGround truth (2026-07-01):") - && string_contains(s: o, pattern: "byte-identity + the interim fixpoint + well-typed emit.\n\n**◆ Milestones:** front-end ✓") - && string_contains(s: o, pattern: "[charter](docs/plans/ci-process-end-to-end.md)\n\n**The core design rule (operator-signed, 2026-07-01):**") + string_contains(s: o, pattern: "[seed census](docs/plans/seed-shrink-census.md)\n\nGround truth (2026-07-05):") + && string_contains(s: o, pattern: "until the §2 compile-clean work lands.\n\n**◆ Milestones:** front-end ✓") + && string_contains(s: o, pattern: "[host-converge inventory](docs/plans/host-converge-inventory.md)\n\n**The core design rule (operator-signed, 2026-07-01):**") && string_contains(s: o, pattern: "Phase 2, earned by receipts.\n\n**◆ Milestones:** OOM root-caused") } fn witness_b_order_discriminator() -> Bool { - !string_contains(s: out(), pattern: "**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473)\n\nGround truth (2026-07-01):") + !string_contains(s: out(), pattern: "**◆ Milestones:** front-end ✓ · emit-rust well-typed ✓ · cross-tree import ✓ (#5473)\n\nGround truth (2026-07-05):") } fn witness_merge_perturb_does_not_flip_boxes() -> Bool { diff --git a/dag/test/retirement/map_lookup_dual_dispatch_retired.dag b/dag/test/retirement/map_lookup_dual_dispatch_retired.dag new file mode 100644 index 00000000000..0b6684a71e8 --- /dev/null +++ b/dag/test/retirement/map_lookup_dual_dispatch_retired.dag @@ -0,0 +1,10 @@ +module test.retirement.map_lookup_dual_dispatch_retired + +import test.retirement.model { TestModuleRetirement, DeleteLowValue } + +data map_lookup_dual_dispatch_retirement: TestModuleRetirement = TestModuleRetirement { + module: "map_lookup_dual_dispatch_test.rs", + disposition: DeleteLowValue { + reason: "Residual of the 5-test-migration lane. Four runtime tests already migrated to dag/test/claim/map_lookup_dual_dispatch_witness_test.dag (method get, index sugar, lookup builtin, std.graph adjacency; routing proven by chokepoint perturbation). The two remaining are NOT redundant-by-coverage, so this is low-value-at-v1-sunset rather than DeleteRedundant: (1) map_lookup_operations_do_not_probe_value_map_outside_chokepoint is a v1_interpreter.rs source-text bypass scan the module itself documents as a pinned-harness fact 'dissolving with the v1 interpreter' (a transient v1-Rust scaffold, no v2-relevant concept; the routing it statically complements is perturbation-proven for the live surfaces); (2) map_get_function_returns_optional_for_empty_list_hit is #[ignore]d on a pre-existing empty-list inference bug (never run in CI), inert." + } +} diff --git a/dag/test/retirement/model.dag b/dag/test/retirement/model.dag new file mode 100644 index 00000000000..ba1c7460edc --- /dev/null +++ b/dag/test/retirement/model.dag @@ -0,0 +1,10 @@ +module test.retirement.model + +type RetirementDisposition + = DeleteRedundant { covered_by: String } + | DeleteLowValue { reason: String } + +type TestModuleRetirement { + module: String + disposition: RetirementDisposition +} diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index fa2c14d6cc5..ae4c92916d4 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -81,8 +81,6 @@ mod list_free_monoid_chokepoint_test; #[cfg(test)] mod map_literal_string_key_test; #[cfg(test)] -mod map_lookup_dual_dispatch_test; -#[cfg(test)] mod measure_alias_ctor_test; #[cfg(test)] mod measure_field_access_test; diff --git a/src/v1/tests/src/map_lookup_dual_dispatch_test.rs b/src/v1/tests/src/map_lookup_dual_dispatch_test.rs deleted file mode 100644 index 16d174d8816..00000000000 --- a/src/v1/tests/src/map_lookup_dual_dispatch_test.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! RESIDUAL after 5-test-migration (2026-07-02): 4 of the original 6 tests are -//! migrated to marker-discovered floor witnesses in -//! dag/test/claim/map_lookup_dual_dispatch_witness_test.dag (method get, index -//! sugar, lookup builtin, std.graph adjacency smoke — a chokepoint perturbation -//! reds all four, proving the routing claim by execution). -//! The 2 tests below stay: -//! - map_lookup_operations_do_not_probe_value_map_outside_chokepoint: scans -//! v1_interpreter.rs source text for forbidden bypass patterns — a pinned-harness -//! fact, dissolving with the v1 interpreter. -//! - map_get_function_returns_optional_for_empty_list_hit: #[ignore]d on a -//! pre-existing empty-list-literal inference bug (bucket=inference); migrate when -//! the bug is fixed and the witness can be authored green. -use std::rc::Rc; - -use v1_compiler::v1_compiler_compile::{compile_to_resolved, ResolvedPipelineResult}; -use v1_compiler::v1_interpreter::{self, Value}; - -use crate::helpers::resolve_imports_transitively; - -fn assert_resolved_no_hard_errors(result: &ResolvedPipelineResult) { - let msgs: Vec = result - .diagnostics - .iter() - .map(|d| v1_compiler::v1_std_core::diagnostic_to_message(d.diagnostic.clone())) - .filter(|m| !m.starts_with("complexity: ")) - .collect(); - assert!( - msgs.is_empty() && result.graph.is_some(), - "expected resolved graph, got diagnostics {:?} (graph present: {})", - msgs, - result.graph.is_some() - ); -} - -#[test] -fn map_lookup_operations_do_not_probe_value_map_outside_chokepoint() { - let source = include_str!("../../stage0/src/v1_interpreter.rs"); - let forbidden = [ - "(Value::Map(m), Value::Str(k)) => Ok(m.get(k.as_str())", - "(Value::Map(m), [Value::Str(k)]) =>", - "Value::Map(m) => {\n let key = expect_str(args.first(), \"get\")?;\n Ok(m.get(&key)", - "[Value::Map(m), Value::Str(k)] => {\n Ok(Some(m.get(k.as_str())", - "Value::Map(m) => Ok(m.get(field).cloned().unwrap_or(Value::Null))", - ]; - for needle in forbidden { - assert!( - !source.contains(needle), - "Map lookup bypass: native Value::Map key-probe outside raw_map_lookup.\n\ - forbidden pattern:\n{needle}\n\ - Route map key probes through raw_map_lookup (ctrl#1476 B6 Option-C)." - ); - } -} - -#[test] -#[ignore = "failing: empty list literal inference error 'expected type is not a collection'. Pre-existing (never run in CI under the 3-test allowlist), surfaced by the run-all widening #5427; fix as follow-up. bucket=inference"] -fn map_get_function_returns_optional_for_empty_list_hit() { - let src = r#"module test.map_get_empty_list -fn hit() -> Bool { - let m = empty_map() |> map_insert("a", []) - match map_get(m, "a") { - Present { value: ns } => ns == [] - Absent => false - } -} - -fn miss() -> Bool { - let m = empty_map() |> map_insert("a", []) - match map_get(m, "b") { - Present { value: _ } => false - Absent => true - } -} -"#; - let sources = resolve_imports_transitively("test.dag", src); - let resolved = compile_to_resolved(Rc::new(sources)); - assert_resolved_no_hard_errors(&resolved); - let graph = resolved - .graph - .as_ref() - .expect("graph after successful resolve"); - let si = resolved.source_indices.clone(); - - match v1_interpreter::run(graph, si.clone(), "hit") { - Ok(Value::Bool(true)) => {} - other => panic!("expected empty-list map_get hit, got {other:?}"), - } - match v1_interpreter::run(graph, si, "miss") { - Ok(Value::Bool(true)) => {} - other => panic!("expected map_get miss -> Absent, got {other:?}"), - } -} diff --git a/src/v1/tests/src/measure_grounded_deref_test.rs b/src/v1/tests/src/measure_grounded_deref_test.rs index 70925dba46e..08a3c025d12 100644 --- a/src/v1/tests/src/measure_grounded_deref_test.rs +++ b/src/v1/tests/src/measure_grounded_deref_test.rs @@ -73,6 +73,7 @@ fn faithful_boxed_nat_field_access_still_dereferenced() { // boxed recursive coproduct, STILL derefs — proving the no-deref rule is grounded(host)-KEYED, // not a blanket removal that would also break legitimately-boxed fields. let body = fn_body(&emit_at("test.dag"), "get_nat"); + eprintln!("DEBUG BODY:\n{body}"); assert!( body.contains("(*"), "under FaithfulFreeMonoid a genuinely boxed Nat field must still deref, got:\n{body}" From a306d3571330e9a5b8cc7e4c0f6c9b770ed82b8a Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:07:49 +0000 Subject: [PATCH 23/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 946 ++++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 2 + .../stage0/src/v1_compiler_infer_emit_info.rs | 4 + src/v1/stage0/src/v1_compiler_ownership.rs | 364 ++++++- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 68 +- 6 files changed, 944 insertions(+), 442 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b45fa7ffa52..ce3e17515c4 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, - collect_callable_refs, + analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, + build_read_only_params, collect_callable_refs, move_site_key, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -163,7 +163,7 @@ pub fn render_rust_type( if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr.clone()) { return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => match find_property( n.properties.clone(), @@ -253,8 +253,8 @@ pub fn render_rust_type_without_applied_binding( match n.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -802,7 +802,7 @@ pub fn render_rust_applied_type_arg( ) { "()".to_string() } else { - match n.inferred.clone().as_deref().cloned() { + match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => render_rust_decl_type( n.clone(), @@ -1319,7 +1319,7 @@ pub fn alias_rhs_container_arg( arg: Rc, source_indices: Rc>>, ) -> Rc { - match arg.inferred.clone().as_deref().cloned() { + match (*arg.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if node_is_collection(rt.clone(), source_indices) { rt.clone() @@ -1401,11 +1401,6 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { - if let Some(host) = - rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) - { - return host; - } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -2105,7 +2100,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match wire_item.body.clone() { + match (*wire_item.body).clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2151,7 +2146,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } Some(wc) => { if is_data_def_item(wc.clone()) { - match wc.body.clone() { + match (*wc.body).clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2202,7 +2197,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( break rust_serde_error_policy(v1_rt::concat("wire_contract: ambiguous VariantEncoding data alias: ".to_string(), alias_name.clone())); } } - None => match init.inferred.clone() { + None => match (*init.inferred).clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2251,7 +2246,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } } } - _ => match init.inferred.clone() { + _ => match (*init.inferred).clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2298,7 +2293,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2316,7 +2311,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2375,7 +2370,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match item.type_annotation.clone() { + match (*item.type_annotation).clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2428,7 +2423,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match item.body.clone() { + match (*item.body).clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2453,7 +2448,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match contract_item.body.clone() { + match (*contract_item.body).clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -2608,8 +2603,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2625,8 +2620,10 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = - authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); + let item_name = authored_name_at( + (*tm.type_env).clone().source_indices.clone(), + item.clone(), + ); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2662,8 +2659,8 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), - typed_module.module.clone(), + (*typed_module.type_env).clone().source_indices.clone(), + (*typed_module.module).clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2682,21 +2679,21 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), item.clone(), ), item.clone(), ) }, ); - module_imports(typed_module.module.clone()) + module_imports((*typed_module.module).clone()) .iter() .cloned() .fold( local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2704,7 +2701,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - typed_module.type_env.clone().source_indices.clone(), + (*typed_module.type_env).clone().source_indices.clone(), ) .iter() .cloned() @@ -3251,12 +3248,14 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, + pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, + pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3267,7 +3266,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), + move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); @@ -3367,7 +3371,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: ownership.move_sites_index.clone(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3437,8 +3448,8 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3446,7 +3457,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3482,16 +3493,16 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )) { __result.push(p); @@ -3517,8 +3528,10 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3669,6 +3682,8 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: base_info.move_sites_index.clone(), + move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3697,12 +3712,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); let exported = get_exported_names( - tm.module.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.module).clone(), + (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3727,17 +3742,17 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = typed_module.module.clone(); + let m = (*typed_module.module).clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( authored_name(scope.type_env.clone(), m.clone()), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ @@ -3746,7 +3761,7 @@ pub fn emit_module_full( __result.extend( (*import_specific_names_at( imp.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) .iter() .cloned(), @@ -3763,11 +3778,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __result.push(item); @@ -3789,7 +3804,7 @@ pub fn emit_module_full( local_type_names, export_sets.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { @@ -3913,7 +3928,7 @@ pub fn emit_module_full( contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3922,7 +3937,7 @@ pub fn emit_module_full( contracts_imports_for_module( this_module_name.clone(), typed_modules.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), module_index.clone(), ), ); @@ -3930,7 +3945,7 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { @@ -3953,8 +3968,10 @@ pub fn emit_module_full( let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) - == "wire_contract".to_string())) + && (authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + i.clone(), + ) == "wire_contract".to_string())) { __result.push(i); } @@ -3986,7 +4003,7 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { @@ -4123,8 +4140,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4136,8 +4153,8 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4196,7 +4213,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports(tm.module.clone()), + Some(tm) => module_imports((*tm.module).clone()), None => Rc::new(vec![]), } } @@ -4211,7 +4228,10 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); + __result.push(authored_name_at( + source_indices.clone(), + (*tm.module).clone(), + )); } __result }) @@ -4384,7 +4404,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4476,7 +4496,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4586,7 +4606,8 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() + for imp in + module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4637,7 +4658,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) + for imp in module_imports((*tm.module).clone()) .iter() .cloned() { @@ -4905,7 +4926,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5162,7 +5183,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5198,7 +5219,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() { + for imp in module_imports((*tm.module).clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5658,7 +5679,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5687,7 +5708,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports(tm.module.clone()), + module_imports((*tm.module).clone()), module_emit_scope(tm.clone()), registry, export_sets.clone(), @@ -5815,8 +5836,8 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - if ((n.inferred.clone() != None) - && is_type_variable(n.inferred.clone().clone().unwrap())) + if (((*n.inferred).clone() != None) + && is_type_variable((*n.inferred).clone().clone().unwrap())) { true } else { @@ -5826,7 +5847,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - scope.type_env.clone(), + (*scope.type_env).clone(), name.clone(), ) { true @@ -5891,8 +5912,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) + && ((*item.transport).clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -5947,8 +5968,8 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs = resolved_type(item.clone()); - if ((rhs.inferred.clone() != None) - && is_compiler_error(rhs.inferred.clone().clone().unwrap())) + if (((*rhs.inferred).clone() != None) + && is_compiler_error((*rhs.inferred).clone().clone().unwrap())) { false } else { @@ -7208,7 +7229,7 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = scope.type_env.clone(); + let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), authored_name(env.clone(), item.clone()), @@ -7480,11 +7501,11 @@ pub fn emit_typed_item( }; let item_is_tco = is_tco_eligible( authored_name(env.clone(), item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco { + let fn_read_only = if item_is_tco.clone() { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7495,6 +7516,17 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; + let fn_move_sites = if item_is_tco.clone() { + v1_rt::rc_empty_map::() + } else { + match v1_rt::map_get( + &emit_info.move_sites_index.clone(), + qualified_name.clone(), + ) { + Some(m) => m.clone(), + None => v1_rt::rc_empty_map::(), + } + }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7507,6 +7539,8 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), @@ -7527,7 +7561,7 @@ pub fn emit_typed_item( item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7538,7 +7572,7 @@ pub fn emit_typed_item( item_text.clone(), item.params.clone(), resolved_type(item.clone()), - item.body.clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7550,8 +7584,8 @@ pub fn emit_typed_item( if is_data_def_item(item.clone()) { emit_data_def( item_text.clone(), - item.type_annotation.clone().clone().unwrap(), - item.body.clone().clone().unwrap(), + (*item.type_annotation).clone().clone().unwrap(), + (*item.body).clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7593,6 +7627,15 @@ pub fn emit_typed_item( } } +pub fn needs_box_wrapping_shared_dominates() -> String { + thread_local! { + static CACHED: String = { + "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7600,34 +7643,31 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { - // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box - // — shared_types dominates the recursive check. Replaced by regen's - // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } - if ((n.children.clone().len() as i64) == 0) { - { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } - } } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; } else { - break false; + if ((n.children.clone().len() as i64) == 0) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; + } else { + break v1_rt::set_contains(&recursive_types, name.clone()); + } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } + } } } } @@ -7694,7 +7734,7 @@ pub fn emit_type_params_with_clone_bound( pub fn is_function_type_param(param: Rc) -> bool { { let type_expr = param_node_type_expr(param.clone()); - let type_expr_is_var = match type_expr.inferred.clone() { + let type_expr_is_var = match (*type_expr.inferred).clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -9246,7 +9286,7 @@ pub fn enum_variant_field_type_node( Some(variant) => { match find_child_named(variant.clone(), field_name, source_indices.clone()) { Some(field) => { - if (field.inferred.clone() != None) { + if ((*field.inferred).clone() != None) { resolved_type(field.clone()) } else { fallback @@ -9561,7 +9601,7 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { @@ -9642,7 +9682,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9651,7 +9691,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9669,7 +9709,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let body_str = emit_typed_tco_body( body.clone(), @@ -9899,19 +9939,19 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), ); let ret_str = emit_func_inferred( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -9981,7 +10021,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -10354,7 +10394,7 @@ pub fn emit_rust_param_type( __result }); let param_str = param_types.join(&", ".to_string()); - let ret_str = match n.inferred.clone().as_deref().cloned() { + let ret_str = match (*n.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_rust_fn_sig_type( rt.clone(), generic_param_names.clone(), @@ -10841,14 +10881,14 @@ pub fn positional_payload_scrut_type( Some(summary) => match v1_rt::map_get(&summary.field_type_map.clone(), "0".to_string()) { Some(payload_type) => payload_type.clone(), - None => match field_binding.inferred.clone().as_deref().cloned() { + None => match (*field_binding.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } _ => "".to_string(), }, }, - None => match field_binding.inferred.clone().as_deref().cloned() { + None => match (*field_binding.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } @@ -11402,13 +11442,13 @@ pub fn analyze_rc_match( } __result }); - let scrutinee_is_optional = match scrutinee.inferred.clone().as_deref().cloned() { + let scrutinee_is_optional = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } _ => false, }; - let scrutinee_is_rc_wrapped = match scrutinee.inferred.clone().as_deref().cloned() { + let scrutinee_is_rc_wrapped = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if (((rt.children.clone().len() as i64) == 0) && (rt.ident_span.clone() != None)) { v1_rt::set_contains( @@ -12079,7 +12119,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { + let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -12089,8 +12129,8 @@ pub fn explicit_record_struct_name( }; let is_product = is_product_type(n.clone()); let is_coproduct = is_coproduct_type(n.clone()); - let n_is_error = if (n.inferred.clone() != None) { - is_compiler_error(n.inferred.clone().clone().unwrap()) + let n_is_error = if ((*n.inferred).clone() != None) { + is_compiler_error((*n.inferred).clone().clone().unwrap()) } else { false }; @@ -12222,10 +12262,28 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } +pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { + if (use_span.clone() == 0) { + false + } else { + match v1_rt::map_get( + &emit_info.move_sites.clone(), + move_site_key(name.clone(), use_span.clone()), + ) { + Some(v) => { + (v.clone() + && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) + } + None => false, + } + } +} + pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, + use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12238,7 +12296,16 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); + let site_move_kind_allowed = match binding_kind.clone().as_deref().cloned() { + Some(VarBindingKind::MatchBoundBinding) => false, + Some(VarBindingKind::FunctionValueBinding) => false, + Some(VarBindingKind::VariantValueBinding { parent_enum: _, .. }) => false, + _ => true, + }; + let moves_by_value = + (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) + || (site_move_kind_allowed + && move_licensed_at_site(emit_info.clone(), name.clone(), use_span))); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12347,7 +12414,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12364,7 +12431,7 @@ pub fn emit_typed_expr_base( let variant_parent = effective_variant_parent( n.clone(), binding_kind.clone(), - texpr.inferred.clone(), + (*texpr.inferred).clone(), emit_info.clone(), si.clone(), ); @@ -12448,18 +12515,18 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); match find_child_named( base_struct, field, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12469,18 +12536,23 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - let faithful_nat_field = - matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) - && (field_ty_name.clone() == "Nat".to_string() - || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); - faithful_nat_field - || needs_box_wrapping( - field_ty.clone(), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) + { + let faithful_nat_field = ((emit_info.corpus_repr.clone() + == RustCorpusRepr::FaithfulFreeMonoid) + && ((field_ty_name.clone() == "Nat".to_string()) + || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); + ((faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + (*scope.type_env).clone().source_indices.clone(), + )) + || is_recursive_type_by_name( + (*scope.type_env).clone(), + field_ty_name.clone(), + )) + } } } None => false, @@ -12507,7 +12579,7 @@ pub fn emit_typed_field_access( shared_types.clone(), emit_info.clone(), ); - let base_is_anon_record = match base.inferred.clone().as_deref().cloned() { + let base_is_anon_record = match (*base.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: bt, .. }) => { let is_product = is_product_type(bt.clone()); if (is_product && (bt.ident_span.clone() == None)) { @@ -12548,7 +12620,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12611,7 +12683,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -12706,7 +12778,7 @@ pub fn type_needs_rc_seen( }; } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if ((*normed.inferred).clone() != None) { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { @@ -12820,8 +12892,8 @@ pub fn rust_empty_map_kv_type_str( pub fn type_node_child_is_type_variable(c: Rc) -> bool { { let ch = child_type_node(c); - if (ch.inferred.clone() != None) { - is_type_variable(ch.inferred.clone().clone().unwrap()) + if ((*ch.inferred).clone() != None) { + is_type_variable((*ch.inferred).clone().clone().unwrap()) } else { false } @@ -12852,13 +12924,13 @@ pub fn rust_empty_set_element_type_str( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; - let elem_is_error = if (elem_node.inferred.clone() != None) { - is_compiler_error(elem_node.inferred.clone().clone().unwrap()) + let elem_is_error = if ((*elem_node.inferred).clone() != None) { + is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -12889,8 +12961,8 @@ pub fn emit_rust_empty_set_expr( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -12984,7 +13056,8 @@ pub fn emit_rust_expr_var( emit_var_ref( n, binding_kind.clone(), - expr.inferred.clone(), + (*expr.inferred).clone(), + expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -13007,7 +13080,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13016,11 +13089,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13065,11 +13138,14 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let f = expr_call_func_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_call_expr( f, expr.children.clone(), - expr.inferred.clone(), + (*expr.inferred).clone(), registry, scope.clone(), depth, @@ -13099,14 +13175,16 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = - expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let m = expr_method_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); emit_typed_method_call( expr.clone(), r, m, a, - expr.inferred.clone(), + (*expr.inferred).clone(), method_semantics.clone(), registry, scope.clone(), @@ -13175,8 +13253,10 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13212,14 +13292,14 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13379,7 +13459,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13398,8 +13478,10 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = - foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); + let v = foreach_variable_at( + expr.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13507,7 +13589,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13526,7 +13608,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }, |expr| { @@ -13732,7 +13814,7 @@ pub fn is_map_typed_expr( texpr: Rc, source_indices: Rc>>, ) -> bool { - match texpr.inferred.clone().as_deref().cloned() { + match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { node_is_keyed_collection(n.clone(), source_indices) } @@ -13759,9 +13841,11 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = - resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); - match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { + let ty_name = resolved_type_name( + arg.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); + match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13779,7 +13863,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13888,7 +13972,7 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -13913,7 +13997,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -14044,9 +14128,9 @@ pub fn emit_typed_call( emit_info.clone(), 1024, ); - let type_name = if (base_arg.inferred.clone() != None) { + let type_name = if ((*base_arg.inferred).clone() != None) { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(base_arg.clone()), ) } else { @@ -14061,7 +14145,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14190,7 +14274,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14337,7 +14421,7 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { @@ -14405,8 +14489,10 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) - { + match arg_name_at( + a.clone(), + (*scope.type_env).clone().source_indices.clone(), + ) { Some(n) => n.clone(), None => "".to_string(), }, @@ -14424,7 +14510,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) { __found = true; @@ -14450,7 +14536,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14475,7 +14561,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14593,7 +14679,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14650,11 +14736,11 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_rust_string_like( base_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { apply_type_template2( spec.indexing.clone().string_index.clone(), @@ -14715,7 +14801,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14748,13 +14834,13 @@ pub fn collection_element_type( match rt.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_error = if (elem_node.inferred.clone() != None) { - is_compiler_error(elem_node.inferred.clone().clone().unwrap()) + let elem_is_error = if ((*elem_node.inferred).clone() != None) { + is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) } else { false }; - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { + is_type_variable((*elem_node.inferred).clone().clone().unwrap()) } else { false }; @@ -14798,7 +14884,7 @@ pub fn lambda_scope_from_children( let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match pn.inferred.clone().as_deref().cloned() { + Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: resolved_type, .. @@ -14841,17 +14927,17 @@ pub fn lambda_param_type_strs( let idx = pair.0.clone(); let param_name = pair.1.clone(); let inferred_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match pn.inferred.clone().as_deref().cloned() { + Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: param_type, .. }) => { - let param_is_error = if (param_type.inferred.clone() != None) { - is_compiler_error(param_type.inferred.clone().clone().unwrap()) + let param_is_error = if ((*param_type.inferred).clone() != None) { + is_compiler_error((*param_type.inferred).clone().clone().unwrap()) } else { false }; - let param_is_type_var = if (param_type.inferred.clone() != None) { - is_type_variable(param_type.inferred.clone().clone().unwrap()) + let param_is_type_var = if ((*param_type.inferred).clone() != None) { + is_type_variable((*param_type.inferred).clone().clone().unwrap()) } else { false }; @@ -14908,7 +14994,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14926,7 +15012,7 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); @@ -14970,7 +15056,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -15017,7 +15103,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15039,6 +15125,19 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); + let site = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + lambda_expr.span.clone().file.clone(), + ":".to_string(), + ), + (lambda_expr.span.clone().start.clone()).to_string(), + ), + ":".to_string(), + ), + acc_name.clone(), + ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15046,16 +15145,22 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), + ), + acc_ident.clone(), + ), + " = v1_rt::take_owned_counted(".to_string(), ), acc_ident.clone(), ), - " = Rc::try_unwrap(".to_string(), + ", \"".to_string(), ), - acc_ident.clone(), + site, ), - ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), + "\"); ".to_string(), ), body_str, ), @@ -15104,10 +15209,10 @@ pub fn emit_rust_fold_method_call( 1024, ); let elem_type_str = collection_element_type( - receiver.inferred.clone(), + (*receiver.inferred).clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15148,33 +15253,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15191,7 +15296,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if (arg_value(init_arg.clone()).inferred.clone() != None) { + if ((*arg_value(init_arg.clone()).inferred).clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15202,7 +15307,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15212,7 +15317,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) .first() .cloned() @@ -15224,7 +15329,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15238,7 +15343,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15256,6 +15361,8 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15271,7 +15378,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprLambda => { let ps = lambda_param_names_at( fold_lambda_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15289,6 +15396,8 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), + move_sites_index: emit_info.move_sites_index.clone(), + move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15306,10 +15415,10 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { - is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) + let acc_type_is_type_var = if ((*acc_type_node.inferred).clone() != None) { + is_type_variable((*acc_type_node.inferred).clone().clone().unwrap()) } else { false }; @@ -15364,7 +15473,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15376,7 +15485,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( @@ -15402,7 +15511,7 @@ pub fn emit_rust_fold_method_call( emit_rust_empty_set_expr( acc_type_node.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { if (init_func.clone() == "empty_set".to_string()) { @@ -15451,7 +15560,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, }; @@ -15518,15 +15627,15 @@ pub fn emit_rust_sort_by_method_call( emit_info.clone(), 1024, ); - let elem_type_str = match receiver.inferred.clone().as_deref().cloned() { + let elem_type_str = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); - let elem_is_type_var = if (elem.inferred.clone() != None) { - is_type_variable(elem.inferred.clone().clone().unwrap()) + let elem_is_type_var = if ((*elem.inferred).clone() != None) { + is_type_variable((*elem.inferred).clone().clone().unwrap()) } else { false }; @@ -15535,7 +15644,7 @@ pub fn emit_rust_sort_by_method_call( elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) } else { "_".to_string() @@ -15594,7 +15703,7 @@ pub fn emit_rust_map_method_call( shared_types.clone(), emit_info.clone(), ); - let recv_is_optional = match receiver.inferred.clone().as_deref().cloned() { + let recv_is_optional = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -15610,7 +15719,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15675,7 +15784,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15773,7 +15882,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15891,13 +16000,13 @@ pub fn emit_rust_get_method_call( ), None => "compile_error!(\"get method missing index\")".to_string(), }; - let receiver_resolved = match receiver.inferred.clone().as_deref().cloned() { + let receiver_resolved = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }; if is_map_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -15944,17 +16053,17 @@ pub fn emit_rust_with_method_call( emit_info.clone(), 1024, ); - let type_name = match receiver.inferred.clone().as_deref().cloned() { + let type_name = match (*receiver.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let rt_is_error = if (rt.inferred.clone() != None) { - is_compiler_error(rt.inferred.clone().clone().unwrap()) + let rt_is_error = if ((*rt.inferred).clone() != None) { + is_compiler_error((*rt.inferred).clone().clone().unwrap()) } else { false }; if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15972,7 +16081,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -16045,7 +16154,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16249,7 +16358,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16378,13 +16487,13 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { "string_length".to_string() } else { @@ -16950,7 +17059,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -17015,16 +17124,16 @@ pub fn emit_typed_match( emit_info.clone(), 1024, ); - let scrut_type = match scrutinee.inferred.clone().as_deref().cloned() { + let scrut_type = match (*scrutinee.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) + authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17056,7 +17165,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17198,7 +17307,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17297,6 +17406,7 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), + arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17395,7 +17505,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17475,11 +17585,11 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name(scope.type_env.clone(), struct_name) { + match lookup_type_by_name((*scope.type_env).clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17506,8 +17616,10 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = - authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); + let receiver_type_name = authored_name_at( + (*scope.type_env).clone().source_indices.clone(), + receiver_type, + ); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17524,7 +17636,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => false, } @@ -17571,7 +17683,7 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); @@ -17593,13 +17705,13 @@ pub fn is_already_optional( if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { - match texpr.inferred.clone().as_deref().cloned() { + match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - (binding.resolved.clone().return_cardinality.clone() + ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17634,7 +17746,7 @@ pub fn is_already_optional( if summary_says_optional { true } else { - match b.inferred.clone().as_deref().cloned() { + match (*b.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. }) => { @@ -17642,14 +17754,14 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_base, ), f, ) { true } else { - match texpr.inferred.clone().as_deref().cloned() { + match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17657,7 +17769,7 @@ pub fn is_already_optional( } } } - _ => match texpr.inferred.clone().as_deref().cloned() { + _ => match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17666,7 +17778,7 @@ pub fn is_already_optional( } } } - _ => match texpr.inferred.clone().as_deref().cloned() { + _ => match (*texpr.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17689,11 +17801,11 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if (field_child.inferred.clone() != None) { + if ((*field_child.inferred).clone() != None) { { let field_type = resolved_type(field_child.clone()); - let ft_is_type_var = if (field_type.inferred.clone() != None) { - is_type_variable(field_type.inferred.clone().clone().unwrap()) + let ft_is_type_var = if ((*field_type.inferred).clone() != None) { + is_type_variable((*field_type.inferred).clone().clone().unwrap()) } else { false }; @@ -17721,13 +17833,13 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if (field_child.inferred.clone() != None) { + if ((*field_child.inferred).clone() != None) { { let field_type = resolved_type(field_child.clone()); let ft_is_type_var = - if (field_type.inferred.clone() != None) { + if ((*field_type.inferred).clone() != None) { is_type_variable( - field_type.inferred.clone().clone().unwrap(), + (*field_type.inferred).clone().clone().unwrap(), ) } else { false @@ -17776,7 +17888,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17784,7 +17896,7 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), @@ -17793,7 +17905,7 @@ pub fn emit_field_value_with_context( match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -18013,13 +18125,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18040,7 +18152,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18056,7 +18168,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18130,7 +18242,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18140,17 +18252,17 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); - match fval.inferred.clone().as_deref().cloned() { + match (*fval.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => v1_rt::rc_map_insert( acc.clone(), fname.clone(), authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ), @@ -18170,7 +18282,10 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18251,20 +18366,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = resolve_node( + let resolved_struct = (*resolve_node( resolved_type.clone(), - scope.type_env.clone(), + (*scope.type_env).clone(), scope.module_name.clone(), ) - .resolved - .clone(); + .resolved) + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18304,8 +18419,8 @@ pub fn emit_typed_record_lit( let effective_parent = match context_lookup { Some(context_parent) => Some(context_parent.clone()), None => { - let rt_is_type_var = if (resolved_type.inferred.clone() != None) { - is_type_variable(resolved_type.inferred.clone().clone().unwrap()) + let rt_is_type_var = if ((*resolved_type.inferred).clone() != None) { + is_type_variable((*resolved_type.inferred).clone().clone().unwrap()) } else { false }; @@ -18521,7 +18636,10 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env) + .clone() + .source_indices + .clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18588,7 +18706,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -18676,7 +18794,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18807,7 +18925,7 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); @@ -18891,10 +19009,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -18940,7 +19058,7 @@ pub fn emit_typed_bin_op( } pub fn is_optional_typed_expr(e: Rc) -> bool { - match e.inferred.clone().as_deref().cloned() { + match (*e.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -18971,7 +19089,7 @@ pub fn is_string_typed_expr( e: Rc, source_indices: Rc>>, ) -> bool { - match e.inferred.clone().as_deref().cloned() { + match (*e.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); let inner = if is_optional { @@ -19210,8 +19328,10 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = - let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); + let n = let_binding_name_at( + stmt.clone(), + (*scope.type_env).clone().source_indices.clone(), + ); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19227,7 +19347,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19297,15 +19417,18 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let call_str = emit_typed_call( f, - frame.expr.clone().children.clone(), + (*frame.expr).clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19332,11 +19455,11 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition(frame.expr.clone()); - let t = if_then_branch(frame.expr.clone()); - let e = if_else_branch(frame.expr.clone()); + let c = if_condition((*frame.expr).clone()); + let t = if_then_branch((*frame.expr).clone()); + let e = if_else_branch((*frame.expr).clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19553,7 +19676,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19611,10 +19734,10 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee(frame.expr.clone()); - let arm_list = match_arm_nodes(frame.expr.clone()); + let s = match_scrutinee((*frame.expr).clone()); + let arm_list = match_arm_nodes((*frame.expr).clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19624,17 +19747,23 @@ pub fn emit_rust_tco_match( emit_info.clone(), 1024, ); - let tco_scrut_type = match s.inferred.clone().as_deref().cloned() { + let tco_scrut_type = match (*s.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), rt.clone(), ) } @@ -19671,7 +19800,10 @@ pub fn emit_rust_tco_match( tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19775,14 +19907,17 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - frame.expr.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.expr).clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ); - let v = let_value(frame.expr.clone()); - let bd = let_body(frame.expr.clone()); + let v = let_value((*frame.expr).clone()); + let bd = let_body((*frame.expr).clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19797,7 +19932,10 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - frame.scope.clone().type_env.clone().source_indices.clone(), + (*frame.scope.clone().type_env) + .clone() + .source_indices + .clone(), ) == n.clone()) { __found = true; @@ -19867,9 +20005,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*frame.expr.clone().expr_data.clone()).clone() { + match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = frame.expr.clone().children.clone(); + let ss = (*frame.expr).clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -19926,7 +20064,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - frame.expr.clone(), + (*frame.expr).clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20043,7 +20181,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20194,7 +20332,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = scope.type_env.clone().source_indices.clone(); + let si = (*scope.type_env).clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -20876,7 +21014,7 @@ let prelude = match wire_opt.clone() { v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()) } else { { - let wire_ty = match tn.inferred.clone().as_deref().cloned() { + let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; @@ -20892,7 +21030,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -let raw = match ch.inferred.clone().as_deref().cloned() { +let raw = match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -21075,7 +21213,7 @@ pub fn emit_rest_http_method( source_indices: Rc>>, ) -> String { match transport_method(transport, source_indices.clone()) { - Some(m) => match m.inferred.clone().as_deref().cloned() { + Some(m) => match (*m.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { let method_name = expr_var_name_at(m.clone(), source_indices.clone()); Rc::new({ @@ -21489,7 +21627,7 @@ pub fn operation_response_200_resolved_type( { Some(p) => { let v = field_init_node_value(p.clone()); - match v.inferred.clone().as_deref().cloned() { + match (*v.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => Some(tn.clone()), _ => { let type_name = authored_name_at( @@ -21603,7 +21741,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match state.node.clone() { + let next_node = match (*state.node).clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21639,7 +21777,7 @@ pub fn advance_wire_path_projection( }) } } else { - match state.node.clone() { + match (*state.node).clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -21882,7 +22020,7 @@ pub fn emit_from_key_extraction( .to_string() } else { { - let wire_ty = match tn.inferred.clone().as_deref().cloned() { + let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; @@ -21915,7 +22053,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -match ch.inferred.clone().as_deref().cloned() { +match (*ch.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -22874,7 +23012,8 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) + && ((*annotation.type_annotation).clone() != None)) && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), @@ -22899,19 +23038,19 @@ pub fn emit_data_def( let render_type_node = if ((annotation_type_node.children.clone().len() as i64) > 0) { annotation_type_node.clone() } else { - match value.inferred.clone().as_deref().cloned() { + match (*value.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => annotation_type_node.clone(), } }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), annotation_type_node.clone(), ), ) @@ -22920,7 +23059,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -22929,11 +23068,11 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { @@ -22964,7 +23103,7 @@ pub fn emit_data_def( let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ), ); @@ -22975,16 +23114,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23088,10 +23227,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let type_name = authored_name_at( - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23100,19 +23239,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23120,14 +23259,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ), None => None, }, @@ -23159,7 +23298,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23175,7 +23314,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23191,7 +23330,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - scope.type_env.clone(), + (*scope.type_env).clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23200,7 +23339,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), )); } __result @@ -23208,7 +23347,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23228,13 +23367,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23251,14 +23390,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23281,8 +23420,7 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - scope - .type_env + (*scope.type_env) .clone() .source_indices .clone(), @@ -23346,14 +23484,14 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), - value.inferred.clone(), + (*value.inferred).clone(), emit_info.clone(), - scope.type_env.clone().source_indices.clone(), + (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( vname.clone(), @@ -23515,7 +23653,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - projection.inferred.clone(), + (*projection.inferred).clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23774,7 +23912,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match data_item.body.clone() { + Some(data_item) => match (*data_item.body).clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23847,7 +23985,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if (item.body.clone() == None) { + if ((*item.body).clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -23881,7 +24019,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), ) { __result.push(item); } @@ -23894,12 +24032,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), ), registry.clone(), tm.items.clone(), - tm.type_env.clone().source_indices.clone(), + (*tm.type_env).clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -23972,7 +24110,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), + (*tm.type_env).clone().source_indices.clone(), + (*tm.module).clone(), )), None => "".to_string(), }; @@ -24009,8 +24147,10 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - == "v1.compiler.compile".to_string()) + if (authored_name_at( + (*m.type_env).clone().source_indices.clone(), + (*m.module).clone(), + ) == "v1.compiler.compile".to_string()) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 0525069bf0f..988059445b2 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -14606,6 +14606,8 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 8dc46a13d29..b19d756df6d 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,6 +83,8 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, + pub move_sites_index: Rc>>>, + pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -104,6 +106,8 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), + move_sites_index: v1_rt::rc_empty_map::>>(), + move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 160e9fc850f..f4200b72527 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -690,14 +690,39 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn build_movable_set(proof: Rc) -> Rc> { +pub fn whole_value_borrow_count(usage: Rc) -> i64 { + (Rc::new({ + let mut __result = Vec::new(); + for c in usage.consumers.clone().iter().cloned() { + if match c.kind.clone() { + EdgeKind::Read => true, + EdgeKind::Threaded => true, + _ => false, + } { + __result.push(c); + } + } + __result + }) + .len() as i64) +} + +pub fn build_movable_set( + proof: Rc, + param_names: Rc>, +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) + if ((match (*make_decision(usage.clone())).clone() { + OwnershipDecision::SoleOwner { .. } => true, + _ => false, + } && (whole_value_borrow_count(usage.clone()) == 0)) + && (is_owned_local(usage.binding_kind.clone()) + || v1_rt::set_contains(¶m_names, usage.name.clone()))) { __result.push(usage); } @@ -1138,13 +1163,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { + let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { + let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1233,6 +1258,337 @@ pub fn analyze_ownership( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiveState { + pub name: String, + pub whole: bool, + pub any_field: bool, + pub fields: Rc>, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct MoveLicenseAccum { + pub live: Rc>>, + pub licensed: Rc>, +} + +pub fn move_site_key(name: String, span_start: i64) -> String { + v1_rt::concat( + v1_rt::concat(name, "@".to_string()), + (span_start).to_string(), + ) +} + +pub fn empty_live_state(name: String) -> Rc { + Rc::new(LiveState { + name: name, + whole: false, + any_field: false, + fields: v1_rt::rc_empty_set::(), + }) +} + +pub fn live_state_of(acc: Rc, name: String) -> Rc { + match v1_rt::map_get(&acc.live.clone(), name.clone()) { + Some(st) => st.clone(), + None => empty_live_state(name.clone()), + } +} + +pub fn record_whole_use_site( + acc: Rc, + name: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !st.any_field.clone()); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: true, + any_field: st.any_field.clone(), + fields: st.fields.clone(), + }), + ), + licensed: licensed, + }) + } +} + +pub fn record_field_use_site( + acc: Rc, + name: String, + field: String, + span_start: i64, + in_capture: bool, +) -> Rc { + { + let st = live_state_of(acc.clone(), name.clone()); + let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) + && !v1_rt::set_contains(&st.fields.clone(), field.clone())); + let licensed = if movable_here { + v1_rt::rc_map_insert( + acc.licensed.clone(), + move_site_key(name.clone(), span_start.clone()), + true, + ) + } else { + acc.licensed.clone() + }; + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_map_insert( + acc.live.clone(), + name.clone(), + Rc::new(LiveState { + name: name.clone(), + whole: st.whole.clone(), + any_field: true, + fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), + }), + ), + licensed: licensed, + }) + } +} + +pub fn merge_live_states(a: Rc, b: Rc) -> Rc { + Rc::new(LiveState { + name: a.name.clone(), + whole: (a.whole.clone() || b.whole.clone()), + any_field: (a.any_field.clone() || b.any_field.clone()), + fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), + }) +} + +pub fn merge_branch_licenses(branches: Rc>>) -> Rc { + branches.iter().cloned().fold( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + |acc: Rc, br: Rc| { + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + { + let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) + .iter() + .cloned() + .fold( + acc.live, + |lm: Rc>>, k: String| { + let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { + Some(s) => s.clone(), + None => empty_live_state(k.clone()), + }; + match v1_rt::map_get(&lm, k.clone()) { + Some(a_st) => v1_rt::rc_map_insert( + lm.clone(), + k.clone(), + merge_live_states(a_st.clone(), b_st.clone()), + ), + None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), + } + }, + ); + let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) + .iter() + .cloned() + .fold(acc.licensed, |l: Rc>, k: String| { + v1_rt::rc_map_insert(l, k.clone(), true) + }); + Rc::new(MoveLicenseAccum { + live: live_merged.clone(), + licensed: lic_merged.clone(), + }) + } + }, + ) +} + +pub fn license_walk( + acc: Rc, + texpr: Rc, + in_capture: bool, + si: Rc>>, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + match (*texpr.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_whole_use_site( + acc.clone(), + expr_var_name_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + ExprData::ExprLiteral { value: _, .. } => acc.clone(), + ExprData::ExprFieldAccess { .. } => { + let base_node = field_access_base(texpr.clone()); + match (*base_node.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => record_field_use_site( + acc.clone(), + expr_var_name_at(base_node.clone(), si.clone()), + field_access_field_at(texpr.clone(), si.clone()), + texpr.span.clone().start.clone(), + in_capture.clone(), + ), + _ => license_walk( + acc.clone(), + base_node.clone(), + in_capture.clone(), + si.clone(), + ), + } + } + ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }), + ExprData::ExprMethodCall { .. } => { + let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, arg: Rc| { + license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) + }); + license_walk( + args_acc, + method_receiver(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprIf => { + let t_acc = license_walk( + acc.clone(), + if_then_branch(texpr.clone()), + in_capture.clone(), + si.clone(), + ); + let e_acc = match if_else_branch(texpr.clone()) { + Some(eb) => { + license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) + } + None => acc.clone(), + }; + let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); + license_walk( + merged, + if_condition(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprMatch => { + let branch_accs = Rc::new({ + let mut __result = Vec::new(); + for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { + __result.push(license_walk( + acc.clone(), + arm_body(arm_node.clone()), + in_capture.clone(), + si.clone(), + )); + } + __result + }); + let merged = merge_branch_licenses(branch_accs); + license_walk( + merged, + match_scrutinee(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprLet => { + let body_acc = match let_body(texpr.clone()) { + Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), + None => acc.clone(), + }; + license_walk( + body_acc, + let_value(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + ExprData::ExprLambda => { + license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) + } + ExprData::ExprForEach => { + let body_acc = + license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); + license_walk( + body_acc, + foreach_collection(texpr.clone()), + in_capture.clone(), + si.clone(), + ) + } + ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) + .iter() + .cloned() + .fold(acc.clone(), |a: Rc, field: Rc| { + license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) + }), + _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( + acc.clone(), + |a: Rc, child: Rc| { + license_walk(a, child.clone(), in_capture.clone(), si.clone()) + }, + ), + } + }) +} + +pub fn build_move_site_licenses( + body: Rc, + si: Rc>>, +) -> Rc> { + { + let walked = license_walk( + Rc::new(MoveLicenseAccum { + live: v1_rt::rc_empty_map::>(), + licensed: v1_rt::rc_empty_map::(), + }), + body, + false, + si, + ); + walked.licensed.clone() + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index f073e49662d..5e92b0e22a9 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -54,7 +54,7 @@ pub fn rt_unicode_ops() -> String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index a0826e3e1bf..461ae3a8ccb 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -335,40 +335,6 @@ pub fn replace(s: String, from: String, to: String) -> String { // will call these. Read-only functions (map_get, map_keys, map_values, lookup, // map_contains_key, map_has) work with Rc via auto-deref. -// take_owned_counted: the fail-closed replacement for the silent -// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: -// a failure arm must refuse or be counted, never silently widen). The ownership -// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose -// per-site frequency must stay observable, so the clone arm counts per emitted -// site (site = ":" of the use-site the emitter rewrote). -thread_local! { - static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = - std::cell::RefCell::new(HashMap::new()); -} - -pub fn take_owned_counted(x: Rc, site: &'static str) -> T { - Rc::try_unwrap(x).unwrap_or_else(|rc| { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); - (*rc).clone() - }) -} - -pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| { - let mut v: Vec<(String, u64)> = m - .borrow() - .iter() - .map(|(site, n)| (site.to_string(), *n)) - .collect(); - v.sort(); - v - }) -} - -pub fn reset_take_owned_clone_fallbacks() { - TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); -} - pub fn rc_list_push(list: Rc>, item: T) -> Rc> { let mut v = list; Rc::make_mut(&mut v).push(item); @@ -685,3 +651,37 @@ pub fn contiguous_loop_elementwise_kernel( } out } + +// take_owned_counted: the fail-closed replacement for the silent +// `Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone())` fallback (DESIGN.md §5: +// a failure arm must refuse or be counted, never silently widen). The ownership +// proof licenses the take-owned; a shared Rc at runtime is a proof deficit whose +// per-site frequency must stay observable, so the clone arm counts per emitted +// site (site = ":" of the use-site the emitter rewrote). +thread_local! { + static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> = + std::cell::RefCell::new(HashMap::new()); +} + +pub fn take_owned_counted(x: Rc, site: &'static str) -> T { + Rc::try_unwrap(x).unwrap_or_else(|rc| { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); + (*rc).clone() + }) +} + +pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| { + let mut v: Vec<(String, u64)> = m + .borrow() + .iter() + .map(|(site, n)| (site.to_string(), *n)) + .collect(); + v.sort(); + v + }) +} + +pub fn reset_take_owned_clone_fallbacks() { + TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear()); +} From e63391b0e71c4792de8f539c7edb57d4d97fb3b4 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:18:12 +0000 Subject: [PATCH 24/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- src/v1/stage0/src/v1_compiler_complexity.rs | 573 ++++--- src/v1/stage0/src/v1_compiler_emit_rust.rs | 1582 +++++++++---------- src/v1/stage0/src/v1_compiler_ownership.rs | 95 +- 3 files changed, 1045 insertions(+), 1205 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 368276eb3bc..6d2d00322da 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -535,7 +535,7 @@ pub fn parser_state_expr_progress( if (name.clone() == state_param.name.clone()) { DescentEvidence::NonIncreasing } else { - match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { + match v1_rt::map_get(&env.state_aliases.clone(), name) { Some(progress) => progress.clone(), None => DescentEvidence::DescentUnknown, } @@ -641,7 +641,7 @@ pub fn parser_state_expr_progress( __result }); match arm_progresses.clone().first().cloned() { - Some(initial) => arm_progresses.clone().iter().cloned().fold( + Some(initial) => arm_progresses.iter().cloned().fold( initial.clone(), |acc: DescentEvidence, p: DescentEvidence| { descent_evidence_lattice_meet(acc, p.clone()) @@ -683,7 +683,7 @@ pub fn parser_block_state_progress( .collect::>(), ); let final_env = leading.iter().cloned().fold( - env.clone(), + env, |acc_env: Rc, stmt: Rc| match (*stmt.expr_data.clone()) .clone() { @@ -739,17 +739,17 @@ pub fn parser_result_source_for_expr( match (*parser_result_witness(expr.clone(), si.clone())).clone() { ParserResultWitness::ParserWitnessAdvance => { Rc::new(ParserResultSource::ParserResultAdvance { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessExpect => { Rc::new(ParserResultSource::ParserResultExpect { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessEat => { Rc::new(ParserResultSource::ParserResultEat { - input: input_progress.clone(), + input: input_progress, }) } ParserResultWitness::ParserWitnessCall { callee: callee, .. } => { @@ -763,7 +763,7 @@ pub fn parser_result_source_for_expr( Rc::new(ParserResultSource::ParserResultOpaque) } _ => Rc::new(ParserResultSource::ParserResultCall { - input: input_progress.clone(), + input: input_progress, callee: name.clone(), }), } @@ -786,9 +786,7 @@ pub fn parser_result_source_for_expr( ); match progress.clone() { DescentEvidence::DescentUnknown => Rc::new(ParserResultSource::ParserResultOpaque), - _ => Rc::new(ParserResultSource::ParserResultDirectState { - input: progress.clone(), - }), + _ => Rc::new(ParserResultSource::ParserResultDirectState { input: progress }), } } } @@ -1015,7 +1013,7 @@ pub fn collect_parser_progress_edges( consumed_true_set.clone(), si.clone(), ); - let then_consumed = match parser_progress_flag_var(cond.clone(), si.clone()) { + let then_consumed = match parser_progress_flag_var(cond, si.clone()) { Some(name) => { v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) } @@ -1060,7 +1058,7 @@ pub fn collect_parser_progress_edges( ); let next_env = parser_env_with_binding( let_binding_name_at(body.clone(), si.clone()), - value_expr.clone(), + value_expr, env.clone(), state_param.clone(), parser_always_advancing.clone(), @@ -1300,7 +1298,7 @@ pub fn parser_success_progress( Some(body) => parser_success_progress( body.clone(), state_param.clone(), - next_env.clone(), + next_env, parser_always_advancing.clone(), consumed_true_set.clone(), si.clone(), @@ -1426,7 +1424,7 @@ pub fn infer_parser_always_advancing_members_worklist( ); if set_has(proven.clone(), name.clone()) { { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } @@ -1444,7 +1442,8 @@ pub fn infer_parser_always_advancing_members_worklist( None => Rc::new(vec![]), }; { - let __tco_0 = deduplicate(v1_rt::concat(rest, callers)); + let __tco_0 = + deduplicate(v1_rt::concat(rest.clone(), callers.clone())); let __tco_1 = v1_rt::rc_map_insert(proven, name.clone(), true); queue = __tco_0; proven = __tco_1; @@ -1452,14 +1451,14 @@ pub fn infer_parser_always_advancing_members_worklist( } } else { { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } } } None => { - let __tco_0 = rest; + let __tco_0 = rest.clone(); queue = __tco_0; continue; } @@ -1618,7 +1617,7 @@ pub fn same_progress_subgraph_has_cycle( { let same_cross_edges = Rc::new({ let mut __result = Vec::new(); - for edge in same_edges.clone().iter().cloned() { + for edge in same_edges.iter().cloned() { if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } @@ -1723,7 +1722,7 @@ pub fn classify_parser_scc_recursion_pattern( __all }; if (all_known - && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) { Some(lower_call_pattern(Rc::new( CallPattern::ParserAdvanceCall { @@ -1864,9 +1863,9 @@ pub fn max_path_self_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls.clone() + then_calls } else { - else_calls.clone() + else_calls }; (cond_calls + branch_max) } @@ -1972,12 +1971,12 @@ pub fn max_path_self_calls_block( continue_calls: i64, si: Rc>>, ) -> i64 { - v1_rt::reverse(stmts).iter().cloned().fold( - continue_calls.clone(), - |acc: i64, stmt: Rc| { + v1_rt::reverse(stmts) + .iter() + .cloned() + .fold(continue_calls, |acc: i64, stmt: Rc| { max_path_self_calls_with_cont(stmt.clone(), func_name.clone(), acc, si.clone()) - }, - ) + }) } pub fn count_target_calls( @@ -2091,9 +2090,9 @@ pub fn max_path_target_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls.clone() + then_calls } else { - else_calls.clone() + else_calls }; (cond_calls + branch_max) } @@ -2207,7 +2206,11 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), + recursive_measure_param_names( + entry.body.clone(), + entry.params.clone(), + si.clone(), + ), ), None => acc.clone(), }, @@ -2228,11 +2231,10 @@ pub fn target_call_has_arithmetic_descent( } else { match v1_rt::map_get(&func_index, callee.clone()) { Some(callee_entry) => { - let callee_measure_params = - match v1_rt::map_get(&scc_measure_params, callee.clone()) { - Some(params) => params.clone(), - None => v1_rt::rc_empty_map::(), - }; + let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee) { + Some(params) => params.clone(), + None => v1_rt::rc_empty_map::(), + }; { let mut __found = false; for pair in Rc::new( @@ -2368,7 +2370,7 @@ pub fn expr_descending_witness_source( } => { break v1_rt::map_get( &descending_witness_names, - expr_var_name_at(expr.clone(), si), + expr_var_name_at(expr.clone(), si.clone()), ); } ExprData::ExprBinOp { op, .. } => match op.clone() { @@ -2403,9 +2405,9 @@ pub fn condition_param_names( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(expr.clone(), si.clone()); + let name = expr_var_name_at(expr.clone(), si); match v1_rt::map_get(¶m_set, name.clone()) { - Some(_) => seed_string_map(name.clone(), name.clone()), + Some(_) => seed_string_map(name.clone(), name), None => v1_rt::rc_empty_map::(), } } @@ -2660,18 +2662,18 @@ pub fn is_children_of_param( ExprData::ExprFieldAccess { .. } => { let base = field_access_base(expr.clone()); let field = field_access_field_at(expr.clone(), si.clone()); - break (is_children_list_field(field) + break (is_children_list_field(field.clone()) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name.clone()), _ => false, }); } ExprData::ExprVar { binding_kind: _, .. } => { - break set_has(vars, expr_var_name_at(expr.clone(), si.clone())); + break set_has(vars.clone(), expr_var_name_at(expr.clone(), si.clone())); } ExprData::ExprMethodCall { method_semantics: ms, @@ -2709,7 +2711,7 @@ pub fn is_structural_children( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(base.clone(), si.clone())), + } => set_has(vars.clone(), expr_var_name_at(base, si.clone())), _ => false, }) } @@ -2779,7 +2781,7 @@ pub fn is_tree_size_preserving_wrapper( pub fn wrapper_inner_arg(expr: Rc) -> Rc { match expr.children.clone().first().cloned() { Some(arg_node) => arg_value(arg_node.clone()), - None => expr.clone(), + None => expr, } } @@ -2796,7 +2798,7 @@ pub fn is_sub_value_extractor(expr: Rc, si: Rc) -> Rc { match expr.children.clone().first().cloned() { Some(arg_node) => arg_value(arg_node.clone()), - None => expr.clone(), + None => expr, } } @@ -2940,11 +2942,12 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); + break ((vname.clone() == param_name.clone()) + || set_has(vars.clone(), vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field == param_name.clone()) { + if (field.clone() == param_name.clone()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2954,7 +2957,7 @@ pub fn is_tokens_input_expr( } => { let bname = expr_var_name_at(base.clone(), si.clone()); break ((bname.clone() == param_name.clone()) - || set_has(vars, bname.clone())); + || set_has(vars.clone(), bname.clone())); } _ => { break false; @@ -3095,9 +3098,9 @@ pub fn expr_contains_descent( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3390,7 +3393,7 @@ pub fn collect_descent_vars( } _ => false, }; - ((inner_is_descent.clone() || inner_is_var.clone()) || inner_is_param) + ((inner_is_descent || inner_is_var) || inner_is_param) } } else { false @@ -3404,9 +3407,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3445,12 +3448,7 @@ pub fn collect_descent_vars( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call( - val.clone(), - param_name.clone(), - vars.clone(), - si.clone(), - )); + && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); let val_is_descent = ((((((((is_direct_descent || is_descent_var) || is_option_descent) || is_match_descent) @@ -3494,9 +3492,8 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -3666,15 +3663,15 @@ pub fn all_self_calls_descend_inc( let is_children_list = match (*val.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(val.clone()); - let field = field_access_field_at(val.clone(), si.clone()); + let field = field_access_field_at(val, si.clone()); (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -3695,7 +3692,7 @@ pub fn all_self_calls_descend_inc( b.clone(), func_name.clone(), param_name.clone(), - next_vars.clone(), + next_vars, check_child.clone(), check_list.clone(), si.clone(), @@ -3727,9 +3724,8 @@ pub fn all_self_calls_descend_inc( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -3921,7 +3917,7 @@ pub fn all_self_calls_descend_inc( if (is_iter && is_struct) { { let recv_ok = all_self_calls_descend_inc( - receiver.clone(), + receiver, func_name.clone(), param_name.clone(), vars.clone(), @@ -4064,12 +4060,12 @@ pub fn matches_on_sub_value_field( match (*scrut.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(scrut.clone()); - let field = field_access_field_at(scrut.clone(), si.clone()); + let field = field_access_field_at(scrut, si.clone()); (is_sub_value_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => (expr_var_name_at(base, si.clone()) == param_name), _ => false, }) } @@ -4150,7 +4146,7 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left.clone(), si) == param_name) + ((expr_var_name_at(left, si) == param_name) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4205,7 +4201,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4237,7 +4233,7 @@ pub fn classify_self_call_evidence( DescentEvidence::NonIncreasing => { DescentEvidence::Strict } - _ => inner_ev.clone(), + _ => inner_ev, } } } else { @@ -4268,9 +4264,9 @@ pub fn classify_self_call_evidence( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname == param_name.clone())) { DescentEvidence::Strict } else { @@ -4483,7 +4479,7 @@ pub fn collect_evidence_incremental( } _ => false, }; - ((inner_d.clone() || inner_v.clone()) || inner_p) + ((inner_d || inner_v) || inner_p) } } else { false @@ -4497,9 +4493,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())) + || set_has(vars.clone(), bname)) } _ => false, }) @@ -4538,12 +4534,7 @@ pub fn collect_evidence_incremental( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call( - val.clone(), - param_name.clone(), - vars.clone(), - si.clone(), - )); + && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); let next_vars = if ((((((((is_direct || is_var) || is_option) || is_match_descent) || is_wrapped) @@ -4565,7 +4556,7 @@ pub fn collect_evidence_incremental( b.clone(), func_name.clone(), param_name.clone(), - next_vars.clone(), + next_vars, check_child.clone(), check_list.clone(), branching_only.clone(), @@ -4599,9 +4590,8 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) - || set_has(vars.clone(), sname.clone())) + let sname = expr_var_name_at(scrut, si.clone()); + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) } _ => false, }; @@ -4698,7 +4688,7 @@ pub fn collect_evidence_incremental( None } else { collect_evidence_incremental( - then_branch.clone(), + then_branch, func_name.clone(), param_name.clone(), vars.clone(), @@ -4711,7 +4701,7 @@ pub fn collect_evidence_incremental( let else_ev = if (branching_only.clone() && (else_path == 0)) { None } else { - match else_opt.clone() { + match else_opt { Some(eb) => collect_evidence_incremental( eb.clone(), func_name.clone(), @@ -4826,7 +4816,7 @@ pub fn collect_evidence_incremental( if (is_iter && is_struct) { { let recv_ev = collect_evidence_incremental( - receiver.clone(), + receiver, func_name.clone(), param_name.clone(), vars.clone(), @@ -5054,7 +5044,7 @@ pub fn construct_termination_proof( } }); let single_dim_proof = match structural_proof.clone() { - Some(_) => structural_proof.clone(), + Some(_) => structural_proof, None => match parser_state_param(params.clone(), si.clone()) { Some(state_param) => { let self_set = seed_bool_map(func_name.clone()); @@ -5070,7 +5060,7 @@ pub fn construct_termination_proof( ); if (((edges.clone().len() as i64) > 0) && { let mut __all = true; - for edge in edges.clone().iter().cloned() { + for edge in edges.iter().cloned() { if !(edge.progress.clone() == DescentEvidence::Strict) { __all = false; break; @@ -5091,7 +5081,7 @@ pub fn construct_termination_proof( }, }; match single_dim_proof.clone() { - Some(_) => single_dim_proof.clone(), + Some(_) => single_dim_proof, None => { let self_set = seed_bool_map(func_name.clone()); let func_entry = Rc::new(FuncEntry { @@ -5105,7 +5095,7 @@ pub fn construct_termination_proof( construct_scc_termination_proof( Rc::new(vec![func_name.clone()]), func_index, - self_set.clone(), + self_set, si.clone(), ) } @@ -5333,7 +5323,7 @@ pub fn classify_recursion_pattern( let first_call = if all_calls_arithmetic_only { Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.clone().iter().cloned() { + for call_ev in all_evidence.iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5382,10 +5372,10 @@ pub fn classify_recursion_pattern( __result }); match tree_rels.clone().first().cloned() { - Some(_) => tree_rels.clone().first().cloned(), + Some(_) => tree_rels.first().cloned(), None => Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.clone().iter().cloned() { + for call_ev in all_evidence.iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5410,9 +5400,7 @@ pub fn classify_recursion_pattern( }; let is_arithmetic_branching = match first_call.clone() { Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::ArithmeticDescent { .. } => { - (path_calls.clone() > 1) - } + SubValueRelation::ArithmeticDescent { .. } => (path_calls > 1), _ => false, }, None => false, @@ -5420,7 +5408,7 @@ pub fn classify_recursion_pattern( if is_arithmetic_branching { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } else { - match first_call.clone() { + match first_call { Some(rel) => match sub_value_to_lowering_target(rel.clone()) { Some(target) => target.clone(), None => { @@ -5501,13 +5489,13 @@ pub fn classify_recursion_pattern( } None => false, }; - match proof.clone() { + match proof { Some(p) => { - if ((path_calls.clone() == 1) || proof_safe_for_branching.clone()) { + if ((path_calls == 1) || proof_safe_for_branching) { lower_call_pattern(proof_to_call_pattern(p.clone())) } else { if branching_proof_safe { - match branching_proof.clone() { + match branching_proof { Some(bp) => lower_call_pattern(proof_to_call_pattern( bp.clone(), )), @@ -5521,8 +5509,8 @@ pub fn classify_recursion_pattern( } } None => { - if (path_calls.clone() > 1) { - match branching_proof.clone() { + if (path_calls > 1) { + match branching_proof { Some(bp) => { if branching_proof_safe { lower_call_pattern(proof_to_call_pattern( @@ -5562,7 +5550,7 @@ pub fn bounded_recursive_cost( let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), + upper: Rc::new(SizeExpr::SizeVar { name: var }), body: simplify_cost(per_iter), }) } @@ -5585,7 +5573,7 @@ pub fn bounded_scc_cost( let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), + upper: Rc::new(SizeExpr::SizeVar { name: var }), body: simplify_cost(per_iter), }) } @@ -5621,7 +5609,7 @@ pub fn is_unknown_cost(expr: Rc) -> bool { pub fn extract_unknown_reason(mut expr: Rc) -> String { loop { - match (*expr).clone() { + match (*expr.clone()).clone() { CostExpr::CostUnknown { reason: r, .. } => { break r.clone(); } @@ -5701,7 +5689,7 @@ pub fn collect_local_call_edges_in_expr( if set_has(local_func_set.clone(), callee.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: callee.clone(), + callee: callee, })]) } else { Rc::new(vec![]) @@ -5822,7 +5810,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5848,7 +5836,7 @@ pub fn classify_scc_call_progress( ); match inner_progress.clone() { DescentEvidence::NonIncreasing => DescentEvidence::Strict, - _ => inner_progress.clone(), + _ => inner_progress, } } } else { @@ -5874,9 +5862,9 @@ pub fn classify_scc_call_progress( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname == param_name.clone())) { DescentEvidence::Strict } else { @@ -5983,7 +5971,7 @@ pub fn collect_scc_child_edges( ); Rc::new(vec![Rc::new(ParserProgressEdge { caller: caller.clone(), - callee: callee.clone(), + callee: callee, progress: progress, })]) } @@ -6028,7 +6016,7 @@ pub fn collect_scc_child_edges( if (is_iter && is_struct) { { let recv_edges = collect_scc_child_edges( - receiver.clone(), + receiver, caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6225,7 +6213,7 @@ pub fn collect_scc_child_edges( } _ => false, }; - ((inner_d.clone() || inner_v.clone()) || inner_p) + ((inner_d || inner_v) || inner_p) } } else { false @@ -6239,9 +6227,9 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base.clone(), si.clone()); + let bname = expr_var_name_at(base, si.clone()); ((bname.clone() == param_name.clone()) - || set_has(descent_vars.clone(), bname.clone())) + || set_has(descent_vars.clone(), bname)) } _ => false, }) @@ -6281,7 +6269,7 @@ pub fn collect_scc_child_edges( }; let is_consuming_helper = (check_list.clone() && is_tokens_consuming_call( - val.clone(), + val, param_name.clone(), descent_vars.clone(), si.clone(), @@ -6307,7 +6295,7 @@ pub fn collect_scc_child_edges( b.clone(), caller.clone(), param_name.clone(), - next_vars.clone(), + next_vars, target_set.clone(), check_child.clone(), check_list.clone(), @@ -6516,7 +6504,7 @@ pub fn is_scc_container_child_descent( }); let unknown_edge_count = count_unknown_progress_edges(edges.clone()); (((unknown_edge_count == 0) && ((edges.clone().len() as i64) > 0)) - && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) } } @@ -6628,9 +6616,9 @@ pub fn pick_best_param_edges( candidate: Rc>, ) -> Rc> { if (count_known_in_edge_map(candidate.clone()) > count_known_in_edge_map(current.clone())) { - candidate.clone() + candidate } else { - current.clone() + current } } @@ -6941,20 +6929,17 @@ pub fn construct_scc_termination_proof( let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { param: if (cx_l2_param.clone() != "".to_string()) { - cx_l2_param.clone() + cx_l2_param } else { "scc".to_string() }, })]), }); if ((cx_l2_all_known && ((cx_l2_edges.clone().len() as i64) > 0)) - && (proof_has_non_descending_cycle( - cx_l2_proof.clone(), - members.clone(), - cx_l2_edges.clone(), - ) == false)) + && (proof_has_non_descending_cycle(cx_l2_proof.clone(), members.clone(), cx_l2_edges) + == false)) { - Some(cx_l2_proof.clone()) + Some(cx_l2_proof) } else { { let tree_edges = collect_scc_proof_edges_for_dim( @@ -6987,10 +6972,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tree_proof.clone(), members.clone(), - tree_edges.clone(), + tree_edges, ) == false)) { - Some(tree_proof.clone()) + Some(tree_proof) } else { { let list_edges = collect_scc_proof_edges_for_dim( @@ -7023,10 +7008,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( list_proof.clone(), members.clone(), - list_edges.clone(), + list_edges, ) == false)) { - Some(list_proof.clone()) + Some(list_proof) } else { { let parser_edges = collect_scc_parser_proof_edges( @@ -7059,10 +7044,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( parser_proof.clone(), members.clone(), - parser_edges.clone(), + parser_edges, ) == false)) { - Some(parser_proof.clone()) + Some(parser_proof) } else { { let lex_edges = collect_scc_independent_dim_edges( @@ -7102,10 +7087,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( lex_proof.clone(), members.clone(), - lex_edges.clone(), + lex_edges, ) == false)) { - Some(lex_proof.clone()) + Some(lex_proof) } else { { let tree_parser_edges = @@ -7156,10 +7141,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tp_proof.clone(), members.clone(), - tree_parser_edges.clone(), + tree_parser_edges, ) == false)) { - Some(tp_proof.clone()) + Some(tp_proof) } else { None } @@ -7359,9 +7344,9 @@ pub fn build_scc_index( ); Rc::new(SccResult { index: result.index.clone(), - topo_order: topo_order.clone(), + topo_order: topo_order, processing_order: finish.order.clone(), - call_graph: graph.clone(), + call_graph: graph, }) } } @@ -7370,9 +7355,9 @@ pub fn cost_seq(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a.clone(), + CostExpr::CostConst { value: 0, .. } => a, _ => Rc::new(CostExpr::CostAdd { - left: a.clone(), + left: a, right: b.clone(), }), }, @@ -7383,9 +7368,9 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a.clone(), + CostExpr::CostConst { value: 0, .. } => a, _ => Rc::new(CostExpr::CostMax { - left: a.clone(), + left: a, right: b.clone(), }), }, @@ -7452,12 +7437,12 @@ pub fn receiver_size_var( match (*recv.expr_data.clone()).clone() { ExprData::ExprVar { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: expr_var_name_at(recv.clone(), si), + collection: expr_var_name_at(recv.clone(), si.clone()), }); } ExprData::ExprFieldAccess { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: field_access_field_at(recv.clone(), si), + collection: field_access_field_at(recv.clone(), si.clone()), }); } ExprData::ExprMethodCall { @@ -7470,7 +7455,7 @@ pub fn receiver_size_var( }; if method_preserves_collection_size(method_semantics.clone()) { { - let __tco_0 = inner_recv; + let __tco_0 = inner_recv.clone(); recv = __tco_0; continue; } @@ -7543,7 +7528,7 @@ pub fn resolve_callback_cost( let fn_ref = expr_var_name_at(la.clone(), si.clone()); match v1_rt::map_get(&func_index, fn_ref.clone()) { Some(_) => get_or_compute_summary( - fn_ref.clone(), + fn_ref, func_index.clone(), scc_index, recv_r.table.clone(), @@ -7632,7 +7617,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), @@ -7665,9 +7650,9 @@ pub fn cost_of_method_by_shape( base: 2, argument: size.clone(), }); - let per_comparison = key_result.summary.clone().work.clone(); + let per_comparison = (*key_result.summary.clone().work).clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), per_comparison), + left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), right: log_factor, }); let sort_os = seed_cost_map( @@ -7681,7 +7666,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), @@ -7709,7 +7694,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), @@ -7768,29 +7753,29 @@ pub fn empty_complexity_report() -> Rc { pub fn simplify_cost(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr.clone(), + CostExpr::CostConst { value: _, .. } => expr, CostExpr::CostAdd { left: l, right: r, .. } => { let sl = simplify_cost(l.clone()); let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr.clone(), + CostExpr::CostConst { value: 0, .. } => sr, CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, CostExpr::CostConst { value: b, .. } => Rc::new(CostExpr::CostConst { value: (a.clone() + b.clone()), }), _ => Rc::new(CostExpr::CostAdd { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, _ => Rc::new(CostExpr::CostAdd { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7805,15 +7790,15 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sr.clone(), + CostExpr::CostConst { value: 1, .. } => sr, _ => match (*sr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sl.clone(), + CostExpr::CostConst { value: 1, .. } => sl, _ => Rc::new(CostExpr::CostMul { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7825,26 +7810,26 @@ pub fn simplify_cost(expr: Rc) -> Rc { let sl = simplify_cost(l.clone()); let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr.clone(), + CostExpr::CostConst { value: 0, .. } => sr, CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, CostExpr::CostConst { value: b, .. } => { if (a.clone() > b.clone()) { - sl.clone() + sl } else { - sr.clone() + sr } } _ => Rc::new(CostExpr::CostMax { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl.clone(), + CostExpr::CostConst { value: 0, .. } => sl, _ => Rc::new(CostExpr::CostMax { - left: sl.clone(), - right: sr.clone(), + left: sl, + right: sr, }), }, }; @@ -7864,7 +7849,7 @@ pub fn simplify_cost(expr: Rc) -> Rc { _ => Rc::new(CostExpr::CostSum { binder: b.clone(), upper: u.clone(), - body: sbd.clone(), + body: sbd, }), } } @@ -7876,8 +7861,8 @@ pub fn simplify_cost(expr: Rc) -> Rc { base: b.clone(), argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -7926,23 +7911,23 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { let nl = normalize_asymptotic(l.clone()); let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl.clone() + nl } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr.clone(), + CostExpr::CostConst { value: 0, .. } => nr, CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr.clone(), + _ => nr, }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostAdd { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -7954,23 +7939,23 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { let nl = normalize_asymptotic(l.clone()); let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl.clone() + nl } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr.clone(), + CostExpr::CostConst { value: 0, .. } => nr, CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr.clone(), + _ => nr, }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl.clone(), - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostMax { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -7985,15 +7970,15 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nr.clone(), + CostExpr::CostConst { value: _, .. } => nr, _ => match (*nr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl, _ => Rc::new(CostExpr::CostMul { - left: nl.clone(), - right: nr.clone(), + left: nl, + right: nr, }), }, } @@ -8010,11 +7995,11 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { Rc::new(CostExpr::CostConst { value: 0 }) } _ => match (*u.clone()).clone() { - SizeExpr::SizeConst { value: _, .. } => nbd.clone(), + SizeExpr::SizeConst { value: _, .. } => nbd, _ => Rc::new(CostExpr::CostSum { binder: b.clone(), upper: u.clone(), - body: nbd.clone(), + body: nbd, }), }, } @@ -8027,8 +8012,8 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { base: b.clone(), argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -8235,7 +8220,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { }) } else { if ((unique.clone().len() as i64) == 1) { - match unique.clone().first().cloned() { + match unique.first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( v1_rt::rc_empty_map::(), @@ -8251,7 +8236,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { } } else { { - let indexed = unique.clone().iter().cloned().fold( + let indexed = unique.iter().cloned().fold( Rc::new(Legend { substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), @@ -8303,13 +8288,13 @@ pub fn substitute_size(size: Rc, legend: Rc>) Some(short) => Rc::new(SizeExpr::SizeVar { name: short.clone(), }), - None => size.clone(), + None => size, }, SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n.clone()) { Some(short) => Rc::new(SizeExpr::SizeVar { name: short.clone(), }), - None => size.clone(), + None => size, }, SizeExpr::SizeAdd { left: l, right: r, .. @@ -8323,7 +8308,7 @@ pub fn substitute_size(size: Rc, legend: Rc>) left: substitute_size(l.clone(), legend.clone()), right: substitute_size(r.clone(), legend.clone()), }), - SizeExpr::SizeConst { value: _, .. } => size.clone(), + SizeExpr::SizeConst { value: _, .. } => size, } }) } @@ -8331,7 +8316,7 @@ pub fn substitute_size(size: Rc, legend: Rc>) pub fn substitute_cost(expr: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr.clone(), + CostExpr::CostConst { value: _, .. } => expr, CostExpr::CostAdd { left: l, right: r, .. } => Rc::new(CostExpr::CostAdd { @@ -8368,8 +8353,8 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) base: b.clone(), argument: substitute_size(a.clone(), legend.clone()), }), - CostExpr::CostExtern { name: _, .. } => expr.clone(), - CostExpr::CostUnknown { reason: _, .. } => expr.clone(), + CostExpr::CostExtern { name: _, .. } => expr, + CostExpr::CostUnknown { reason: _, .. } => expr, } }) } @@ -8379,7 +8364,7 @@ pub fn classify_complexity(expr: Rc) -> String { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); let legend = build_legend(size_names); - let substituted = substitute_cost(normalized.clone(), legend.substitution.clone()); + let substituted = substitute_cost(normalized, legend.substitution.clone()); v1_rt::concat(format_cost_class(substituted), legend.suffix.clone()) } } @@ -8584,7 +8569,7 @@ pub fn cost_of_expr( let fname = expr_call_func_at(texpr.clone(), si.clone()); let callee_result = match v1_rt::map_get(&func_index, fname.clone()) { Some(entry) => get_or_compute_summary( - fname.clone(), + fname, func_index.clone(), scc_index.clone(), table, @@ -8624,13 +8609,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), - span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8641,13 +8626,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - args_result.summary.clone().work.clone(), - callee_result.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*args_result.summary.clone().work).clone(), + (*callee_result.summary.clone().work).clone(), ), - span: cost_seq( - args_result.summary.clone().span.clone(), - callee_result.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*args_result.summary.clone().span).clone(), + (*callee_result.summary.clone().span).clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), @@ -8670,7 +8655,7 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(recv.clone(), si.clone()); + let size = receiver_size_var(recv, si.clone()); let binder = size_binder_name(size.clone()); let method_cost_result = if (ms.clone() == None) { None @@ -8688,7 +8673,7 @@ pub fn cost_of_expr( pc, recv_r.clone(), mc_args.clone(), - size.clone(), + size, binder, func_index.clone(), scc_index.clone(), @@ -8719,7 +8704,7 @@ pub fn cost_of_expr( match method_cost_result { Some(result) => result.clone(), _ => { - let args_result = mc_args.clone().iter().cloned().fold( + let args_result = mc_args.iter().cloned().fold( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), @@ -8741,13 +8726,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), - span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8810,7 +8795,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - acc.result.clone().table.clone(), + (*acc.result).clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8818,13 +8803,13 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par)))))))( + (*(*acc.result).clone().summary.clone().work).clone(), + (*ar.summary.clone().work).clone(), ), - span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par)))))))( + (*(*acc.result).clone().summary.clone().span).clone(), + (*ar.summary.clone().span).clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), @@ -8846,25 +8831,31 @@ pub fn cost_of_expr( ), span: cost_conditional( s_r.summary.clone().span.clone(), - Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), + Rc::new(vec![ + (*arms_accum.result).clone().summary.clone().span.clone() + ]), ), - output_size: arms_accum - .result + output_size: (*arms_accum.result) .clone() .summary .clone() .output_size .clone(), - certainty: arms_accum.result.clone().summary.clone().certainty.clone(), + certainty: (*arms_accum.result) + .clone() + .summary + .clone() + .certainty + .clone(), }), - table: arms_accum.result.clone().table.clone(), + table: (*arms_accum.result).clone().table.clone(), }) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); let t = if_then_branch(texpr.clone()); let c_r = cost_of_expr( - c.clone(), + c, func_index.clone(), scc_index.clone(), table, @@ -8953,13 +8944,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - v_r.summary.clone().work.clone(), - b_r.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*v_r.summary.clone().work).clone(), + (*b_r.summary.clone().work).clone(), ), - span: cost_seq( - v_r.summary.clone().span.clone(), - b_r.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*v_r.summary.clone().span).clone(), + (*b_r.summary.clone().span).clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), @@ -8967,7 +8958,7 @@ pub fn cost_of_expr( table: b_r.table.clone(), }) } - None => v_r.clone(), + None => v_r, } } ExprData::ExprBlock => texpr.children.clone().iter().cloned().fold( @@ -8992,13 +8983,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - sr.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().work).clone(), + (*sr.summary.clone().work).clone(), ), - span: cost_seq( - acc.summary.clone().span.clone(), - sr.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().span).clone(), + (*sr.summary.clone().span).clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), @@ -9028,13 +9019,13 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(c.clone(), si.clone()); + let size = receiver_size_var(c, si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); + let loop_work = cost_loop(binder, size, bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), @@ -9063,13 +9054,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), - span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9100,13 +9091,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - cr.summary.clone().work.clone(), + work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().work).clone(), + (*cr.summary.clone().work).clone(), ), - span: cost_seq( - acc.summary.clone().span.clone(), - cr.summary.clone().span.clone(), + span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( + (*acc.summary.clone().span).clone(), + (*cr.summary.clone().span).clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9182,7 +9173,7 @@ pub fn get_or_compute_summary( None => Rc::new(vec![]), }; let is_scc = ((scc_members.clone().len() as i64) > 1); - let bounded = match target.clone() { + let bounded = match target { Some(t) => { if is_scc { Rc::new(ComplexitySummary { @@ -9194,7 +9185,7 @@ pub fn get_or_compute_summary( span: bounded_scc_cost( t.clone(), result.summary.clone().span.clone(), - scc_members.clone(), + scc_members, ), output_size: result.summary.clone().output_size.clone(), certainty: Certainty::Conservative, @@ -9224,10 +9215,13 @@ pub fn get_or_compute_summary( output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = - cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); + let final_table = cache_summary( + result.table.clone(), + func_name.clone(), + simplified.clone(), + ); Rc::new(SummaryResult { - summary: simplified.clone(), + summary: simplified, table: final_table, }) } @@ -9507,9 +9501,9 @@ pub fn max_path_descending( None => 0, }; let branch_max = if (then_count.clone() > else_count.clone()) { - then_count.clone() + then_count } else { - else_count.clone() + else_count }; (cond_count + branch_max) } @@ -9720,7 +9714,8 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) + > 0) { { let pattern = classify_recursion_pattern( @@ -9845,7 +9840,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - sr.table.clone(), + (*sr.table).clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), @@ -9865,9 +9860,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(evicted_table.clone(), func_name.clone()) + evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) } else { - evicted_table.clone() + Rc::new(evicted_table.clone()) }; Rc::new(TopoBuildAcc { table: final_table.clone(), @@ -9880,7 +9875,7 @@ pub fn build_complexity_report( None => acc.clone(), }, ); - let structural_bounds = analyze_structural_bounds(func_entries.clone(), si.clone()); + let structural_bounds = analyze_structural_bounds(func_entries.clone(), si); Rc::new(ComplexityReport { function_classes: result.classes.clone(), violations: result.violations.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index ce3e17515c4..9858b6c2687 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -163,7 +163,7 @@ pub fn render_rust_type( if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr.clone()) { return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => match find_property( n.properties.clone(), @@ -253,8 +253,8 @@ pub fn render_rust_type_without_applied_binding( match n.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -267,7 +267,7 @@ pub fn render_rust_type_without_applied_binding( ) { { let elem_name = - authored_name_at(source_indices.clone(), elem_node.clone()); + authored_name_at(source_indices.clone(), elem_node); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("Set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -516,8 +516,7 @@ pub fn is_host_text_carrier_type( if (nm.clone() == "String".to_string()) { true } else { - if ((nm.clone() == "FreeMonoid".to_string()) || (nm.clone() == "List".to_string())) - { + if ((nm.clone() == "FreeMonoid".to_string()) || (nm == "List".to_string())) { (rust_host_text_carrier_elem_name(n.clone(), source_indices.clone()) == "Char".to_string()) } else { @@ -638,7 +637,7 @@ pub fn type_leaf_name_for_collapse( if (a.clone() == "".to_string()) { n.name.clone() } else { - a.clone() + a } } } @@ -802,7 +801,7 @@ pub fn render_rust_applied_type_arg( ) { "()".to_string() } else { - match (*n.inferred).clone().as_deref().cloned() { + match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => to_pascal(tv.clone()), _ => render_rust_decl_type( n.clone(), @@ -834,7 +833,7 @@ pub fn render_rust_applied_type( if ((n.children.clone().len() as i64) == 0) { match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { Some(host) => host.clone(), - None => rust_named_type_base(base_name.clone(), corpus_repr.clone()), + None => rust_named_type_base(base_name, corpus_repr.clone()), } } else { { @@ -843,7 +842,7 @@ pub fn render_rust_applied_type( Some(host) => host.clone(), None => rust_applied_type_base(base_name.clone(), corpus_repr.clone()), }; - let peel = is_parametric_opaque_type_by_name(env.clone(), base_name.clone()); + let peel = is_parametric_opaque_type_by_name(env.clone(), base_name); let args = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { @@ -953,7 +952,7 @@ pub fn render_rust_decl_type( shared_types.clone(), corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), + variant_to_enum, env.clone(), ), None => { @@ -971,7 +970,7 @@ pub fn render_rust_decl_type( __found }) { - to_pascal(name.clone()) + to_pascal(name) } else { if (((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -986,16 +985,14 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) + && (applied_prop == None)) && v1_rt::set_contains(&shared_types, name.clone())) { { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); + let rendered = + rust_render_type_leaf_name(name.clone(), variant_to_enum); render_rust_shared_type_if_needed( - name.clone(), + name, rendered, shared_types.clone(), ) @@ -1009,7 +1006,7 @@ pub fn render_rust_decl_type( { render_rust_shared_type_if_needed( name.clone(), - name.clone(), + name, shared_types.clone(), ) } else { @@ -1059,7 +1056,7 @@ pub fn render_rust_decl_type( __result }); let applied_ty = if (name.clone() == tuple_type_name()) { - render_tuple_parts(arg_list.clone(), RenderTarget::Rust) + render_tuple_parts(arg_list, RenderTarget::Rust) } else { if node_is_keyed_collection( n.clone(), @@ -1082,9 +1079,7 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1092,9 +1087,7 @@ pub fn render_rust_decl_type( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1117,9 +1110,7 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ), @@ -1128,9 +1119,7 @@ pub fn render_rust_decl_type( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list - .clone() - .join(&", ".to_string()), + arg_list.join(&", ".to_string()), ), ">".to_string(), ) @@ -1138,7 +1127,7 @@ pub fn render_rust_decl_type( } }; render_rust_shared_type_if_needed( - name.clone(), + name, applied_ty, shared_types.clone(), ) @@ -1170,7 +1159,7 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { Some(b) => b.clone(), None => { let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name.clone()) { + match lookup_type_by_name(env.clone(), name) { Some(b) => b.clone(), None => return false, } @@ -1236,7 +1225,7 @@ pub fn render_rust_fn_sig_type( && !is_container_type(name.clone())) && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) { - render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) + render_rust_shared_type_if_needed(name.clone(), name, shared_types.clone()) } else { if ((generic_param_names.clone().len() as i64) > 0) { render_rust_decl_type( @@ -1285,7 +1274,7 @@ pub fn render_rust_fn_sig_type_applied_binding( { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types, ) } else { @@ -1319,15 +1308,15 @@ pub fn alias_rhs_container_arg( arg: Rc, source_indices: Rc>>, ) -> Rc { - match (*arg.inferred).clone().as_deref().cloned() { + match arg.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if node_is_collection(rt.clone(), source_indices) { rt.clone() } else { - arg.clone() + arg } } - _ => arg.clone(), + _ => arg, } } @@ -1364,7 +1353,7 @@ pub fn render_rust_alias_rhs_type( __found }) { - to_pascal(name.clone()) + to_pascal(name) } else { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -1383,12 +1372,10 @@ pub fn render_rust_alias_rhs_type( match rust_opaque_kernel_alias_carrier(name.clone()) { Some(carrier) => carrier.clone(), None => { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); + let rendered = + rust_render_type_leaf_name(name.clone(), variant_to_enum); render_rust_shared_type_if_needed( - name.clone(), + name, rendered, shared_types.clone(), ) @@ -1435,7 +1422,7 @@ pub fn render_rust_alias_rhs_type( }; let peel = is_parametric_opaque_type_base( name.clone(), - def_mod.clone(), + def_mod, typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -1487,12 +1474,12 @@ pub fn render_rust_alias_rhs_type( v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), ">".to_string(), ); - if (v1_rt::set_contains(&shared_types, name.clone()) + if (v1_rt::set_contains(&shared_types, name) && !rust_type_is_rc_wrapped(applied_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + wrap_shared_type(RenderTarget::Rust, applied_ty) } else { - applied_ty.clone() + applied_ty } } } else { @@ -1682,8 +1669,7 @@ pub fn rust_nominal_ord_type_ref_eligible( (((((elem_node.children.clone().len() as i64) == 0) && ((elem_node.params.clone().len() as i64) == 0)) && (elem_node.connective.clone() == Connective::NoConnective)) - && ((type_name.clone() == "Symbol".to_string()) - || (type_name.clone() == "DiffId".to_string()))) + && ((type_name.clone() == "Symbol".to_string()) || (type_name == "DiffId".to_string()))) } } @@ -1923,7 +1909,7 @@ pub fn rust_string_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name.clone(), + naming_name, )) } } @@ -2026,7 +2012,7 @@ pub fn rust_internal_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name.clone(), + naming_name, )) } } @@ -2087,7 +2073,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantEncoding: ".to_string(), - encoding_name.clone(), + encoding_name, )) } } @@ -2100,7 +2086,7 @@ pub fn resolve_wire_serde_policy( wire_item: Rc, source_indices: Rc>>, ) -> Rc { - match (*wire_item.body).clone() { + match wire_item.body.clone() { Some(ve) => resolve_wire_serde_policy_from_encoding_node(ve.clone(), source_indices), None => match (*wire_item.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => resolve_wire_serde_policy_from_encoding_node(wire_item.clone(), source_indices), @@ -2140,13 +2126,13 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( "wire_contract: VariantEncoding alias chain exceeded recursion limit".to_string(), ); } else { - match wire_contract_item { + match wire_contract_item.clone() { None => { break rust_tagged_object_policy(); } Some(wc) => { if is_data_def_item(wc.clone()) { - match (*wc.body).clone() { + match wc.body.clone() { None => { break rust_serde_error_policy( "wire_contract: data item has no initializer body".to_string(), @@ -2197,7 +2183,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( break rust_serde_error_policy(v1_rt::concat("wire_contract: ambiguous VariantEncoding data alias: ".to_string(), alias_name.clone())); } } - None => match (*init.inferred).clone() { + None => match init.inferred.clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2246,7 +2232,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( } } } - _ => match (*init.inferred).clone() { + _ => match init.inferred.clone() { None => { break rust_serde_error_policy("wire_contract: missing type inference on initializer (cannot resolve VariantEncoding alias)".to_string()); } @@ -2293,7 +2279,7 @@ pub fn coproduct_wire_contract_encoding( contract_item: Rc, source_indices: Rc>>, ) -> Option> { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => field_value_by_name(body.clone(), "encoding".to_string(), source_indices), None => None, } @@ -2311,7 +2297,7 @@ pub fn coproduct_wire_contract_targets( coproduct_name: String, source_indices: Rc>>, ) -> bool { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => (target_name.clone() == coproduct_name), None => false, @@ -2370,7 +2356,7 @@ pub fn data_item_type_is_coproduct_wire_contract( imports: Rc>>, source_indices: Rc>>, ) -> bool { - match (*item.type_annotation).clone() { + match item.type_annotation.clone() { Some(type_node) => { ((authored_name_at(source_indices.clone(), type_node.clone()) == "CoproductWireContract".to_string()) @@ -2423,7 +2409,7 @@ pub fn is_coproduct_wire_contract_row( ) { false } else { - match (*item.body).clone() { + match item.body.clone() { Some(body) => { ((field_value_by_name( body.clone(), @@ -2448,7 +2434,7 @@ pub fn emit_coproduct_wire_contract_target_validation( local_coproduct_names: Rc>, source_indices: Rc>>, ) -> String { - match (*contract_item.body).clone() { + match contract_item.body.clone() { Some(body) => match coproduct_decl_ref_decl_name(body.clone(), source_indices) { Some(target_name) => { if { @@ -2562,7 +2548,7 @@ pub fn resolve_local_coproduct_wire_policy( None } else { if ((contracts.clone().len() as i64) == 1) { - match contracts.clone().first().cloned() { + match contracts.first().cloned() { Some(contract) => match coproduct_wire_contract_encoding( contract.clone(), source_indices.clone(), @@ -2604,7 +2590,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, tm: Rc| { let module_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); Rc::new({ let mut __result = Vec::new(); @@ -2660,7 +2646,7 @@ pub fn build_scoped_data_item_index( { let module_name = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), - (*typed_module.module).clone(), + typed_module.module.clone(), ); let local = Rc::new({ let mut __result = Vec::new(); @@ -2686,11 +2672,11 @@ pub fn build_scoped_data_item_index( ) }, ); - module_imports((*typed_module.module).clone()) + module_imports(typed_module.module.clone()) .iter() .cloned() .fold( - local.clone(), + local, |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( (*typed_module.type_env).clone().source_indices.clone(), @@ -2736,7 +2722,7 @@ pub fn augment_scoped_data_item_index_with_imports( data_items: Rc>>, ) -> Rc>>>> { imports.iter().cloned().fold( - scoped.clone(), + scoped, |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at(source_indices.clone(), imp.clone()); if import_is_all(imp.clone()) { @@ -2836,7 +2822,7 @@ pub fn emit_rust_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2859,8 +2845,8 @@ pub fn emit_rust_block_stmts( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2884,7 +2870,7 @@ pub fn emit_rust_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2900,7 +2886,7 @@ pub fn emit_rust_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -2918,16 +2904,16 @@ pub fn emit_rust_init_block_stmts( ExprData::ExprLet => true, _ => false, }; - let line = if is_let { - raw_line + let line = if is_let.clone() { + raw_line.clone() } else { - v1_rt::concat(raw_line, ";".to_string()) + v1_rt::concat(raw_line.clone(), ";".to_string()) }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -3234,7 +3220,7 @@ pub fn build_shared_types( __result }); collection_keys.iter().cloned().fold( - user_shared.clone(), + user_shared, |acc: Rc>, key: String| { let pascal = to_pascal(key.clone()); v1_rt::rc_set_insert(acc, pascal.clone()) @@ -3266,7 +3252,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>>(), }), |acc: Rc, entry: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/05_emit_rust.dag:78228:acc"); { let read_only = if v1_rt::set_contains( &callable_set, @@ -3432,7 +3418,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if ((workflow_default_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: workflow_default_diags.clone(), + diagnostics: workflow_default_diags, }); } let svc_module_map = typed.modules.clone().iter().cloned().fold( @@ -3449,7 +3435,7 @@ pub fn emit_rust(typed: Rc) -> Rc { }); let mod_filename = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); svc_items.clone().iter().cloned().fold( acc, @@ -3494,7 +3480,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result.push(emit_test_file( authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), Rc::new({ let mut __result = Vec::new(); @@ -3502,7 +3488,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if (p.module_name.clone() == authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )) { __result.push(p); @@ -3530,7 +3516,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for m in typed.modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -3546,11 +3532,11 @@ pub fn emit_rust(typed: Rc) -> Rc { }; let cargo = emit_cargo_toml(crate_name.clone(), has_services.clone()); let main_file = emit_main_rs( - workflow_funcs.clone(), + workflow_funcs, typed.modules.clone(), has_services.clone(), - crate_name.clone(), - svc_module_map.clone(), + crate_name, + svc_module_map, ); let rt_file = emit_v2_rt_module(); let compiler_tests_file = if has_pipeline.clone() { @@ -3558,7 +3544,7 @@ pub fn emit_rust(typed: Rc) -> Rc { } else { Rc::new(vec![]) }; - let dry_run_file = if has_services.clone() { + let dry_run_file = if has_services { Rc::new(vec![emit_dry_run_module()]) } else { Rc::new(vec![]) @@ -3567,13 +3553,10 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::concat(module_files, Rc::new(vec![rt_file])), dry_run_file, ); - let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline.clone()); + let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline); let files = v1_rt::concat( v1_rt::concat( - v1_rt::concat( - Rc::new(vec![cargo, lib_file, main_file]), - all_mod_files.clone(), - ), + v1_rt::concat(Rc::new(vec![cargo, lib_file, main_file]), all_mod_files), compiler_tests_file, ), test_files, @@ -3694,7 +3677,7 @@ pub fn emit_module( emit_module_full( typed_module.clone(), registry, - emit_info.clone(), + emit_info, shared_types, v1_rt::rc_empty_map::(), build_data_item_index(Rc::new(vec![typed_module.clone()])), @@ -3713,10 +3696,10 @@ pub fn build_module_export_sets( |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); let exported = get_exported_names( - (*tm.module).clone(), + tm.module.clone(), (*tm.type_env).clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( @@ -3747,7 +3730,7 @@ pub fn emit_module_full( let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - authored_name(scope.type_env.clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()), typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3757,7 +3740,7 @@ pub fn emit_module_full( ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(m.clone()).iter().cloned() { + for imp in module_imports(Rc::new(m.clone())).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), @@ -3798,7 +3781,7 @@ pub fn emit_module_full( __result }); let imports_str = emit_imports( - module_imports(m.clone()), + module_imports(Rc::new(m.clone())), emit_info.clone(), registry.clone(), local_type_names, @@ -3810,10 +3793,10 @@ pub fn emit_module_full( let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) + v1_rt::concat("\n".to_string(), imports_str) }; let this_mod_filename = - module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3869,10 +3852,7 @@ pub fn emit_module_full( let svc_imports_str = if ((extern_svc_imports.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat( - "\n".to_string(), - extern_svc_imports.clone().join(&"\n".to_string()), - ) + v1_rt::concat("\n".to_string(), extern_svc_imports.join(&"\n".to_string())) }; let local_enum_uses = Rc::new({ let mut __result = Vec::new(); @@ -3921,8 +3901,8 @@ pub fn emit_module_full( } __result }); - let module_import_items = module_imports(m.clone()); - let this_module_name = authored_name(scope.type_env.clone(), m.clone()); + let module_import_items = module_imports(Rc::new(m.clone())); + let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( @@ -3935,7 +3915,7 @@ pub fn emit_module_full( let wire_context_imports = v1_rt::concat( module_import_items, contracts_imports_for_module( - this_module_name.clone(), + this_module_name, typed_modules.clone(), (*scope.type_env).clone().source_indices.clone(), module_index.clone(), @@ -3951,18 +3931,12 @@ pub fn emit_module_full( if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat( - coproduct_wire_contract_validations.clone(), - "\n\n".to_string(), - ) + v1_rt::concat(coproduct_wire_contract_validations, "\n\n".to_string()) }; let local_uses_str = if ((local_enum_uses.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat( - "\n".to_string(), - local_enum_uses.clone().join(&"\n".to_string()), - ) + v1_rt::concat("\n".to_string(), local_enum_uses.join(&"\n".to_string())) }; let wire_contract_item = Rc::new({ let mut __result = Vec::new(); @@ -3985,7 +3959,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - authored_name(scope.type_env.clone(), m.clone()), + Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -4003,26 +3977,26 @@ pub fn emit_module_full( }) .join(&"\n\n".to_string()); let phantom_zst_markers = - emit_module_phantom_zst_markers(typed_module.items.clone(), (*scope.type_env).clone()); + emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers) }; - let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); + let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { - raw_filename.clone() + raw_filename }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) + let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4141,7 +4115,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>, tm: Rc| { let nm = authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { Some(_) => acc.clone(), @@ -4154,7 +4128,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { Some(prior) => v1_rt::rc_map_insert( @@ -4213,7 +4187,7 @@ pub fn contracts_imports_for_module( source_indices, module_index, ) { - Some(tm) => module_imports((*tm.module).clone()), + Some(tm) => module_imports(tm.module.clone()), None => Rc::new(vec![]), } } @@ -4230,7 +4204,7 @@ pub fn module_name_from_filename( for tm in mods.clone().iter().cloned() { __result.push(authored_name_at( source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )); } __result @@ -4404,7 +4378,7 @@ pub fn type_name_is_rust_importable_in_module( item.clone(), name.clone(), module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), registry, export_sets, @@ -4445,7 +4419,7 @@ pub fn imported_name_is_non_emittable_type( module_index.clone(), ) && (type_name_is_rust_importable_in_module( name.clone(), - defining_module.clone(), + defining_module, typed_modules.clone(), registry, export_sets.clone(), @@ -4496,7 +4470,7 @@ pub fn name_in_transitive_export_surface( let mut __found = false; for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -4607,7 +4581,7 @@ pub fn reexport_source_module_name_with_visited( for imp in Rc::new({ let mut __result = Vec::new(); for imp in - module_imports((*tm.module).clone()).iter().cloned() + module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -4658,7 +4632,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()) + for imp in module_imports(tm.module.clone()) .iter() .cloned() { @@ -4926,7 +4900,7 @@ pub fn wildcard_import_pool_surface_names( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5054,7 +5028,7 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - mod_name.clone() + mod_name } else { match reexport_source_module_name( name.clone(), @@ -5065,7 +5039,7 @@ pub fn graph_type_import_module_filename( module_index.clone(), ) { Some(src) => module_to_filename(src.clone()), - None => mod_name.clone(), + None => mod_name, } } } @@ -5107,11 +5081,11 @@ pub fn variant_defining_module_filename_for_import( continue; } } else { - break fallback; + break fallback.clone(); } } None => { - break fallback; + break fallback.clone(); } } } @@ -5183,7 +5157,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()) @@ -5219,7 +5193,7 @@ pub fn explicit_import_source_module_for_name( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in module_imports((*tm.module).clone()).iter().cloned() { + for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } @@ -5273,7 +5247,7 @@ pub fn reexport_variant_parent_in_import_module( loop { match reexport_source_module_name( variant_name.clone(), - import_module, + import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), @@ -5354,7 +5328,7 @@ pub fn alias_rhs_rust_qualify_module_filename( source_indices.clone(), module_index.clone(), ) { - spell_mod.clone() + spell_mod } else { match module_name_from_filename( spell_mod.clone(), @@ -5371,9 +5345,9 @@ pub fn alias_rhs_rust_qualify_module_filename( module_index.clone(), ) { Some(src) => module_to_filename(src.clone()), - None => spell_mod.clone(), + None => spell_mod, }, - None => spell_mod.clone(), + None => spell_mod, } } } @@ -5608,7 +5582,7 @@ pub fn type_item_has_rust_nominal_shell_authority( && ((rhs.children.clone().len() as i64) > 0)) { alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -5629,9 +5603,9 @@ pub fn type_item_has_rust_nominal_shell_authority( rhs.clone(), ); (((rhs_name.clone() != item_text.clone()) - && (rhs_name.clone() != "".to_string())) + && (rhs_name != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -5679,7 +5653,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( mut module_index: Rc, ) -> bool { loop { - if is_phantom_unit_variant_type_arg((*scope.type_env).clone(), rhs_name.clone()) { + if is_phantom_unit_variant_type_arg(scope.type_env.clone(), rhs_name.clone()) { break true; } else { match type_item_by_name_in_module_filename( @@ -5708,9 +5682,9 @@ pub fn rhs_base_has_rust_type_authority_in_module( item.clone(), rhs_name.clone(), def_module_name.clone(), - module_imports((*tm.module).clone()), + module_imports(tm.module.clone()), module_emit_scope(tm.clone()), - registry, + registry.clone(), export_sets.clone(), typed_modules.clone(), source_indices.clone(), @@ -5801,7 +5775,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); (rhs_base_has_rust_type_authority_in_module( - name.clone(), + name, def_mod, module_name.clone(), imports.clone(), @@ -5836,8 +5810,8 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - if (((*n.inferred).clone() != None) - && is_type_variable((*n.inferred).clone().clone().unwrap())) + if ((n.inferred.clone() != None) + && is_type_variable(n.inferred.clone().clone().unwrap())) { true } else { @@ -5847,7 +5821,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( true } else { if is_phantom_unit_variant_type_arg( - (*scope.type_env).clone(), + scope.type_env.clone(), name.clone(), ) { true @@ -5865,7 +5839,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); rhs_base_has_rust_type_authority_in_module( - name.clone(), + name, def_mod, module_name.clone(), imports.clone(), @@ -5896,7 +5870,7 @@ pub fn is_self_referential_opaque_type_resolved( let item_text = authored_name_at(source_indices.clone(), item.clone()); let rhs = resolved_type(item.clone()); (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), rhs.clone()) == item_text)) + && (authored_name_at(source_indices.clone(), rhs) == item_text)) } } @@ -5912,8 +5886,8 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && ((*item.body).clone() == None)) - && ((*item.transport).clone() == None)) + ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + && (item.transport.clone() == None)) && ((item.children.clone().len() as i64) == 0)) && (!is_type_alias_return_node(resolved_type(item.clone()), source_indices.clone()) || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) @@ -5968,8 +5942,8 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs = resolved_type(item.clone()); - if (((*rhs.inferred).clone() != None) - && is_compiler_error((*rhs.inferred).clone().clone().unwrap())) + if ((rhs.inferred.clone() != None) + && is_compiler_error(rhs.inferred.clone().clone().unwrap())) { false } else { @@ -5981,9 +5955,9 @@ pub fn is_emittable_parametric_type_alias_item( ((rhs_name.clone() != item_text) && (((rhs.children.clone().len() as i64) > 0) || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name.clone() != "".to_string())) + && (rhs_name != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), + rhs, module_name, imports, scope, @@ -6298,7 +6272,7 @@ pub fn emit_specific_import_block( __result }); let merged_direct_names = - unique_strings(v1_rt::concat(direct_names.clone(), local_parent_names)); + unique_strings(v1_rt::concat(direct_names, local_parent_names)); let type_direct_names = Rc::new({ let mut __result = Vec::new(); for n in merged_direct_names.clone().iter().cloned() { @@ -6319,7 +6293,7 @@ pub fn emit_specific_import_block( }); let other_direct_names = Rc::new({ let mut __result = Vec::new(); - for n in merged_direct_names.clone().iter().cloned() { + for n in merged_direct_names.iter().cloned() { if (is_import_graph_type_name( n.clone(), import_module.clone(), @@ -6414,7 +6388,7 @@ pub fn emit_specific_import_block( { let names_str = Rc::new({ let mut __result = Vec::new(); - for n in other_direct_names.clone().iter().cloned() { + for n in other_direct_names.iter().cloned() { __result.push(emit_import_name(n.clone(), registry.clone())); } __result @@ -6451,7 +6425,7 @@ pub fn emit_specific_import_block( __result }), if (other_direct_line.clone() != "".to_string()) { - Rc::new(vec![other_direct_line.clone()]) + Rc::new(vec![other_direct_line]) } else { Rc::new(vec![]) }, @@ -6545,7 +6519,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib }); let main_lines = if ((direct_lines.clone().len() as i64) > 0) { v1_rt::concat( - direct_lines.clone(), + direct_lines, Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { @@ -6605,7 +6579,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con }); let imported_enums = Rc::new({ let mut __result = Vec::new(); - for n in top_level.clone().iter().cloned() { + for n in top_level.iter().cloned() { if is_enum_in_summaries(type_summaries.clone(), n.clone()) { __result.push(n); } @@ -6616,7 +6590,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con let mut __result = Vec::new(); for en in Rc::new({ let mut __result = Vec::new(); - for en in imported_enums.clone().iter().cloned() { + for en in imported_enums.iter().cloned() { if (({ let mut __found = false; for p in parent_list.clone().iter().cloned() { @@ -7187,10 +7161,10 @@ pub fn emit_prelude(imported_names: Rc>) -> String { let variant_line = if (has_holds.clone() && has_violates.clone()) { "".to_string() } else { - if has_holds.clone() { + if has_holds { "\nuse crate::v1_rt::Witness::Violates;".to_string() } else { - if has_violates.clone() { + if has_violates { "\nuse crate::v1_rt::Witness::Holds;".to_string() } else { "\nuse crate::v1_rt::Witness::{Holds, Violates};".to_string() @@ -7232,15 +7206,15 @@ pub fn emit_typed_item( let env = (*scope.type_env).clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env.clone()), item.clone()), ); - let item_text = authored_name(env.clone(), item.clone()); + let item_text = authored_name(Rc::new(env.clone()), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - env.clone(), + Rc::new(env), emit_info.clone(), wire_contract_item, data_items, @@ -7263,7 +7237,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text.clone()) + rust_nominal_identity_carrier_def(item_text) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -7289,7 +7263,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), " = ".to_string(), ), @@ -7308,7 +7282,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), " = ".to_string(), ), @@ -7339,7 +7313,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text.clone()) + rust_nominal_identity_carrier_def(item_text) } else { match rust_seed_host_container_base( item_text.clone(), @@ -7370,7 +7344,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), @@ -7382,7 +7356,7 @@ pub fn emit_typed_item( ), Rc::new({ let mut __result = Vec::new(); - for n in generic_names.clone().iter().cloned() { + for n in generic_names.iter().cloned() { __result.push(to_pascal(n.clone())); } __result @@ -7425,16 +7399,14 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( "std::marker::PhantomData<".to_string(), - rust_phantom_marker_inner( - unused_params.clone(), - ), + rust_phantom_marker_inner(unused_params), ), ">".to_string(), ) } else { render_rust_alias_rhs_type( - alias_rhs.clone(), - generic_names.clone(), + alias_rhs, + generic_names, shared_types, emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -7462,7 +7434,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), @@ -7500,8 +7472,8 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(env.clone(), item.clone()), - (*item.body).clone().clone().unwrap(), + authored_name(Rc::new(env.clone()), item.clone()), + item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); @@ -7516,12 +7488,12 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco.clone() { + let fn_move_sites = if item_is_tco { v1_rt::rc_empty_map::() } else { match v1_rt::map_get( &emit_info.move_sites_index.clone(), - qualified_name.clone(), + qualified_name, ) { Some(m) => m.clone(), None => v1_rt::rc_empty_map::(), @@ -7547,7 +7519,7 @@ pub fn emit_typed_item( }); let is_effectful = match lookup_item( registry.clone(), - authored_name(env.clone(), item.clone()), + authored_name(Rc::new(env), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7557,11 +7529,11 @@ pub fn emit_typed_item( }; if is_effectful { emit_func_def( - item_text.clone(), + item_text, item.params.clone(), resolved_type(item.clone()), item.uses.clone(), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7569,10 +7541,10 @@ pub fn emit_typed_item( ) } else { emit_fn_def( - item_text.clone(), + item_text, item.params.clone(), resolved_type(item.clone()), - (*item.body).clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), shared_types, @@ -7583,9 +7555,9 @@ pub fn emit_typed_item( } else { if is_data_def_item(item.clone()) { emit_data_def( - item_text.clone(), - (*item.type_annotation).clone().clone().unwrap(), - (*item.body).clone().clone().unwrap(), + item_text, + item.type_annotation.clone().clone().unwrap(), + item.body.clone().clone().unwrap(), registry.clone(), scope.clone(), 0, @@ -7599,7 +7571,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env), ) } else { if is_resource_def_item(item.clone()) { @@ -7607,13 +7579,13 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - env.clone(), + Rc::new(env), ) } else { v1_rt::concat( v1_rt::concat( "compile_error!(\"unhandled item: ".to_string(), - item_text.clone(), + item_text, ), "\");".to_string(), ) @@ -7658,7 +7630,7 @@ pub fn needs_box_wrapping( } } else { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional { + if is_optional.clone() { { let __tco_0 = with_required_cardinality(n); n = __tco_0; @@ -7734,7 +7706,7 @@ pub fn emit_type_params_with_clone_bound( pub fn is_function_type_param(param: Rc) -> bool { { let type_expr = param_node_type_expr(param.clone()); - let type_expr_is_var = match (*type_expr.inferred).clone() { + let type_expr_is_var = match type_expr.inferred.clone() { Some(inf) => is_type_variable(inf.clone()), None => false, }; @@ -7780,7 +7752,7 @@ pub fn function_type_params_have_collision(type_params: Rc>>) -> bo } __result }); - ((names.clone().len() as i64) > (unique_strings(names.clone()).len() as i64)) + ((names.clone().len() as i64) > (unique_strings(names).len() as i64)) } } @@ -7809,7 +7781,7 @@ pub fn emit_type_def_from_connective( __result }); emit_struct_from_children( - item_text.clone(), + item_text, type_params, generic_param_names, item.children.clone(), @@ -7842,7 +7814,7 @@ pub fn emit_type_def_from_connective( rust_visibility_prefix(), "type ".to_string(), ), - item_text.clone(), + item_text, ), type_params, ), @@ -7874,7 +7846,7 @@ pub fn emit_type_def_from_connective( ) { Some(local_policy) => local_policy.clone(), None => { - if all_unit_variants.clone() { + if all_unit_variants { match wire_contract_item.clone() { Some(_) => resolve_wire_serde_policy_for_coproduct( wire_contract_item.clone(), @@ -7898,14 +7870,14 @@ pub fn emit_type_def_from_connective( None => "".to_string(), }; let validations = if (policy_validation.clone() == "".to_string()) { - rename_validations.clone() + rename_validations } else { if (rename_validations.clone() == "".to_string()) { - policy_validation.clone() + policy_validation } else { v1_rt::concat( - v1_rt::concat(policy_validation.clone(), "\n".to_string()), - rename_validations.clone(), + v1_rt::concat(policy_validation, "\n".to_string()), + rename_validations, ) } }; @@ -7918,23 +7890,20 @@ pub fn emit_type_def_from_connective( __result }); let enum_text = emit_enum_from_children( - item_text.clone(), + item_text, type_params, generic_param_names, item.children.clone(), recursive_types, shared_types, env.clone(), - serde_policy.clone(), + serde_policy, emit_info.clone(), ); if (validations.clone() == "".to_string()) { enum_text } else { - v1_rt::concat( - v1_rt::concat(validations.clone(), "\n".to_string()), - enum_text, - ) + v1_rt::concat(v1_rt::concat(validations, "\n".to_string()), enum_text) } } } @@ -8020,13 +7989,10 @@ pub fn rust_phantom_marker_inner(unused: Rc>) -> String { __result }); if ((pascal_unused.clone().len() as i64) == 1) { - pascal_unused.clone().join(&", ".to_string()) + pascal_unused.join(&", ".to_string()) } else { v1_rt::concat( - v1_rt::concat( - "(".to_string(), - pascal_unused.clone().join(&", ".to_string()), - ), + v1_rt::concat("(".to_string(), pascal_unused.join(&", ".to_string())), ")".to_string(), ) } @@ -8128,7 +8094,7 @@ pub fn emit_struct_from_children( ), ": std::marker::PhantomData<".to_string(), ), - rust_phantom_marker_inner(unused_params.clone()), + rust_phantom_marker_inner(unused_params), ), ">,".to_string(), )]), @@ -8195,14 +8161,14 @@ pub fn render_rust_type_with_applied_binding( if (outer_name.clone() != applied_name) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types.clone(), ) } else { if v1_rt::set_contains(&shared_types, outer_name.clone()) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name.clone(), + outer_name, shared_types.clone(), ) } else { @@ -8328,7 +8294,7 @@ pub fn render_rust_field_type_with_applied_binding( ) != None) { render_rust_type_with_applied_binding( - authored_type.clone(), + authored_type, shared_types, corpus_repr, source_indices.clone(), @@ -8338,7 +8304,7 @@ pub fn render_rust_field_type_with_applied_binding( && ((authored_type.children.clone().len() as i64) > 0)) { render_rust_type( - authored_type.clone(), + authored_type, shared_types, corpus_repr, source_indices.clone(), @@ -8400,7 +8366,7 @@ pub fn emit_struct_field_from_child( ) != None) { render_rust_type_with_applied_binding( - authored_child_type.clone(), + authored_child_type, shared_types.clone(), emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -8455,7 +8421,7 @@ pub fn emit_struct_field_from_child( ">".to_string(), ); render_rust_shared_type_if_needed( - rt_child_name.clone(), + rt_child_name, with_params, shared_types.clone(), ) @@ -8501,20 +8467,20 @@ pub fn emit_struct_field_from_child( env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), generic_ty.clone()), + v1_rt::concat("Box<".to_string(), generic_ty), ">".to_string(), ) } else { if (((rt_child.return_cardinality.clone() != Cardinality::CardOptional) && v1_rt::set_contains( &shared_types, - authored_name_at(env.source_indices.clone(), rt_child.clone()), + authored_name_at(env.source_indices.clone(), rt_child), )) && !rust_type_is_rc_wrapped(generic_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, generic_ty.clone()) + wrap_shared_type(RenderTarget::Rust, generic_ty) } else { - generic_ty.clone() + generic_ty } }; let rename_attr = match Rc::new({ @@ -8571,7 +8537,7 @@ pub fn emit_rust_field_definition( v1_rt::concat( v1_rt::concat( v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), + snake, ), "\")]\n".to_string(), ) @@ -8589,7 +8555,7 @@ pub fn emit_rust_field_definition( ), visibility, ), - emitted.clone(), + emitted, ), ": ".to_string(), ), @@ -8694,10 +8660,7 @@ pub fn emit_enum_from_children( if (accessor_impl.clone() == "".to_string()) { enum_def } else { - v1_rt::concat( - v1_rt::concat(enum_def, "\n".to_string()), - accessor_impl.clone(), - ) + v1_rt::concat(v1_rt::concat(enum_def, "\n".to_string()), accessor_impl) } } } @@ -8796,7 +8759,7 @@ pub fn emit_enum_shared_accessors( let first_fielded = fielded.clone().first().cloned().clone().unwrap(); let shared = Rc::new({ let mut __result = Vec::new(); - for fname in all_shared.clone().iter().cloned() { + for fname in all_shared.iter().cloned() { if { let types = Rc::new({ let mut __result = Vec::new(); @@ -8855,7 +8818,7 @@ pub fn emit_enum_shared_accessors( } let accessor_fns = Rc::new({ let mut __result = Vec::new(); - for fname in shared.clone().iter().cloned() { + for fname in shared.iter().cloned() { __result.push({ let ty = match Rc::new({ let mut __result = Vec::new(); @@ -9150,7 +9113,7 @@ pub fn policy_serde_tag_field(policy: Rc) -> Option { ) { Some(end) => Some(v1_rt::substring( &policy.enum_attr.clone(), - after.clone(), + after, end.clone(), )), None => None, @@ -9286,7 +9249,7 @@ pub fn enum_variant_field_type_node( Some(variant) => { match find_child_named(variant.clone(), field_name, source_indices.clone()) { Some(field) => { - if ((*field.inferred).clone() != None) { + if (field.inferred.clone() != None) { resolved_type(field.clone()) } else { fallback @@ -9338,12 +9301,7 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) + render_rust_type(n.clone(), shared_types, corpus_repr, source_indices.clone()) } } @@ -9377,10 +9335,7 @@ pub fn emit_variant_from_child( wire_variant_rename_attr_for_policy(child_text.clone(), serde_policy.clone()); if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( - v1_rt::concat( - v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), - ), + v1_rt::concat(v1_rt::concat(rename_attr, " ".to_string()), child_text), ",".to_string(), ) } else { @@ -9408,7 +9363,7 @@ pub fn emit_variant_from_child( } else { fallback }; - let raw_ty = if positional_payload.clone() { + let raw_ty = if positional_payload { render_variant_payload_type( type_node.clone(), shared_types.clone(), @@ -9439,28 +9394,28 @@ pub fn emit_variant_from_child( raw_ty }; let final_ty = if needs_box_wrapping( - type_node.clone(), - recursive_types.clone(), + type_node, + recursive_types, shared_types.clone(), env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), ty.clone()), + v1_rt::concat("Box<".to_string(), ty), ">".to_string(), ) } else { - ty.clone() + ty }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), "(".to_string(), ), - final_ty.clone(), + final_ty, ), "),".to_string(), ) @@ -9468,7 +9423,7 @@ pub fn emit_variant_from_child( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), ",".to_string(), ), @@ -9519,7 +9474,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), " {\n".to_string(), ), @@ -9576,7 +9531,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text.clone(), + child_text, ), " {\n".to_string(), ), @@ -9608,7 +9563,7 @@ pub fn emit_fn_def( None }; if (host_text_op.clone() != None) { - return match host_text_op.clone() { + return match host_text_op { Some(op_fn) => op_fn.clone(), None => "".to_string(), }; @@ -9666,13 +9621,9 @@ pub fn emit_fn_def( > 0); let needs_clone_bound = (return_is_bare_generic && !body_is_param_ref); let type_params_str = if needs_clone_bound { - emit_type_params_with_clone_bound( - type_params.clone(), - ret_name.clone(), - si.clone(), - ) + emit_type_params_with_clone_bound(type_params, ret_name, si.clone()) } else { - emit_type_params(type_params.clone(), si.clone()) + emit_type_params(type_params, si.clone()) }; let params_str = emit_params( value_params.clone(), @@ -9682,7 +9633,7 @@ pub fn emit_fn_def( si.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -9691,7 +9642,7 @@ pub fn emit_fn_def( emit_info.corpus_repr.clone(), si.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); let depth = 0; @@ -9700,21 +9651,21 @@ pub fn emit_fn_def( let needs_stacker = (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) && (use_tco.clone() == false)); - if use_tco.clone() { + if use_tco { { let tco_params_str = emit_tco_params( value_params.clone(), - generic_param_names.clone(), + generic_param_names, shared_types.clone(), emit_info.corpus_repr.clone(), - si.clone(), + si, emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), name.clone(), - value_params.clone(), + value_params, registry.clone(), body_scope, (depth.clone() + 1), @@ -9756,7 +9707,7 @@ pub fn emit_fn_def( ), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ), @@ -9772,7 +9723,7 @@ pub fn emit_fn_def( body.clone(), registry.clone(), body_scope, - depth.clone(), + depth, shared_types.clone(), emit_info.clone(), needs_stacker, @@ -9942,7 +9893,7 @@ pub fn emit_func_def( (*scope.type_env).clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -9966,7 +9917,7 @@ pub fn emit_func_def( let body_str = emit_func_body( body, registry.clone(), - body_scope.clone(), + body_scope, (depth.clone() + 1), shared_types.clone(), emit_info.clone(), @@ -10003,7 +9954,7 @@ pub fn emit_func_def( ), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_str, ), @@ -10039,8 +9990,8 @@ pub fn emit_func_body( let let_line = emit_let_binding(n.clone(), val_str, RenderTarget::Rust); let next_scope = extend_scope( scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { @@ -10073,7 +10024,7 @@ pub fn emit_func_body( shared_types.clone(), emit_info.clone(), ); - let last_stmt = ss.clone().last().cloned(); + let last_stmt = ss.last().cloned(); let last_str = match last_stmt { Some(s) => match (*s.expr_data.clone()).clone() { ExprData::ExprReturn => v1_rt::concat( @@ -10199,7 +10150,7 @@ pub fn emit_tco_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored.clone(), + authored, generic_param_names, shared_types, corpus_repr, @@ -10394,7 +10345,7 @@ pub fn emit_rust_param_type( __result }); let param_str = param_types.join(&", ".to_string()); - let ret_str = match (*n.inferred).clone().as_deref().cloned() { + let ret_str = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => render_rust_fn_sig_type( rt.clone(), generic_param_names.clone(), @@ -10444,7 +10395,7 @@ pub fn emit_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored.clone(), + authored, generic_param_names, shared_types, corpus_repr, @@ -10621,7 +10572,7 @@ pub fn collect_pattern_string_guards( mut source_indices: Rc>>, ) -> String { loop { - match (*pattern).clone() { + match (*pattern.clone()).clone() { MatchPattern::VariantPattern { name: n, parent_enum: parent, @@ -10675,18 +10626,18 @@ pub fn collect_pattern_string_guards( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), "0".to_string(), ); if is_string_lit_pattern(fb_pat.clone()) { break positional_payload_string_guard( fb_pat.clone(), - pattern_string_binding_name(pos_path), + pattern_string_binding_name(pos_path.clone()), ); } else { { let __tco_0 = fb_pat.clone(); - let __tco_1 = pos_path; + let __tco_1 = pos_path.clone(); pattern = __tco_0; path_prefix = __tco_1; continue; @@ -10695,7 +10646,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), source_indices.clone(), ); } @@ -10707,7 +10658,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix, n.clone()), + v1_rt::rc_list_push(path_prefix.clone(), n.clone()), source_indices.clone(), ); } @@ -10815,7 +10766,7 @@ pub fn pattern_parent_enum( let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { - parent_enum.clone() + parent_enum } else { if scrut_is_known_enum { Some(scrut_type.clone()) @@ -10847,7 +10798,7 @@ pub fn unique_variant_parent( __result }); if ((parent_matches.clone().len() as i64) == 1) { - parent_matches.clone().first().cloned() + parent_matches.first().cloned() } else { None } @@ -10881,14 +10832,14 @@ pub fn positional_payload_scrut_type( Some(summary) => match v1_rt::map_get(&summary.field_type_map.clone(), "0".to_string()) { Some(payload_type) => payload_type.clone(), - None => match (*field_binding.inferred).clone().as_deref().cloned() { + None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } _ => "".to_string(), }, }, - None => match (*field_binding.inferred).clone().as_deref().cloned() { + None => match field_binding.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, normalize_access_type_node(rt.clone())) } @@ -10943,7 +10894,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10954,9 +10905,9 @@ pub fn emit_variant_pattern( } else { { let inner_pat = emit_pattern( - fb_pat.clone(), - v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), - shared_types.clone(), + fb_pat, + v1_rt::rc_list_push(path_prefix, rust_name), + shared_types, scrut_type.clone(), source_indices.clone(), emit_info.clone(), @@ -10968,7 +10919,7 @@ pub fn emit_variant_pattern( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -10980,38 +10931,38 @@ pub fn emit_variant_pattern( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), name.clone()), + v1_rt::rc_list_push(path_prefix, name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(ref ".to_string()), - bind_name.clone(), + v1_rt::concat(qualified, "(ref ".to_string()), + bind_name, ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent.clone(), + resolved_parent, name.clone(), fb.clone(), emit_info.clone(), source_indices.clone(), ); let inner_pat = emit_pattern( - fb_pat.clone(), - pos_path.clone(), - shared_types.clone(), + fb_pat, + pos_path, + shared_types, payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(".to_string()), + v1_rt::concat(qualified, "(".to_string()), inner_pat, ), ")".to_string(), @@ -11028,19 +10979,13 @@ pub fn emit_variant_pattern( { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), + v1_rt::rc_list_push(path_prefix, name.clone()), + fb_name, )); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - bind_name.clone(), + v1_rt::concat(qualified, " { ref ".to_string()), + bind_name, ), ", .. }".to_string(), ) @@ -11048,31 +10993,25 @@ pub fn emit_variant_pattern( } else { { let pat_str = emit_pattern( - fb_pat.clone(), + fb_pat, v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), + v1_rt::rc_list_push(path_prefix, name.clone()), fb_name.clone(), ), - shared_types.clone(), + shared_types, "".to_string(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), + emit_ident(fb_name, RenderTarget::Rust), ": ".to_string(), ), - pat_str.clone(), + pat_str, ), ), ", .. }".to_string(), @@ -11082,12 +11021,12 @@ pub fn emit_variant_pattern( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent.clone() { + let shape_key = match resolved_parent { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11101,20 +11040,19 @@ pub fn emit_variant_pattern( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = (v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - shape_key.clone(), - ) || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = + (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) + || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11134,7 +11072,7 @@ pub fn emit_variant_pattern( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent.clone() { + let shape_key2 = match resolved_parent { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11150,18 +11088,18 @@ pub fn emit_variant_pattern( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2.clone(), + shape_key2, ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11169,7 +11107,7 @@ pub fn emit_variant_pattern( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.clone().iter().cloned() { + for fb in effective_bindings.iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11268,7 +11206,7 @@ pub fn emit_variant_pattern( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11341,7 +11279,7 @@ pub fn analyze_rc_pattern( "".to_string(), shared_types.clone(), emit_info.clone(), - source_indices.clone(), + source_indices, ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, @@ -11411,7 +11349,7 @@ pub fn analyze_rc_pattern( matches_rc_variant: matches_rc_variant, matches_option_rc_variant: false, needs_rc_pattern: ((ref_bound_fields.clone().len() as i64) > 0), - ref_bound_fields: ref_bound_fields.clone(), + ref_bound_fields: ref_bound_fields, }) } } @@ -11442,13 +11380,13 @@ pub fn analyze_rc_match( } __result }); - let scrutinee_is_optional = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrutinee_is_optional = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } _ => false, }; - let scrutinee_is_rc_wrapped = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrutinee_is_rc_wrapped = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { if (((rt.children.clone().len() as i64) == 0) && (rt.ident_span.clone() != None)) { v1_rt::set_contains( @@ -11473,7 +11411,7 @@ pub fn analyze_rc_match( }; let arms_want_deref = { let mut __found = false; - for a in arm_analyses.clone().iter().cloned() { + for a in arm_analyses.iter().cloned() { if a.matches_rc_variant.clone() { __found = true; break; @@ -11570,7 +11508,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -11588,9 +11526,9 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat.clone(), - v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), - inner_analysis.clone(), + fb_pat, + v1_rt::rc_list_push(path_prefix, rust_name), + inner_analysis, shared_types.clone(), scrut_type.clone(), source_indices.clone(), @@ -11603,7 +11541,7 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -11615,22 +11553,22 @@ pub fn emit_variant_pattern_rc_aware( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), name.clone()), + v1_rt::rc_list_push(path_prefix, name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(ref ".to_string()), - bind_name.clone(), + v1_rt::concat(qualified, "(ref ".to_string()), + bind_name, ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent.clone(), + resolved_parent, name.clone(), fb.clone(), emit_info.clone(), @@ -11644,17 +11582,17 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat.clone(), - pos_path.clone(), - inner_analysis.clone(), + fb_pat, + pos_path, + inner_analysis, shared_types.clone(), - payload_scrut.clone(), + payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), "(".to_string()), + v1_rt::concat(qualified, "(".to_string()), inner_pat, ), ")".to_string(), @@ -11671,32 +11609,23 @@ pub fn emit_variant_pattern_rc_aware( { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), + v1_rt::rc_list_push(path_prefix, name.clone()), + fb_name, )); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - bind_name.clone(), + v1_rt::concat(qualified, " { ref ".to_string()), + bind_name, ), ", .. }".to_string(), ) } } else { - if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { + if field_needs_rc_ref(fb_name.clone(), rc_analysis) { v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ref ".to_string(), - ), - emit_ident(fb_name.clone(), RenderTarget::Rust), + v1_rt::concat(qualified, " { ref ".to_string()), + emit_ident(fb_name, RenderTarget::Rust), ), ", .. }".to_string(), ) @@ -11710,15 +11639,12 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let pat_str = emit_pattern_rc_aware( - fb_pat.clone(), + fb_pat, v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), + v1_rt::rc_list_push(path_prefix, name.clone()), fb_name.clone(), ), - inner_analysis.clone(), + inner_analysis, shared_types.clone(), "".to_string(), source_indices.clone(), @@ -11726,19 +11652,13 @@ pub fn emit_variant_pattern_rc_aware( ); v1_rt::concat( v1_rt::concat( - v1_rt::concat( - qualified.clone(), - " { ".to_string(), - ), + v1_rt::concat(qualified, " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), + emit_ident(fb_name, RenderTarget::Rust), ": ".to_string(), ), - pat_str.clone(), + pat_str, ), ), ", .. }".to_string(), @@ -11749,12 +11669,12 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified.clone(), + None => qualified, } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent.clone() { + let shape_key = match resolved_parent { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11768,20 +11688,19 @@ pub fn emit_variant_pattern_rc_aware( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = (v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - shape_key.clone(), - ) || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = + (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) + || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11801,7 +11720,7 @@ pub fn emit_variant_pattern_rc_aware( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent.clone() { + let shape_key2 = match resolved_parent { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11817,18 +11736,18 @@ pub fn emit_variant_pattern_rc_aware( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2.clone(), + shape_key2, ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified.clone(), "(_)".to_string()) + v1_rt::concat(qualified, "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified.clone(), " { .. }".to_string()) + v1_rt::concat(qualified, " { .. }".to_string()) } else { - qualified.clone() + qualified } } } @@ -11836,7 +11755,7 @@ pub fn emit_variant_pattern_rc_aware( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.clone().iter().cloned() { + for fb in effective_bindings.iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11959,7 +11878,7 @@ pub fn emit_variant_pattern_rc_aware( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified.clone(), " { ".to_string()), + v1_rt::concat(qualified, " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -12000,8 +11919,8 @@ pub fn rc_pattern_preludes( source_indices.clone(), ); rc_pattern_preludes( - fb_pat.clone(), - inner_analysis.clone(), + fb_pat, + inner_analysis, shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -12119,7 +12038,7 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if (((*inferred_node.type_annotation).clone() != None) && has_structure) { + let n = if ((inferred_node.type_annotation.clone() != None) && has_structure) { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -12129,34 +12048,34 @@ pub fn explicit_record_struct_name( }; let is_product = is_product_type(n.clone()); let is_coproduct = is_coproduct_type(n.clone()); - let n_is_error = if ((*n.inferred).clone() != None) { - is_compiler_error((*n.inferred).clone().clone().unwrap()) + let n_is_error = if (n.inferred.clone() != None) { + is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; let nname = authored_name_at(source_indices, n.clone()); if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { - type_name.clone() + type_name } else { if n_is_error { - type_name.clone() + type_name } else { if is_product { if (n.ident_span.clone() == None) { - type_name.clone() + type_name } else { - Some(nname.clone()) + Some(nname) } } else { if is_coproduct { - type_name.clone() + type_name } else { if (((n.children.clone().len() as i64) == 0) && (n.ident_span.clone() != None)) { - Some(nname.clone()) + Some(nname) } else { - type_name.clone() + type_name } } } @@ -12240,7 +12159,7 @@ pub fn effective_variant_parent( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { variant_parent_from_binding_kind(binding_kind) } @@ -12425,15 +12344,15 @@ pub fn emit_typed_expr_base( emit_keyword("null".to_string(), RenderTarget::Rust) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n.clone(), RenderTarget::Rust) + emit_keyword(n, RenderTarget::Rust) } else { { let variant_parent = effective_variant_parent( n.clone(), binding_kind.clone(), - (*texpr.inferred).clone(), + texpr.inferred.clone(), emit_info.clone(), - si.clone(), + si, ); match variant_parent { Some(enum_name) => { @@ -12447,7 +12366,7 @@ pub fn emit_typed_expr_base( let qualified = if (is_optional_variant_name(n.clone()) && (enum_name.clone() == "Optional".to_string())) { - if (n.clone() == "Present".to_string()) { + if (n == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -12458,7 +12377,7 @@ pub fn emit_typed_expr_base( enum_name.clone(), "::".to_string(), ), - n.clone(), + n, ) }; if v1_rt::set_contains(&shared_types, enum_name.clone()) @@ -12480,12 +12399,12 @@ pub fn emit_typed_expr_base( Some(info) => { let is_data = (info.kind.clone() == ItemKind::DataItem); if is_data { - v1_rt::concat(to_snake(n.clone()), "()".to_string()) + v1_rt::concat(to_snake(n), "()".to_string()) } else { - emit_ident(n.clone(), RenderTarget::Rust) + emit_ident(n, RenderTarget::Rust) } } - None => emit_ident(n.clone(), RenderTarget::Rust), + None => emit_ident(n, RenderTarget::Rust), }, } } @@ -12515,7 +12434,7 @@ pub fn field_access_field_is_boxed( { let base_struct = expand_type_for_field_access( resolved_type(base), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); match find_child_named( @@ -12543,15 +12462,12 @@ pub fn field_access_field_is_boxed( || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); ((faithful_nat_field || needs_box_wrapping( - field_ty.clone(), + field_ty, emit_info.recursive_type_set.clone(), shared_types, (*scope.type_env).clone().source_indices.clone(), )) - || is_recursive_type_by_name( - (*scope.type_env).clone(), - field_ty_name.clone(), - )) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name)) } } } @@ -12579,7 +12495,7 @@ pub fn emit_typed_field_access( shared_types.clone(), emit_info.clone(), ); - let base_is_anon_record = match (*base.inferred).clone().as_deref().cloned() { + let base_is_anon_record = match base.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: bt, .. }) => { let is_product = is_product_type(bt.clone()); if (is_product && (bt.ident_span.clone() == None)) { @@ -12759,13 +12675,13 @@ pub fn type_needs_rc_seen( mut source_indices: Rc>>, ) -> bool { loop { - let normed = normalize_access_type_node(type_node); + let normed = normalize_access_type_node(type_node.clone()); let is_product = is_product_type(normed.clone()); let is_coproduct = is_coproduct_type(normed.clone()); - if is_product { + if is_product.clone() { break true; } else { - if is_coproduct { + if is_coproduct.clone() { break { let mut __found = false; for child in normed.children.clone().iter().cloned() { @@ -12778,7 +12694,7 @@ pub fn type_needs_rc_seen( }; } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); - if ((*normed.inferred).clone() != None) { + if (normed.inferred.clone() != None) { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { @@ -12786,7 +12702,7 @@ pub fn type_needs_rc_seen( }; { let __tco_0 = resolved_type(normed.clone()); - let __tco_1 = next_seen; + let __tco_1 = next_seen.clone(); type_node = __tco_0; seen = __tco_1; continue; @@ -12803,12 +12719,13 @@ pub fn type_needs_rc_seen( v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; let has_structure = (normed.connective.clone() != Connective::NoConnective); - if (!has_structure && ((normed.children.clone().len() as i64) == 0)) { + if (!has_structure.clone() && ((normed.children.clone().len() as i64) == 0)) + { break false; } else { { let __tco_0 = normed.clone(); - let __tco_1 = next_seen; + let __tco_1 = next_seen.clone(); type_node = __tco_0; seen = __tco_1; continue; @@ -12828,7 +12745,7 @@ pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> bool pub fn rust_runtime_bridge_name(function_name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), function_name.clone()) { Some(runtime_name) => runtime_name.clone(), - None => function_name.clone(), + None => function_name, } } @@ -12849,7 +12766,7 @@ pub fn rust_empty_map_value_type_str( if (rendered.clone() == "".to_string()) { "".to_string() } else { - rendered.clone() + rendered } } None => "".to_string(), @@ -12879,10 +12796,7 @@ pub fn rust_empty_map_kv_type_str( source_indices.clone(), ); if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { - v1_rt::concat( - v1_rt::concat(key_str.clone(), ", ".to_string()), - val_str.clone(), - ) + v1_rt::concat(v1_rt::concat(key_str, ", ".to_string()), val_str) } else { "".to_string() } @@ -12892,8 +12806,8 @@ pub fn rust_empty_map_kv_type_str( pub fn type_node_child_is_type_variable(c: Rc) -> bool { { let ch = child_type_node(c); - if ((*ch.inferred).clone() != None) { - is_type_variable((*ch.inferred).clone().clone().unwrap()) + if (ch.inferred.clone() != None) { + is_type_variable(ch.inferred.clone().clone().unwrap()) } else { false } @@ -12911,7 +12825,7 @@ pub fn rust_btree_set_element_ord_eligible( || (elem_name.clone() == "Bool".to_string())) || (elem_name.clone() == "Unit".to_string())) || (elem_name.clone() == "Secret".to_string())) - || (elem_name.clone() == "Bytes".to_string())) + || (elem_name == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12924,13 +12838,13 @@ pub fn rust_empty_set_element_type_str( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; - let elem_is_error = if ((*elem_node.inferred).clone() != None) { - is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_error = if (elem_node.inferred.clone() != None) { + is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -12941,7 +12855,7 @@ pub fn rust_empty_set_element_type_str( "".to_string() } else { render_node_type( - elem_node.clone(), + elem_node, RenderTarget::Rust, shared_types, source_indices.clone(), @@ -12961,8 +12875,8 @@ pub fn emit_rust_empty_set_expr( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -12971,7 +12885,7 @@ pub fn emit_rust_empty_set_expr( } else { if !rust_btree_set_element_ord_eligible(elem_node.clone(), source_indices.clone()) { { - let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); + let elem_name = authored_name_at(source_indices.clone(), elem_node); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("empty_set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -12986,10 +12900,7 @@ pub fn emit_rust_empty_set_expr( ); if (elem_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat( - "v1_rt::rc_empty_set::<".to_string(), - elem_str.clone(), - ), + v1_rt::concat("v1_rt::rc_empty_set::<".to_string(), elem_str), ">()".to_string(), ) } else { @@ -13056,7 +12967,7 @@ pub fn emit_rust_expr_var( emit_var_ref( n, binding_kind.clone(), - (*expr.inferred).clone(), + expr.inferred.clone(), expr.span.clone().start.clone(), shared_types, registry, @@ -13145,7 +13056,7 @@ pub fn emit_rust_expr_call( emit_typed_call_expr( f, expr.children.clone(), - (*expr.inferred).clone(), + expr.inferred.clone(), registry, scope.clone(), depth, @@ -13184,7 +13095,7 @@ pub fn emit_rust_expr_method_call( r, m, a, - (*expr.inferred).clone(), + expr.inferred.clone(), method_semantics.clone(), registry, scope.clone(), @@ -13299,7 +13210,7 @@ pub fn emit_rust_expr_record_lit( let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ); let variant_name = match tn.clone() { @@ -13315,13 +13226,13 @@ pub fn emit_rust_expr_record_lit( if ((concrete.clone() != "".to_string()) && (concrete.clone() != variant_name.clone())) { - Some(concrete.clone()) + Some(concrete) } else { - tn.clone() + tn } } } else { - tn.clone() + tn }; let raw = emit_typed_record_lit( peeled_type_name, @@ -13345,21 +13256,20 @@ pub fn emit_rust_expr_record_lit( ) { Some(p) => p.clone(), None => { - let expanded_name = authored_name_at(si.clone(), expanded_rt.clone()); + let expanded_name = authored_name_at(si, expanded_rt.clone()); if ((((expanded_rt.ident_span.clone() != None) && (expanded_name.clone() != "".to_string())) && (expanded_name.clone() != variant_name.clone())) && v1_rt::set_contains(&shared_types, expanded_name.clone())) { - expanded_name.clone() + expanded_name } else { - variant_name.clone() + variant_name } } }, }; - if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name.clone())) + if ((rc_name.clone() != "".to_string()) && v1_rt::set_contains(&shared_types, rc_name)) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -13802,7 +13712,7 @@ pub fn contextual_variant_parent( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { None } @@ -13814,7 +13724,7 @@ pub fn is_map_typed_expr( texpr: Rc, source_indices: Rc>>, ) -> bool { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: n, .. }) => { node_is_keyed_collection(n.clone(), source_indices) } @@ -13841,11 +13751,8 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name( - arg.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); - match lookup_type_by_name((*scope.type_env).clone(), ty_name.clone()) { + let ty_name = resolved_type_name(arg, (*scope.type_env).clone().source_indices.clone()); + match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { { @@ -13911,7 +13818,7 @@ pub fn emit_discriminant_call_lowering( } __result }); - let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name.clone()) { + let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name) { v1_rt::concat( v1_rt::concat("&*(".to_string(), scrutinee), ")".to_string(), @@ -13935,19 +13842,13 @@ pub fn emit_discriminant_call_lowering( } } else { emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( - v1_rt::concat("\"".to_string(), ty_name.clone()), - "\"".to_string(), - ), + v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), emit_info.corpus_repr.clone(), ) } } None => emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( - v1_rt::concat("\"".to_string(), ty_name.clone()), - "\"".to_string(), - ), + v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), emit_info.corpus_repr.clone(), ), } @@ -13976,10 +13877,7 @@ pub fn emit_typed_call_expr( ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat( - "v1_rt::rc_empty_map::<".to_string(), - kv_type_str.clone(), - ), + v1_rt::concat("v1_rt::rc_empty_map::<".to_string(), kv_type_str), ">()".to_string(), ) } else { @@ -14067,7 +13965,7 @@ pub fn emit_typed_call( { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); - let get_idx = get_args.clone().get(1 as usize).cloned(); + let get_idx = get_args.get(1 as usize).cloned(); let get_result = match get_list { Some(list_arg) => match get_idx { Some(idx_arg) => { @@ -14117,8 +14015,7 @@ pub fn emit_typed_call( if ((with_args.clone().len() as i64) < 2) { return "compile_error!(\"with call missing update record\")".to_string(); } - let update_arg = - arg_value(with_args.clone().get(1 as usize).cloned().clone().unwrap()); + let update_arg = arg_value(with_args.get(1 as usize).cloned().clone().unwrap()); let base_str = emit_typed_expr( base_arg.clone(), registry.clone(), @@ -14128,10 +14025,10 @@ pub fn emit_typed_call( emit_info.clone(), 1024, ); - let type_name = if ((*base_arg.inferred).clone() != None) { + let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( (*scope.type_env).clone().source_indices.clone(), - resolved_type(base_arg.clone()), + resolved_type(base_arg), ) } else { "compile_error!(\"with call missing resolved record type\")".to_string() @@ -14165,7 +14062,7 @@ pub fn emit_typed_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg.clone(), + update_arg, registry.clone(), scope.clone(), depth.clone(), @@ -14185,17 +14082,14 @@ pub fn emit_typed_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(type_name.clone(), " { ".to_string()), - fields_str, - ), + v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc.clone() { + if needs_rc { return v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string(), @@ -14427,7 +14321,7 @@ pub fn emit_typed_call( } else { { let mut __found = false; - for a in filled_args.clone().iter().cloned() { + for a in filled_args.iter().cloned() { if expr_references_var(arg_value(a.clone()), func.clone(), si.clone()) { __found = true; break; @@ -14449,21 +14343,21 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt.clone() && (func.clone() == "concat".to_string())) + let call_str = if ((is_rt && (func.clone() == "concat".to_string())) && ((all_args.clone().len() as i64) > 2)) { - emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) + emit_nested_rt_concat(all_args, "".to_string(), shared_types.clone()) } else { v1_rt::concat( v1_rt::concat(v1_rt::concat(func_name, "(".to_string()), args_str), ")".to_string(), ) }; - match callee.clone() { + match callee { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects.clone() { + if has_effects { v1_rt::concat(call_str, ".await?".to_string()) } else { call_str @@ -14646,7 +14540,7 @@ pub fn emit_nested_rt_concat( .skip(1 as usize) .collect::>(), ); - let __tco_1 = next_acc; + let __tco_1 = next_acc.clone(); remaining = __tco_0; acc = __tco_1; continue; @@ -14700,7 +14594,7 @@ pub fn emit_typed_for_each( let ind2 = make_indent((depth.clone() + 2)); let ind0 = make_indent(depth.clone()); let iter_str = apply_type_template1(sharing.iter_owned.clone(), coll_str); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1.clone()), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) } } @@ -14738,10 +14632,7 @@ pub fn emit_typed_index( base_node.clone(), (*scope.type_env).clone().source_indices.clone(), ); - if is_rust_string_like( - base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { apply_type_template2( spec.indexing.clone().string_index.clone(), base_str, @@ -14834,13 +14725,13 @@ pub fn collection_element_type( match rt.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); - let elem_is_error = if ((*elem_node.inferred).clone() != None) { - is_compiler_error((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_error = if (elem_node.inferred.clone() != None) { + is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { false }; - let elem_is_type_var = if ((*elem_node.inferred).clone() != None) { - is_type_variable((*elem_node.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; @@ -14848,7 +14739,7 @@ pub fn collection_element_type( "_".to_string() } else { render_rust_type( - elem_node.clone(), + elem_node, shared_types, corpus_repr, source_indices.clone(), @@ -14880,11 +14771,11 @@ pub fn lambda_scope_from_children( ) .iter() .cloned() - .fold(scope.clone(), |acc: Rc, pair: (i64, String)| { + .fold(scope, |acc: Rc, pair: (i64, String)| { let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { + Some(pn) => match pn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: resolved_type, .. @@ -14927,17 +14818,17 @@ pub fn lambda_param_type_strs( let idx = pair.0.clone(); let param_name = pair.1.clone(); let inferred_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { - Some(pn) => match (*pn.inferred).clone().as_deref().cloned() { + Some(pn) => match pn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: param_type, .. }) => { - let param_is_error = if ((*param_type.inferred).clone() != None) { - is_compiler_error((*param_type.inferred).clone().clone().unwrap()) + let param_is_error = if (param_type.inferred.clone() != None) { + is_compiler_error(param_type.inferred.clone().clone().unwrap()) } else { false }; - let param_is_type_var = if ((*param_type.inferred).clone() != None) { - is_type_variable((*param_type.inferred).clone().clone().unwrap()) + let param_is_type_var = if (param_type.inferred.clone() != None) { + is_type_variable(param_type.inferred.clone().clone().unwrap()) } else { false }; @@ -15015,7 +14906,7 @@ pub fn emit_typed_collection_lambda( (*scope.type_env).clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); - let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); + let lambda_scope = lambda_scope_from_children(scope.clone(), ps, pn); let body_str = emit_typed_expr( bd, registry, @@ -15116,7 +15007,7 @@ pub fn emit_typed_fold_lambda( emit_info.clone(), 1024, ); - let acc_name = match ps.clone().first().cloned() { + let acc_name = match ps.first().cloned() { Some(n) => n.clone(), None => "".to_string(), }; @@ -15136,7 +15027,7 @@ pub fn emit_typed_fold_lambda( ), ":".to_string(), ), - acc_name.clone(), + acc_name, ); v1_rt::concat( v1_rt::concat( @@ -15154,7 +15045,7 @@ pub fn emit_typed_fold_lambda( ), " = v1_rt::take_owned_counted(".to_string(), ), - acc_ident.clone(), + acc_ident, ), ", \"".to_string(), ), @@ -15209,7 +15100,7 @@ pub fn emit_rust_fold_method_call( 1024, ); let elem_type_str = collection_element_type( - (*receiver.inferred).clone(), + receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15270,7 +15161,7 @@ pub fn emit_rust_fold_method_call( (*scope.type_env).clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) - || acc_children_have_unit.clone())); + || acc_children_have_unit)); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15296,7 +15187,7 @@ pub fn emit_rust_fold_method_call( Some(concrete_type) => concrete_type.clone(), None => match args.clone().first().cloned() { Some(init_arg) => { - if ((*arg_value(init_arg.clone()).inferred).clone() != None) { + if (arg_value(init_arg.clone()).inferred.clone() != None) { resolved_type(arg_value(init_arg.clone())) } else { type_variable_node("fold_accum".to_string()) @@ -15342,7 +15233,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node.clone(), + fold_lambda_node, (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15377,7 +15268,7 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node.clone(), + fold_lambda_node, (*scope.type_env).clone().source_indices.clone(), ); match ps.first().cloned() { @@ -15417,8 +15308,8 @@ pub fn emit_rust_fold_method_call( emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), ); - let acc_type_is_type_var = if ((*acc_type_node.inferred).clone() != None) { - is_type_variable((*acc_type_node.inferred).clone().clone().unwrap()) + let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { + is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) } else { false }; @@ -15433,7 +15324,7 @@ pub fn emit_rust_fold_method_call( __found }; let is_bare_container = (((acc_type_node.children.clone().len() as i64) == 0) - && is_container_type(acc_type_name.clone())); + && is_container_type(acc_type_name)); let lambda_acc_type_str = if ((is_bare_container || acc_type_is_type_var) || acc_child_is_type_var) { "_".to_string() @@ -15482,7 +15373,7 @@ pub fn emit_rust_fold_method_call( { { let kv_type_str = rust_empty_map_kv_type_str( - acc_type_node.clone(), + acc_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15491,7 +15382,7 @@ pub fn emit_rust_fold_method_call( v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), - kv_type_str.clone(), + kv_type_str, ), ">()".to_string(), ) @@ -15505,16 +15396,16 @@ pub fn emit_rust_fold_method_call( } else { if ((((init_func.clone() == "empty_set".to_string()) && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) - && !acc_has_unit_child.clone()) + && (acc_type_str != "".to_string())) + && !acc_has_unit_child) { emit_rust_empty_set_expr( - acc_type_node.clone(), + acc_type_node, shared_types.clone(), (*scope.type_env).clone().source_indices.clone(), ) } else { - if (init_func.clone() == "empty_set".to_string()) { + if (init_func == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -15552,7 +15443,7 @@ pub fn emit_rust_fold_method_call( scope.clone(), depth.clone(), shared_types.clone(), - fold_emit_info.clone(), + fold_emit_info, ), None => "compile_error!(\"missing fold function argument\")".to_string(), }; @@ -15627,21 +15518,21 @@ pub fn emit_rust_sort_by_method_call( emit_info.clone(), 1024, ); - let elem_type_str = match (*receiver.inferred).clone().as_deref().cloned() { + let elem_type_str = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, (*scope.type_env).clone().source_indices.clone(), ); - let elem_is_type_var = if ((*elem.inferred).clone() != None) { - is_type_variable((*elem.inferred).clone().clone().unwrap()) + let elem_is_type_var = if (elem.inferred.clone() != None) { + is_type_variable(elem.inferred.clone().clone().unwrap()) } else { false }; if ((elem.ident_span.clone() != None) && !elem_is_type_var) { render_rust_type( - elem.clone(), + elem, shared_types.clone(), emit_info.corpus_repr.clone(), (*scope.type_env).clone().source_indices.clone(), @@ -15671,7 +15562,7 @@ pub fn emit_rust_sort_by_method_call( if (elem_type_str.clone() == "_".to_string()) { v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a, b| { a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str.clone()), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn.clone()), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } } } @@ -15703,7 +15594,7 @@ pub fn emit_rust_map_method_call( shared_types.clone(), emit_info.clone(), ); - let recv_is_optional = match (*receiver.inferred).clone().as_deref().cloned() { + let recv_is_optional = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -15728,7 +15619,7 @@ pub fn emit_rust_map_method_call( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( arg_value(a.clone()) .children @@ -15793,7 +15684,7 @@ pub fn emit_rust_map_method_call( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( arg_value(a.clone()) .children @@ -15891,7 +15782,7 @@ pub fn emit_rust_higher_order_method( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps.clone(), + ps, Rc::new( arg_value(a.clone()) .children @@ -15923,7 +15814,7 @@ pub fn emit_rust_higher_order_method( v1_rt::rc_map_insert( seed_bindings("param".to_string(), p), "body".to_string(), - body_str.clone(), + body_str, ), "iter".to_string(), iter_str, @@ -16000,7 +15891,7 @@ pub fn emit_rust_get_method_call( ), None => "compile_error!(\"get method missing index\")".to_string(), }; - let receiver_resolved = match (*receiver.inferred).clone().as_deref().cloned() { + let receiver_resolved = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => true, _ => false, }; @@ -16053,10 +15944,10 @@ pub fn emit_rust_with_method_call( emit_info.clone(), 1024, ); - let type_name = match (*receiver.inferred).clone().as_deref().cloned() { + let type_name = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let rt_is_error = if ((*rt.inferred).clone() != None) { - is_compiler_error((*rt.inferred).clone().clone().unwrap()) + let rt_is_error = if (rt.inferred.clone() != None) { + is_compiler_error(rt.inferred.clone().clone().unwrap()) } else { false }; @@ -16101,7 +15992,7 @@ pub fn emit_rust_with_method_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg.clone(), + update_arg, registry.clone(), scope.clone(), depth.clone(), @@ -16121,17 +16012,14 @@ pub fn emit_rust_with_method_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(type_name.clone(), " { ".to_string()), - fields_str, - ), + v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc.clone() { + if needs_rc { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16261,7 +16149,7 @@ pub fn emit_rust_generic_method_call( v1_rt::concat("(".to_string(), recv_str), ".".to_string(), ), - emit_ident(function_name.clone(), RenderTarget::Rust), + emit_ident(function_name, RenderTarget::Rust), ), ")(".to_string(), ), @@ -16324,7 +16212,7 @@ pub fn emit_rust_generic_method_call( ), ")".to_string(), ); - if rust_runtime_bridge_wraps_collection_result_in_rc(function_name.clone()) { + if rust_runtime_bridge_wraps_collection_result_in_rc(function_name) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), lowered), ")".to_string(), @@ -16500,7 +16388,7 @@ pub fn emit_typed_method_call( "count".to_string() } } else { - method_name_raw.clone() + method_name_raw }; if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( @@ -16693,7 +16581,7 @@ pub fn emit_typed_method_call( tmpl.clone(), bindings, ); - if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { + if rust_runtime_bridge_wraps_collection_result_in_rc(method_name) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16701,7 +16589,7 @@ pub fn emit_typed_method_call( } None => { emit_rust_generic_method_call( - method_name.clone(), + method_name, receiver.clone(), args.clone(), result_type, @@ -16924,7 +16812,7 @@ pub fn arms_are_freemonoid_coproduct( }; let is_fm = (empty_is_fm || cons_is_fm); let empty_fillable = (has_empty || has_catchall.clone()); - let cons_fillable = (has_cons || has_catchall.clone()); + let cons_fillable = (has_cons || has_catchall); ((is_fm && empty_fillable) && cons_fillable) } } @@ -16955,7 +16843,7 @@ pub fn freemonoid_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; @@ -16995,7 +16883,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind.clone()), + v1_rt::concat("let ".to_string(), head_bind), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -17003,7 +16891,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind.clone()), + v1_rt::concat("let ".to_string(), tail_bind), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; @@ -17027,7 +16915,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; @@ -17074,7 +16962,7 @@ pub fn emit_native_freemonoid_match( ); let nonempty_body = freemonoid_nonempty_branch_body( cons_arm, - catchall.clone(), + catchall, si, registry.clone(), scope.clone(), @@ -17093,11 +16981,11 @@ pub fn emit_native_freemonoid_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body.clone(), + empty_body, ), " } else { ".to_string(), ), - nonempty_body.clone(), + nonempty_body, ), " } }".to_string(), ) @@ -17124,7 +17012,7 @@ pub fn emit_typed_match( emit_info.clone(), 1024, ); - let scrut_type = match (*scrutinee.inferred).clone().as_deref().cloned() { + let scrut_type = match scrutinee.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -17157,7 +17045,7 @@ pub fn emit_typed_match( "".to_string() }; if (native_fm.clone() != "".to_string()) { - return native_fm.clone(); + return native_fm; } let rc_match = analyze_rc_match( scrutinee.clone(), @@ -17198,7 +17086,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -17218,10 +17106,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( "match ".to_string(), - apply_type_template1( - sharing.deref_clone.clone(), - scrut_str.clone(), - ), + apply_type_template1(sharing.deref_clone.clone(), scrut_str), ), " {\n".to_string(), ), @@ -17235,7 +17120,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_str() {\n".to_string(), ), arms_str, @@ -17266,7 +17151,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), sf_arms_str, @@ -17278,7 +17163,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), arms_str, @@ -17377,17 +17262,17 @@ pub fn emit_typed_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), + v1_rt::concat(" if ".to_string(), field_guards), " && ".to_string(), ), - arm_guard_str.clone(), + arm_guard_str, ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat(" if ".to_string(), field_guards) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + v1_rt::concat(" if ".to_string(), arm_guard_str) } else { "".to_string() } @@ -17414,7 +17299,7 @@ pub fn emit_typed_match_arm( ) } else { emit_typed_expr( - arm_b.clone(), + arm_b, registry.clone(), scope.clone(), depth.clone(), @@ -17425,7 +17310,7 @@ pub fn emit_typed_match_arm( } } _ => emit_typed_expr( - arm_b.clone(), + arm_b, registry.clone(), scope.clone(), depth.clone(), @@ -17437,10 +17322,10 @@ pub fn emit_typed_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat.clone(), - rc_analysis.clone(), + arm_pat, + rc_analysis, shared_types.clone(), - si.clone(), + si, emit_info.clone(), ); v1_rt::concat( @@ -17585,7 +17470,7 @@ pub fn rust_struct_field_type_node( struct_name: String, field_name: String, ) -> Option> { - match lookup_type_by_name((*scope.type_env).clone(), struct_name) { + match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( struct_node.clone(), field_name, @@ -17686,7 +17571,7 @@ pub fn is_already_optional( let si = (*scope.type_env).clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); - let f = field_access_field_at(texpr.clone(), si.clone()); + let f = field_access_field_at(texpr.clone(), si); match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, @@ -17705,11 +17590,11 @@ pub fn is_already_optional( if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } - _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { + _ => match v1_rt::map_get(&scope.locals.clone(), n) { Some(binding) => { ((*binding.resolved).clone().return_cardinality.clone() == Cardinality::CardOptional) @@ -17746,7 +17631,7 @@ pub fn is_already_optional( if summary_says_optional { true } else { - match (*b.inferred).clone().as_deref().cloned() { + match b.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: base_type, .. }) => { @@ -17761,7 +17646,7 @@ pub fn is_already_optional( ) { true } else { - match (*texpr.inferred).clone().as_deref().cloned() { + match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17769,7 +17654,7 @@ pub fn is_already_optional( } } } - _ => match (*texpr.inferred).clone().as_deref().cloned() { + _ => match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17778,7 +17663,7 @@ pub fn is_already_optional( } } } - _ => match (*texpr.inferred).clone().as_deref().cloned() { + _ => match texpr.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -17801,11 +17686,11 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if ((*field_child.inferred).clone() != None) { + if (field_child.inferred.clone() != None) { { let field_type = resolved_type(field_child.clone()); - let ft_is_type_var = if ((*field_type.inferred).clone() != None) { - is_type_variable((*field_type.inferred).clone().clone().unwrap()) + let ft_is_type_var = if (field_type.inferred.clone() != None) { + is_type_variable(field_type.inferred.clone().clone().unwrap()) } else { false }; @@ -17822,7 +17707,7 @@ pub fn lookup_struct_field_type_name( None => None, }; match direct.clone() { - Some(_) => direct.clone(), + Some(_) => direct, None => match variant_name { Some(vn) => { match find_child_named(struct_node.clone(), vn.clone(), source_indices.clone()) @@ -17833,23 +17718,23 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if ((*field_child.inferred).clone() != None) { + if (field_child.inferred.clone() != None) { { let field_type = resolved_type(field_child.clone()); let ft_is_type_var = - if ((*field_type.inferred).clone() != None) { + if (field_type.inferred.clone() != None) { is_type_variable( - (*field_type.inferred).clone().clone().unwrap(), + field_type.inferred.clone().clone().unwrap(), ) } else { false }; if ((field_type.ident_span.clone() != None) - && !ft_is_type_var.clone()) + && !ft_is_type_var) { Some(authored_name_at( source_indices.clone(), - field_type.clone(), + field_type, )) } else { None @@ -17899,7 +17784,7 @@ pub fn emit_field_value_with_context( (*scope.type_env).clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { - Some(_) => node_lookup.clone(), + Some(_) => node_lookup, None => { if (struct_node.ident_span.clone() != None) { match lookup_emit_type_summary( @@ -17935,7 +17820,7 @@ pub fn emit_field_value_with_context( None => pe.clone(), }; let raw = emit_typed_record_lit( - tn.clone(), + tn, inner_fields, corrected_parent.clone(), resolved_type(field_value.clone()), @@ -17945,12 +17830,12 @@ pub fn emit_field_value_with_context( shared_types.clone(), emit_info.clone(), ); - let rc_name = match corrected_parent.clone() { + let rc_name = match corrected_parent { Some(en) => en.clone(), None => variant_name.clone(), }; if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name.clone())) + && v1_rt::set_contains(&shared_types, rc_name)) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -18031,7 +17916,7 @@ pub fn find_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) <= 1) { - match candidates.clone().first().cloned() { + match candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -18066,13 +17951,13 @@ pub fn find_struct_name_by_fields( __result }); if ((typed_candidates.clone().len() as i64) == 1) { - match typed_candidates.clone().first().cloned() { + match typed_candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } } else { match Rc::new({ - let mut __sorted: Vec<_> = candidates.clone().iter().cloned().collect(); + let mut __sorted: Vec<_> = candidates.iter().cloned().collect(); __sorted.sort_by(|a: &Rc, b: &Rc| { let __ka = (|c: Rc| c.name.clone())(a.clone()); let __kb = (|c: Rc| c.name.clone())(b.clone()); @@ -18099,7 +17984,7 @@ pub fn find_unique_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) == 1) { - match candidates.clone().first().cloned() { + match candidates.first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -18201,7 +18086,7 @@ pub fn emit_typed_record_lit( " {\n ".to_string(), ), emit_ident( - fname0.clone(), + fname0, RenderTarget::Rust, ), ), @@ -18255,7 +18140,7 @@ pub fn emit_typed_record_lit( (*scope.type_env).clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); - match (*fval.inferred).clone().as_deref().cloned() { + match fval.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => v1_rt::rc_map_insert( @@ -18375,7 +18260,7 @@ pub fn emit_typed_record_lit( { let resolved_struct = (*resolve_node( resolved_type.clone(), - (*scope.type_env).clone(), + scope.type_env.clone(), scope.module_name.clone(), ) .resolved) @@ -18419,8 +18304,8 @@ pub fn emit_typed_record_lit( let effective_parent = match context_lookup { Some(context_parent) => Some(context_parent.clone()), None => { - let rt_is_type_var = if ((*resolved_type.inferred).clone() != None) { - is_type_variable((*resolved_type.inferred).clone().clone().unwrap()) + let rt_is_type_var = if (resolved_type.inferred.clone() != None) { + is_type_variable(resolved_type.inferred.clone().clone().unwrap()) } else { false }; @@ -18435,7 +18320,7 @@ pub fn emit_typed_record_lit( rt_name.clone(), )) { - Some(rt_name.clone()) + Some(rt_name) } else { parent_enum.clone() } @@ -18538,7 +18423,7 @@ pub fn emit_typed_record_lit( None => ctor_name.clone(), } }; - if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) + if ((optional_variant && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -18563,7 +18448,7 @@ pub fn emit_typed_record_lit( if ((fields.clone().len() as i64) == 0) { { let host_freemonoid_carrier = - authored_name_at(si.clone(), resolved_type.clone()); + authored_name_at(si, resolved_type.clone()); match rust_seed_host_freemonoid_empty( host_freemonoid_carrier, emit_info.corpus_repr.clone(), @@ -18574,7 +18459,7 @@ pub fn emit_typed_record_lit( } } else { { - let variant_summary_name = match effective_parent.clone() { + let variant_summary_name = match effective_parent { Some(parent) => variant_summary_key(parent.clone(), tn.clone()), None => ctor_name.clone(), }; @@ -18603,25 +18488,25 @@ pub fn emit_typed_record_lit( ); let needs_wrap = (is_optional_struct_field( emit_info.clone(), - variant_summary_name.clone(), + variant_summary_name, "0".to_string(), ) && (is_already_optional( - f_value.clone(), + f_value, emit_info.clone(), scope.clone(), ) == false)); - let field_val = if needs_wrap.clone() { + let field_val = if needs_wrap { v1_rt::concat( - v1_rt::concat("Some(".to_string(), val_str.clone()), + v1_rt::concat("Some(".to_string(), val_str), ")".to_string(), ) } else { - val_str.clone() + val_str }; v1_rt::concat( v1_rt::concat( v1_rt::concat(display_tn, "(".to_string()), - field_val.clone(), + field_val, ), ")".to_string(), ) @@ -18772,7 +18657,7 @@ pub fn emit_typed_record_lit( if all_defaultable { Rc::new({ let mut __result = Vec::new(); - for fname in missing.clone().iter().cloned() { + for fname in missing.iter().cloned() { __result.extend((*if is_optional_struct_field(emit_info.clone(), variant_summary_name.clone(), fname.clone()) { Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { @@ -18794,7 +18679,7 @@ pub fn emit_typed_record_lit( None => Rc::new(vec![]), }; let phantom_strs = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), ctor_name.clone(), ) { Some(struct_decl) => { @@ -18814,7 +18699,7 @@ pub fn emit_typed_record_lit( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - si.clone(), + si, ); let has_unused = ((unused.len() as i64) > 0); if (is_struct && has_unused) { @@ -18844,7 +18729,7 @@ pub fn emit_typed_record_lit( "\n}".to_string(), ); if (ctor_alias_resolved - && v1_rt::set_contains(&shared_types, ctor_name.clone())) + && v1_rt::set_contains(&shared_types, ctor_name)) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), @@ -18932,7 +18817,7 @@ pub fn emit_typed_bin_op( let r_optional = is_optional_typed_expr(right.clone()); if (l_optional.clone() || r_optional.clone()) { { - let l_cmp = if l_optional.clone() { + let l_cmp = if l_optional { v1_rt::concat(l_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18946,7 +18831,7 @@ pub fn emit_typed_bin_op( ").as_deref()".to_string(), ) }; - let r_cmp = if r_optional.clone() { + let r_cmp = if r_optional { v1_rt::concat(r_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18968,7 +18853,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_cmp), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -18992,7 +18877,7 @@ pub fn emit_typed_bin_op( ), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -19024,7 +18909,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str.clone(), + op_str, ), " &".to_string(), ), @@ -19041,7 +18926,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str.clone(), + op_str, ), " ".to_string(), ), @@ -19058,7 +18943,7 @@ pub fn emit_typed_bin_op( } pub fn is_optional_typed_expr(e: Rc) -> bool { - match (*e.inferred).clone().as_deref().cloned() { + match e.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } @@ -19089,7 +18974,7 @@ pub fn is_string_typed_expr( e: Rc, source_indices: Rc>>, ) -> bool { - match (*e.inferred).clone().as_deref().cloned() { + match e.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); let inner = if is_optional { @@ -19152,7 +19037,7 @@ pub fn emit_typed_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.clone().iter().cloned() { + for p in fmt_parts.iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -19173,7 +19058,7 @@ pub fn emit_typed_string_interp( ) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); emit_rust_host_to_dag_string_via_seam( v1_rt::concat( v1_rt::concat( @@ -19270,7 +19155,7 @@ pub fn emit_tco_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -19286,7 +19171,7 @@ pub fn emit_tco_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text, + text: text.clone(), scope: scope.clone(), }); } @@ -19303,8 +19188,8 @@ pub fn emit_tco_init_block_stmts( let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; + let __tco_1 = v1_rt::rc_list_push(text, line.clone()); + let __tco_2 = next_scope.clone(); remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -19359,13 +19244,13 @@ pub fn emit_tco_init_stmt( if is_param { v1_rt::concat( v1_rt::concat( - v1_rt::concat(emit_ident(n.clone(), RenderTarget::Rust), " = ".to_string()), + v1_rt::concat(emit_ident(n, RenderTarget::Rust), " = ".to_string()), val_str, ), ";".to_string(), ) } else { - emit_let_binding(n.clone(), val_str, RenderTarget::Rust) + emit_let_binding(n, val_str, RenderTarget::Rust) } } _ => emit_typed_expr( @@ -19420,7 +19305,7 @@ pub fn emit_rust_tco_non_self_call( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices @@ -19457,9 +19342,9 @@ pub fn emit_rust_tco_if( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprIf => { - let c = if_condition((*frame.expr).clone()); - let t = if_then_branch((*frame.expr).clone()); - let e = if_else_branch((*frame.expr).clone()); + let c = if_condition(frame.expr.clone()); + let t = if_then_branch(frame.expr.clone()); + let e = if_else_branch(frame.expr.clone()); let cond_str = emit_typed_expr( c, registry.clone(), @@ -19565,7 +19450,7 @@ pub fn freemonoid_tco_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; @@ -19608,7 +19493,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind.clone()), + v1_rt::concat("let ".to_string(), head_bind), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -19616,7 +19501,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind.clone()), + v1_rt::concat("let ".to_string(), tail_bind), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; @@ -19641,7 +19526,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn.clone()), + v1_rt::concat("let ".to_string(), bn), " = __fm.clone(); ".to_string(), ) }; @@ -19693,7 +19578,7 @@ pub fn emit_native_freemonoid_tco_match( ); let nonempty_body = freemonoid_tco_nonempty_branch_body( cons_arm, - catchall.clone(), + catchall, si, fn_name.clone(), params.clone(), @@ -19714,11 +19599,11 @@ pub fn emit_native_freemonoid_tco_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body.clone(), + empty_body, ), " } else { ".to_string(), ), - nonempty_body.clone(), + nonempty_body, ), " } }".to_string(), ) @@ -19736,8 +19621,8 @@ pub fn emit_rust_tco_match( ) -> String { match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprMatch => { - let s = match_scrutinee((*frame.expr).clone()); - let arm_list = match_arm_nodes((*frame.expr).clone()); + let s = match_scrutinee(frame.expr.clone()); + let arm_list = match_arm_nodes(frame.expr.clone()); let scrut_str = emit_typed_expr( s.clone(), registry.clone(), @@ -19747,7 +19632,7 @@ pub fn emit_rust_tco_match( emit_info.clone(), 1024, ); - let tco_scrut_type = match (*s.inferred).clone().as_deref().cloned() { + let tco_scrut_type = match s.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -19791,11 +19676,11 @@ pub fn emit_rust_tco_match( "".to_string() }; if (native_tco_fm.clone() != "".to_string()) { - native_tco_fm.clone() + native_tco_fm } else { { let rc_match = analyze_rc_match( - s.clone(), + s, arm_list.clone(), tco_scrut_type.clone(), shared_types.clone(), @@ -19824,14 +19709,14 @@ pub fn emit_rust_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let tco_needs_as_str = (all_arms_are_string_lit(arm_list.clone()) - && ((arm_list.clone().len() as i64) > 0)); + && ((arm_list.len() as i64) > 0)); if rc_match.needs_option_deref.clone() { v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -19853,7 +19738,7 @@ pub fn emit_rust_tco_match( "match ".to_string(), apply_type_template1( sharing.deref_clone.clone(), - scrut_str.clone(), + scrut_str, ), ), " {\n".to_string(), @@ -19868,7 +19753,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), ".as_str() {\n".to_string(), ), arms_str, @@ -19879,7 +19764,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str.clone()), + v1_rt::concat("match ".to_string(), scrut_str), " {\n".to_string(), ), arms_str, @@ -19910,14 +19795,14 @@ pub fn emit_rust_tco_let( match (*(*frame.expr).clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( - (*frame.expr).clone(), + frame.expr.clone(), (*frame.scope.clone().type_env) .clone() .source_indices .clone(), ); - let v = let_value((*frame.expr).clone()); - let bd = let_body((*frame.expr).clone()); + let v = let_value(frame.expr.clone()); + let bd = let_body(frame.expr.clone()); let val_str = emit_typed_expr( v.clone(), registry.clone(), @@ -19969,8 +19854,8 @@ pub fn emit_rust_tco_let( }; let next_scope = extend_scope( frame.scope.clone(), - n.clone(), - resolved_type(v.clone()), + n, + resolved_type(v), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { @@ -20022,7 +19907,7 @@ pub fn emit_rust_tco_block( emit_info.clone(), params.clone(), ); - let last_str = match ss.clone().last().cloned() { + let last_str = match ss.last().cloned() { Some(last_expr) => emit_typed_tco_expr( last_expr.clone(), fn_name, @@ -20064,7 +19949,7 @@ pub fn emit_rust_tco_default_return( ) -> String { { let val_str = emit_typed_expr( - (*frame.expr).clone(), + frame.expr.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -20228,17 +20113,17 @@ pub fn emit_typed_tco_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), + v1_rt::concat(" if ".to_string(), field_guards), " && ".to_string(), ), - arm_guard_str.clone(), + arm_guard_str, ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat(" if ".to_string(), field_guards) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + v1_rt::concat(" if ".to_string(), arm_guard_str) } else { "".to_string() } @@ -20257,10 +20142,10 @@ pub fn emit_typed_tco_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat.clone(), - rc_analysis.clone(), + arm_pat, + rc_analysis, shared_types.clone(), - si.clone(), + si, emit_info.clone(), ); v1_rt::concat( @@ -20307,7 +20192,7 @@ pub fn expr_references_var( match (*node.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), + } => (expr_var_name_at(node.clone(), source_indices) == var_name), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -20447,7 +20332,7 @@ pub fn emit_typed_tco_reassign( }); let ordered_args = Rc::new({ let mut __result = Vec::new(); - for av in filtered_arg_values.clone().iter().cloned() { + for av in filtered_arg_values.iter().cloned() { __result.push(emit_typed_expr( av.clone(), registry.clone(), @@ -20462,7 +20347,7 @@ pub fn emit_typed_tco_reassign( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for p in filtered_params.clone().iter().cloned() { + for p in filtered_params.iter().cloned() { __result.push(emit_ident( param_node_name_at(p.clone(), si.clone()), RenderTarget::Rust, @@ -20509,9 +20394,9 @@ pub fn emit_service_def( env.source_indices.clone(), ); let impl_block = emit_service_impl( - safe_name.clone(), - fallback_transport.clone(), - op_children.clone(), + safe_name, + fallback_transport, + op_children, registry, shared_types, corpus_repr, @@ -20576,14 +20461,12 @@ pub fn emit_service_config_fields( } else { fs.clone() }; - let decls = service_field_decls( - fs.clone(), - language_spec(RenderTarget::Rust).service_fields.clone(), - ); + let decls = + service_field_decls(fs, language_spec(RenderTarget::Rust).service_fields.clone()); if ((decls.clone().len() as i64) == 0) { " // No configuration needed for local binding.\n".to_string() } else { - decls.clone().join(&"".to_string()) + decls.join(&"".to_string()) } } } @@ -20633,7 +20516,7 @@ pub fn emit_service_impl( v1_rt::concat("impl ".to_string(), name.clone()), " {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), methods_str, ), @@ -20684,7 +20567,7 @@ pub fn emit_service_new_method( None => "".to_string(), }; let base_url_default = if (from_config.clone() != "".to_string()) { - from_config.clone() + from_config } else { if fs.has_rest.clone() { { @@ -20709,7 +20592,7 @@ pub fn emit_service_new_method( "".to_string() }; if (from_fallback.clone() != "".to_string()) { - from_fallback.clone() + from_fallback } else { "http://localhost".to_string() } @@ -20718,10 +20601,8 @@ pub fn emit_service_new_method( "".to_string() } }; - let ctors = service_field_ctors( - fs.clone(), - language_spec(RenderTarget::Rust).service_fields.clone(), - ); + let ctors = + service_field_ctors(fs, language_spec(RenderTarget::Rust).service_fields.clone()); let ctors = Rc::new({ let mut __result = Vec::new(); for c in ctors.clone().iter().cloned() { @@ -20743,7 +20624,7 @@ pub fn emit_service_new_method( }), None => ctors.clone(), }; - let inits = ctors.clone().join(&"".to_string()); + let inits = ctors.join(&"".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -20803,10 +20684,7 @@ pub fn emit_modifier_doc_from_props( "".to_string() } else { v1_rt::concat( - v1_rt::concat( - "/// Modifiers: ".to_string(), - names.clone().join(&", ".to_string()), - ), + v1_rt::concat("/// Modifiers: ".to_string(), names.join(&", ".to_string())), "\n".to_string(), ) } @@ -20854,7 +20732,7 @@ pub fn emit_operation_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str.clone()) + v1_rt::concat("&self, ".to_string(), params_str) }; let ret_type = render_rust_type( resolved_type(op_node.clone()), @@ -20950,7 +20828,7 @@ pub fn emit_operation_method( ), " ".to_string(), ), - emit_ident(op_text.clone(), RenderTarget::Rust), + emit_ident(op_text, RenderTarget::Rust), ), "(".to_string(), ), @@ -21014,7 +20892,7 @@ let prelude = match wire_opt.clone() { v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()) } else { { - let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + let wire_ty = match tn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; @@ -21030,7 +20908,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -let raw = match (*ch.inferred).clone().as_deref().cloned() { +let raw = match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -21046,7 +20924,7 @@ match ch.return_cardinality.clone() { _ => raw.clone(), } }); } __result }); -let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.clone().iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); +let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); let result_body = v1_rt::concat(v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(log_line, "\n".to_string()), prelude), extract_lines.join(&"\n".to_string())), "\nOk(".to_string()), result_body), ")".to_string()) } @@ -21213,7 +21091,7 @@ pub fn emit_rest_http_method( source_indices: Rc>>, ) -> String { match transport_method(transport, source_indices.clone()) { - Some(m) => match (*m.inferred).clone().as_deref().cloned() { + Some(m) => match m.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { let method_name = expr_var_name_at(m.clone(), source_indices.clone()); Rc::new({ @@ -21290,7 +21168,7 @@ pub fn emit_rest_url_line( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.clone().iter().cloned() { + for p in parts.iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -21323,7 +21201,7 @@ pub fn emit_rest_url_line( ) } else { { - let args_str = args.clone().join(&", ".to_string()); + let args_str = args.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21478,7 +21356,7 @@ pub fn emit_rest_query_line( v1_rt::concat( v1_rt::concat( "let request = request.query(&[".to_string(), - pairs.clone().join(&", ".to_string()), + pairs.join(&", ".to_string()), ), "]);".to_string(), ) @@ -21505,11 +21383,11 @@ if (((req_strs.clone().len() as i64) == 0) && ((optional_fields.clone().len() as } else { { let body_init = if ((req_strs.clone().len() as i64) > 0) { - v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.clone().join(&", ".to_string())), " });".to_string()) + v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.join(&", ".to_string())), " });".to_string()) } else { "let mut __body = serde_json::json!({});".to_string() }; -let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.clone().iter().cloned() { __result.push({ +let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.iter().cloned() { __result.push({ let fname = field_init_node_name_at(fi.clone(), source_indices.clone()); let fexpr = emit_simple_expr(field_init_node_value(fi.clone()), RenderTarget::Rust, source_indices.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("if let Some(ref __v) = ".to_string(), fexpr.clone()), " { __body[\"".to_string()), fname.clone()), "\"] = serde_json::json!(__v); }".to_string()) @@ -21627,17 +21505,15 @@ pub fn operation_response_200_resolved_type( { Some(p) => { let v = field_init_node_value(p.clone()); - match (*v.inferred).clone().as_deref().cloned() { + match v.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => Some(tn.clone()), _ => { - let type_name = authored_name_at( - source_indices.clone(), - normalize_access_type_node(v.clone()), - ); + let type_name = + authored_name_at(source_indices.clone(), normalize_access_type_node(v)); if (type_name.clone() == "".to_string()) { None } else { - lookup_type_by_name(env, type_name.clone()) + lookup_type_by_name(env, type_name) } } } @@ -21657,8 +21533,7 @@ pub fn is_json_wire_declaration_type( } else { { let parts = Rc::new( - n.clone() - .split(&".".to_string()) + n.split(&".".to_string()) .map(|s| s.to_string()) .collect::>(), ); @@ -21741,7 +21616,7 @@ pub fn advance_wire_path_projection( } else { if path_segment_is_list_index(seg.clone()) { { - let next_node = match (*state.node).clone() { + let next_node = match state.node.clone() { Some(n) => Some(for_each_element_type_node( n.clone(), source_indices.clone(), @@ -21777,7 +21652,7 @@ pub fn advance_wire_path_projection( }) } } else { - match (*state.node).clone() { + match state.node.clone() { Some(n) => { match wire_child_for_segment(n.clone(), seg.clone(), source_indices.clone()) { Some(ch) => Rc::new(WirePathProjection { @@ -21955,7 +21830,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "bool".to_string()) { + if (rust_type == "bool".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -22020,7 +21895,7 @@ pub fn emit_from_key_extraction( .to_string() } else { { - let wire_ty = match (*tn.inferred).clone().as_deref().cloned() { + let wire_ty = match tn.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => tn.clone(), }; @@ -22053,7 +21928,7 @@ let from_path = match child_from_key(ch.clone(), source_indices.clone()) { Some(p) => p.clone(), None => ch_name.clone(), }; -match (*ch.inferred).clone().as_deref().cloned() { +match ch.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => if use_typed_wire.clone() { match wire_opt.clone() { Some(wire_node) => emit_typed_wire_field_assign(field_name.clone(), from_path.clone(), wire_node.clone(), source_indices.clone()), @@ -22070,7 +21945,7 @@ match (*ch.inferred).clone().as_deref().cloned() { }); let field_names = Rc::new({ let mut __result = Vec::new(); - for ch in children.clone().iter().cloned() { + for ch in children.iter().cloned() { __result.push(emit_ident( authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust, @@ -22082,13 +21957,13 @@ match (*ch.inferred).clone().as_deref().cloned() { v1_rt::concat( v1_rt::concat( "(".to_string(), - field_names.clone().first().cloned().clone().unwrap(), + field_names.first().cloned().clone().unwrap(), ), ",)".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), field_names.clone().join(&", ".to_string())), + v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string(), ) }; @@ -22147,22 +22022,22 @@ pub fn emit_response_code_handling( __result }); if ((response_props.clone().len() as i64) == 0) { - if use_from_key.clone() { + if use_from_key { emit_from_key_extraction( op_node.clone(), source_indices.clone(), - shared_types.clone(), - corpus_repr.clone(), - env.clone(), + shared_types, + corpus_repr, + env, ) } else { - emit_plain_response_body(op_node.clone(), transport.clone(), source_indices.clone()) + emit_plain_response_body(op_node.clone(), transport, source_indices.clone()) } } else { { let arms = Rc::new({ let mut __result = Vec::new(); - for p in response_props.clone().iter().cloned() { + for p in response_props.iter().cloned() { __result.push(emit_response_arm( p.clone(), op_node.clone(), @@ -22222,15 +22097,12 @@ pub fn emit_response_arm( { let prefix = v1_rt::substring(&code_str, 0, 1); v1_rt::concat( - v1_rt::concat( - v1_rt::concat(prefix.clone(), "00..=".to_string()), - prefix.clone(), - ), + v1_rt::concat(v1_rt::concat(prefix.clone(), "00..=".to_string()), prefix), "99".to_string(), ) } } else { - code_str.clone() + code_str } }; if is_success { @@ -22294,7 +22166,7 @@ pub fn emit_exit_code_handling( __result }); if ((exit_props.clone().len() as i64) == 0) { - emit_shell_return(inferred.clone(), source_indices.clone()) + emit_shell_return(inferred, source_indices) } else { { let has_nonzero = { @@ -22311,7 +22183,7 @@ pub fn emit_exit_code_handling( }; let exit_arms = Rc::new({ let mut __result = Vec::new(); - for p in exit_props.clone().iter().cloned() { + for p in exit_props.iter().cloned() { __result.push(emit_exit_arm( p.clone(), inferred.clone(), @@ -22358,7 +22230,7 @@ pub fn emit_exit_arm( } else { code_str.clone() }; - let is_success = (code_str.clone() == "0".to_string()); + let is_success = (code_str == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -22454,15 +22326,9 @@ pub fn emit_shell_call( let arg_lines = if ((argv.clone().len() as i64) > 1) { Rc::new({ let mut __result = Vec::new(); - for arg in Rc::new( - argv.clone() - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ) - .iter() - .cloned() + for arg in Rc::new(argv.iter().cloned().skip(1 as usize).collect::>()) + .iter() + .cloned() { __result.push(v1_rt::concat( v1_rt::concat( @@ -22507,7 +22373,7 @@ pub fn emit_shell_call( __result }); let wd_line = " .current_dir(self.working_dir.as_deref().unwrap_or(\".\"))".to_string(); - if has_stdin.clone() { + if has_stdin { { let stdin_expr = transport_stdin(transport.clone(), source_indices.clone()) .clone() @@ -22516,14 +22382,10 @@ pub fn emit_shell_call( ExprData::ExprVar { binding_kind: _, .. } => emit_ident( - expr_var_name_at(stdin_expr.clone(), source_indices.clone()), - RenderTarget::Rust, - ), - _ => emit_simple_expr( - stdin_expr.clone(), + expr_var_name_at(stdin_expr, source_indices.clone()), RenderTarget::Rust, - source_indices.clone(), ), + _ => emit_simple_expr(stdin_expr, RenderTarget::Rust, source_indices.clone()), }; let spawn_line = " .stdin(std::process::Stdio::piped())\n .stdout(std::process::Stdio::piped())\n .stderr(std::process::Stdio::piped())".to_string(); let spawn_exec = " .spawn()?;".to_string(); @@ -22621,7 +22483,7 @@ pub fn emit_shell_argv_element( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.clone().iter().cloned() { + for p in parts.iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -22664,23 +22526,23 @@ pub fn emit_shell_argv_element( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(arg.clone(), source_indices.clone()); + let name = expr_var_name_at(arg.clone(), source_indices); let var_name = emit_ident(name.clone(), RenderTarget::Rust); let is_opt = (is_optional_typed_expr(arg.clone()) - || match v1_rt::map_get(&optional_params, name.clone()) { + || match v1_rt::map_get(&optional_params, name) { Some(_) => true, None => false, }); - if is_opt.clone() { + if is_opt { emit_rust_dag_string_to_host_via_seam( - v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), + v1_rt::concat(var_name, ".as_deref().unwrap_or(\"\")".to_string()), corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name, corpus_repr) } } - _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), + _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices), } } @@ -22704,10 +22566,10 @@ pub fn emit_shell_return( Some(channel) => { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr(channel.clone(), is_optional.clone()) + emit_shell_channel_expr(channel.clone(), is_optional) } None => { - if (is_product.clone() && ((effective.children.clone().len() as i64) > 1)) { + if (is_product && ((effective.children.clone().len() as i64) > 1)) { { let needs_stderr = { let mut __found = false; @@ -22745,7 +22607,7 @@ pub fn emit_shell_return( __result }); let lines = if (stderr_line.clone() != "".to_string()) { - v1_rt::concat(stderr_line.clone(), "\n".to_string()) + v1_rt::concat(stderr_line, "\n".to_string()) } else { "".to_string() }; @@ -22761,7 +22623,7 @@ pub fn emit_shell_return( { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr("stdout".to_string(), is_optional.clone()) + emit_shell_channel_expr("stdout".to_string(), is_optional) } } } @@ -22800,10 +22662,10 @@ pub fn unwrap_single_field_product(n: Rc) -> Rc { { match n.children.clone().first().cloned() { Some(field_node) => resolved_type(field_node.clone()), - None => n.clone(), + None => n, } } else { - n.clone() + n } } } @@ -22868,7 +22730,7 @@ pub fn emit_resource_def( let depth = 0; let cap_methods = Rc::new({ let mut __result = Vec::new(); - for c in cap_children.clone().iter().cloned() { + for c in cap_children.iter().cloned() { __result.push(emit_capability_method( c.clone(), shared_types.clone(), @@ -22935,7 +22797,7 @@ pub fn emit_capability_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str.clone()) + v1_rt::concat("&self, ".to_string(), params_str) }; let ret = render_rust_type( resolved_type(cap_node.clone()), @@ -23013,8 +22875,8 @@ pub fn data_def_annotation_is_named_refinement( { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); ((((ann_name.clone() != "".to_string()) - && ((*annotation.type_annotation).clone() != None)) - && !is_container_type(ann_name.clone())) + && (annotation.type_annotation.clone() != None)) + && !is_container_type(ann_name)) && !is_host_text_carrier_type( annotation.clone(), source_indices.clone(), @@ -23038,7 +22900,7 @@ pub fn emit_data_def( let render_type_node = if ((annotation_type_node.children.clone().len() as i64) > 0) { annotation_type_node.clone() } else { - match (*value.inferred).clone().as_deref().cloned() { + match value.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), _ => annotation_type_node.clone(), } @@ -23051,7 +22913,7 @@ pub fn emit_data_def( RenderTarget::Rust, authored_name_at( (*scope.type_env).clone().source_indices.clone(), - annotation_type_node.clone(), + annotation_type_node, ), ) } else { @@ -23076,28 +22938,25 @@ pub fn emit_data_def( resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { - raw_ty_str.clone() + raw_ty_str } else { - if (raw_ty_str.clone() == "Rc".to_string()) { + if (raw_ty_str == "Rc".to_string()) { v1_rt::concat( - v1_rt::concat( - "Rc>".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("BoundedLattice<".to_string(), top_type_name.clone()), + v1_rt::concat("BoundedLattice<".to_string(), top_type_name), ">".to_string(), ) } } } - None => raw_ty_str.clone(), + None => raw_ty_str, } } else { - raw_ty_str.clone() + raw_ty_str }; let fn_name = to_snake(name); let needs_rc = v1_rt::set_contains( @@ -23151,7 +23010,7 @@ pub fn emit_data_def( ), "() -> ".to_string(), ), - ty_str.clone(), + ty_str, ), " { ".to_string(), ), @@ -23170,10 +23029,10 @@ pub fn emit_data_def( depth, shared_types.clone(), emit_info.clone(), - needs_rc.clone(), + needs_rc, ); let kw = rust_items().func_keyword.clone(); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str.clone()), "| c.clone())\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str), "| c.clone())\n".to_string()), "}".to_string()) } } } @@ -23198,7 +23057,7 @@ pub fn rust_nominal_identity_data_expr( let symbol_name = expr_var_name_at(value.clone(), source_indices.clone()); Some(v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_name.clone(), "(\"".to_string()), + v1_rt::concat(type_name, "(\"".to_string()), escape_string_literal_body(symbol_name), ), "\".to_string())".to_string(), @@ -23262,7 +23121,7 @@ pub fn emit_data_def_body( (*scope.type_env).clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => match lattice_value.clone() { + None => match lattice_value { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), @@ -23330,7 +23189,7 @@ pub fn emit_data_def_body( } }; let phantom_line = match lookup_type_by_name( - (*scope.type_env).clone(), + scope.type_env.clone(), "BoundedLattice".to_string(), ) { Some(struct_decl) => { @@ -23462,7 +23321,7 @@ pub fn emit_data_def_body( emit_info.clone(), 1024, ); - v1_rt::concat(" ".to_string(), val_str.clone()) + v1_rt::concat(" ".to_string(), val_str) } } } else { @@ -23489,12 +23348,12 @@ pub fn emit_data_def_body( match effective_variant_parent( vname.clone(), bk.clone(), - (*value.inferred).clone(), + value.inferred.clone(), emit_info.clone(), (*scope.type_env).clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( - vname.clone(), + vname, enum_name.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), @@ -23509,7 +23368,7 @@ pub fn emit_data_def_body( } else { "".to_string() }; - let wrap_end = if (needs_rc.clone() && !is_already_wrapped.clone()) { + let wrap_end = if (needs_rc.clone() && !is_already_wrapped) { ")".to_string() } else { "".to_string() @@ -23517,7 +23376,7 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat(" ".to_string(), wrap_start), - val_str.clone(), + val_str, ), wrap_end, ) @@ -23555,7 +23414,7 @@ pub fn emit_test_file( } else { { let filename = module_to_filename(module_name.clone()); - let tests_str = test_fns.clone().join(&"\n\n".to_string()); + let tests_str = test_fns.join(&"\n\n".to_string()); let content = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -23577,7 +23436,7 @@ pub fn emit_test_file( ), " use super::*;\n\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), tests_str, ), @@ -23653,7 +23512,7 @@ pub fn rust_test_signature_comment( ") -> ".to_string(), ), emit_node_type( - (*projection.inferred).clone(), + projection.inferred.clone(), RenderTarget::Rust, projection.source_indices.clone(), ), @@ -23685,9 +23544,9 @@ pub fn emit_operation_test( let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { - args_str.clone() + args_str }; - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent.clone()), "assert!(result.is_ok(), \"".to_string()), struct_name.clone()), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent), "assert!(result.is_ok(), \"".to_string()), struct_name), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) } } @@ -23703,7 +23562,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name.clone(), + type_name, ), "\")".to_string(), ), @@ -23711,7 +23570,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name.clone(), + type_name, ), "\")".to_string(), ), @@ -23912,7 +23771,7 @@ pub fn resolve_param_default( .first() .cloned() { - Some(data_item) => match (*data_item.body).clone() { + Some(data_item) => match data_item.body.clone() { Some(body) => extract_literal_string(body.clone()), None => None, }, @@ -23967,7 +23826,7 @@ pub fn to_workflow_func( None => v1_rt::rc_empty_set::(), }; Rc::new(WorkflowFunc { - name: item_name.clone(), + name: item_name, module_name: module_name.clone(), params: item.params.clone(), inferred: resolved_type(item.clone()), @@ -23985,7 +23844,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if ((*item.body).clone() == None) { + if (item.body.clone() == None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -24033,7 +23892,7 @@ pub fn collect_workflow_funcs( item.clone(), authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), ), registry.clone(), tm.items.clone(), @@ -24128,7 +23987,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( (*tm.type_env).clone().source_indices.clone(), - (*tm.module).clone(), + tm.module.clone(), )), None => "".to_string(), }; @@ -24149,7 +24008,7 @@ pub fn emit_main_rs( for m in modules.clone().iter().cloned() { if (authored_name_at( (*m.type_env).clone().source_indices.clone(), - (*m.module).clone(), + m.module.clone(), ) == "v1.compiler.compile".to_string()) { __found = true; @@ -24285,12 +24144,12 @@ pub fn emit_main_rs( "".to_string() }; let resource_use = if (resource_imports_str.clone() != "".to_string()) { - v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) + v1_rt::concat(resource_imports_str, "\n".to_string()) } else { "".to_string() }; let svc_use = if (svc_imports_str.clone() != "".to_string()) { - v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) + v1_rt::concat(svc_imports_str, "\n".to_string()) } else { "".to_string() }; @@ -24338,7 +24197,7 @@ pub fn emit_main_rs( has_pipeline.clone(), crate_name.clone(), ); - let diagnostic_fns = if has_pipeline.clone() { + let diagnostic_fns = if has_pipeline { emit_main_diagnostic_fns(crate_name.clone()) } else { "".to_string() @@ -24425,7 +24284,7 @@ pub fn emit_main_mod_uses( { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); let core_mod = module_to_filename("v1.std.core".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) } } else { base @@ -24558,7 +24417,7 @@ pub fn emit_subcommand_enum( "#[derive(Subcommand)]\n".to_string(), "enum Commands {\n".to_string(), ), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), variants_str, ), @@ -24692,8 +24551,8 @@ pub fn emit_cli_param_type_node( { let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname.clone()) { - mapped.clone() + if (mapped.clone() != nname) { + mapped } else { "String".to_string() } @@ -24773,10 +24632,7 @@ pub fn emit_main_fn( } else { v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(parse_line, "\n".to_string()), - dry_run_line.clone(), - ), + v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), dry_run_line), "\n".to_string(), ), result_handling, @@ -24786,7 +24642,7 @@ pub fn emit_main_fn( v1_rt::concat( v1_rt::concat( v1_rt::concat(async_attr, "{\n".to_string()), - make_indent((depth.clone() + 1)), + make_indent((depth + 1)), ), body_lines, ), @@ -24798,7 +24654,7 @@ pub fn emit_main_fn( pub fn emit_compile_match_arm(crate_name: String) -> String { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) } } @@ -24821,7 +24677,7 @@ pub fn emit_main_pipeline_fns(crate_name: String) -> String { ), emit_resolve_transitively_fn(crate_name.clone(), pipeline_mod.clone()), ), - emit_compile_target_helpers(crate_name.clone(), pipeline_mod.clone(), artifact_mod), + emit_compile_target_helpers(crate_name.clone(), pipeline_mod, artifact_mod), ) } } diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index f4200b72527..877a7cfd813 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -193,9 +193,9 @@ pub fn record_use( pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc { if (binding_fan_out(b.clone()) > binding_fan_out(a.clone())) { - b.clone() + b } else { - a.clone() + a } } @@ -271,7 +271,7 @@ pub fn walk_expr( binding_kind: bk, .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if in_tail.clone() { + if in_tail { record_use( accum, n, @@ -298,7 +298,7 @@ pub fn walk_expr( ExprData::ExprVar { binding_kind: bk, .. } => { - let vn = expr_var_name_at(base_node.clone(), si.clone()); + let vn = expr_var_name_at(base_node, si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); record_use( accum, @@ -309,7 +309,7 @@ pub fn walk_expr( texpr.span.clone().start.clone(), ) } - _ => walk_expr(accum, base_node.clone(), false, si.clone()), + _ => walk_expr(accum, base_node, false, si.clone()), } } ExprData::ExprCall { .. } => { @@ -344,7 +344,7 @@ pub fn walk_expr( ia_val.span.clone().start.clone(), ) } - _ => walk_expr(accum, ia_val.clone(), false, si.clone()), + _ => walk_expr(accum, ia_val, false, si.clone()), } } None => accum, @@ -359,7 +359,7 @@ pub fn walk_expr( __result }); non_init.iter().cloned().fold( - threaded_accum.clone(), + threaded_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -409,14 +409,14 @@ pub fn walk_expr( ia_val.span.clone().start.clone(), ) } - _ => walk_expr(recv_accum, ia_val.clone(), false, si.clone()), + _ => walk_expr(recv_accum, ia_val, false, si.clone()), } } None => recv_accum, }; let non_init = Rc::new({ let mut __result = Vec::new(); - for a in mc_args.clone().iter().cloned() { + for a in mc_args.iter().cloned() { if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } @@ -424,7 +424,7 @@ pub fn walk_expr( __result }); let walked = non_init.iter().cloned().fold( - threaded_accum.clone(), + threaded_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -440,7 +440,7 @@ pub fn walk_expr( } else { { let recv_accum = walk_expr(accum, recv, false, si.clone()); - mc_args.clone().iter().cloned().fold( + mc_args.iter().cloned().fold( recv_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) @@ -465,7 +465,7 @@ pub fn walk_expr( } __result }); - merge_branch_usages(s_accum.clone(), branch_accums) + merge_branch_usages(s_accum, branch_accums) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); @@ -473,16 +473,16 @@ pub fn walk_expr( let c_accum = walk_expr(accum, c, false, si.clone()); let t_accum = walk_expr(c_accum.clone(), t, in_tail.clone(), si.clone()); let e_accum = match if_else_branch(texpr.clone()) { - Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail.clone(), si.clone()), + Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail, si.clone()), None => c_accum.clone(), }; - merge_branch_usages(c_accum.clone(), Rc::new(vec![t_accum, e_accum])) + merge_branch_usages(c_accum, Rc::new(vec![t_accum, e_accum])) } ExprData::ExprLet => { let v = let_value(texpr.clone()); let v_accum = walk_expr(accum, v, false, si.clone()); match let_body(texpr.clone()) { - Some(b) => walk_expr(v_accum, b.clone(), in_tail.clone(), si.clone()), + Some(b) => walk_expr(v_accum, b.clone(), in_tail, si.clone()), None => v_accum, } } @@ -520,13 +520,10 @@ pub fn walk_expr( walk_expr(acc, p.1.clone(), false, si.clone()) }, ); - match ss.clone().last().cloned() { - Some(last_expr) => walk_expr( - init_accum, - last_expr.clone(), - in_tail.clone(), - si.clone(), - ), + match ss.last().cloned() { + Some(last_expr) => { + walk_expr(init_accum, last_expr.clone(), in_tail, si.clone()) + } None => init_accum, } } @@ -579,7 +576,7 @@ pub fn walk_expr( .iter() .cloned() .fold( - coll_accum.clone(), + coll_accum, |acc: Rc, usage: Rc| { let a1 = record_use( acc, @@ -669,7 +666,7 @@ pub fn make_decision(usage: Rc) -> Rc { }); Rc::new(OwnershipDecision::SharedError { binding: usage.name.clone(), - consumer_count: sc.clone(), + consumer_count: sc, sites: sites, }) } @@ -817,7 +814,7 @@ pub fn collect_callable_refs( } => { let recv = collect_callable_refs(method_receiver(texpr.clone()), si.clone()); method_arg_nodes(texpr.clone()).iter().cloned().fold( - recv.clone(), + recv, |acc: Rc>, a: Rc| { v1_rt::rc_set_union( acc, @@ -838,7 +835,7 @@ pub fn collect_callable_refs( ExprData::ExprMatch => { let scrut = collect_callable_refs(match_scrutinee(texpr.clone()), si.clone()); match_arm_nodes(texpr.clone()).iter().cloned().fold( - scrut.clone(), + scrut, |acc: Rc>, arm: Rc| { v1_rt::rc_set_union( acc, @@ -949,7 +946,7 @@ pub fn summarize_fold_acc_uses( binding_kind: _, .. } => { if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { - if inside_nested.clone() { + if inside_nested { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -971,11 +968,11 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), + } => (expr_var_name_at(base, si.clone()) == acc_name.clone()), _ => false, }; if is_direct { - if inside_nested.clone() { + if inside_nested { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -1033,7 +1030,7 @@ pub fn summarize_fold_acc_uses( foreach_collection(node.clone()), acc_name.clone(), si.clone(), - inside_nested.clone(), + inside_nested, ); let body_summary = summarize_fold_acc_uses( foreach_body(node.clone()), @@ -1097,7 +1094,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal.clone()) == acc_type_name) + (authored_name_at(si, terminal) == acc_type_name) } _ => false, } @@ -1147,7 +1144,7 @@ pub fn analyze_single_fold( Some(a) => arg_value(a.clone()), None => method_call.clone(), }; - let fold_lambda_node = match args.clone().get(1 as usize).cloned() { + let fold_lambda_node = match args.get(1 as usize).cloned() { Some(a) => arg_value(a.clone()), None => method_call.clone(), }; @@ -1163,13 +1160,13 @@ pub fn analyze_single_fold( } _ => "".to_string(), }; - let acc_type_name = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let acc_type_name = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => authored_name_at(si.clone(), type_node.clone()), _ => "".to_string(), }; - let cond_required = match (*init_arg_node.inferred).clone().as_deref().cloned() { + let cond_required = match init_arg_node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: type_node, .. }) => (type_node.return_cardinality.clone() == Cardinality::Required), @@ -1185,20 +1182,17 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let cond_safe = fold_body_safe_field_moves( - fold_lambda_node.clone(), - acc_param_name.clone(), - si.clone(), - ); + let cond_safe = + fold_body_safe_field_moves(fold_lambda_node, acc_param_name.clone(), si.clone()); let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), - acc_param_name: acc_param_name.clone(), - acc_type_name: acc_type_name.clone(), - body_constructs_acc: cond_struct.clone(), - whole_acc_single_use: cond_whole_acc.clone(), - safe_field_moves: cond_safe.clone(), + acc_param_name: acc_param_name, + acc_type_name: acc_type_name, + body_constructs_acc: cond_struct, + whole_acc_single_use: cond_whole_acc, + safe_field_moves: cond_safe, eligible: eligible, }) } @@ -1216,7 +1210,7 @@ pub fn analyze_ownership( .iter() .cloned() .fold(empty_usage_accum(), |acc: Rc, p: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:23177:acc"); { let p_name = authored_name_at(si.clone(), p.clone()); Rc::new(UsageAccum { @@ -1382,7 +1376,7 @@ pub fn merge_branch_licenses(branches: Rc>>) -> Rc(), }), |acc: Rc, br: Rc| { - let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); + let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:26035:acc"); { let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) .iter() @@ -1443,17 +1437,12 @@ pub fn license_walk( binding_kind: _, .. } => record_field_use_site( acc.clone(), - expr_var_name_at(base_node.clone(), si.clone()), + expr_var_name_at(base_node, si.clone()), field_access_field_at(texpr.clone(), si.clone()), texpr.span.clone().start.clone(), in_capture.clone(), ), - _ => license_walk( - acc.clone(), - base_node.clone(), - in_capture.clone(), - si.clone(), - ), + _ => license_walk(acc.clone(), base_node, in_capture.clone(), si.clone()), } } ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) From 1509122eb07d3af59f8ea309ca0e9c1806ca31df Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:27:28 +0000 Subject: [PATCH 25/27] Restore seed to origin/main + v1_rt counted helper (post gen-2' adjudication; v1_rt updated to main's sorted_map_keys base) Co-Authored-By: Claude Fable 5 --- src/v1/stage0/src/v1_compiler_complexity.rs | 573 ++--- src/v1/stage0/src/v1_compiler_emit_rust.rs | 1876 +++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 2 - .../stage0/src/v1_compiler_infer_emit_info.rs | 4 - src/v1/stage0/src/v1_compiler_ownership.rs | 435 +--- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- 6 files changed, 1275 insertions(+), 1617 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 6d2d00322da..368276eb3bc 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -535,7 +535,7 @@ pub fn parser_state_expr_progress( if (name.clone() == state_param.name.clone()) { DescentEvidence::NonIncreasing } else { - match v1_rt::map_get(&env.state_aliases.clone(), name) { + match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { Some(progress) => progress.clone(), None => DescentEvidence::DescentUnknown, } @@ -641,7 +641,7 @@ pub fn parser_state_expr_progress( __result }); match arm_progresses.clone().first().cloned() { - Some(initial) => arm_progresses.iter().cloned().fold( + Some(initial) => arm_progresses.clone().iter().cloned().fold( initial.clone(), |acc: DescentEvidence, p: DescentEvidence| { descent_evidence_lattice_meet(acc, p.clone()) @@ -683,7 +683,7 @@ pub fn parser_block_state_progress( .collect::>(), ); let final_env = leading.iter().cloned().fold( - env, + env.clone(), |acc_env: Rc, stmt: Rc| match (*stmt.expr_data.clone()) .clone() { @@ -739,17 +739,17 @@ pub fn parser_result_source_for_expr( match (*parser_result_witness(expr.clone(), si.clone())).clone() { ParserResultWitness::ParserWitnessAdvance => { Rc::new(ParserResultSource::ParserResultAdvance { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessExpect => { Rc::new(ParserResultSource::ParserResultExpect { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessEat => { Rc::new(ParserResultSource::ParserResultEat { - input: input_progress, + input: input_progress.clone(), }) } ParserResultWitness::ParserWitnessCall { callee: callee, .. } => { @@ -763,7 +763,7 @@ pub fn parser_result_source_for_expr( Rc::new(ParserResultSource::ParserResultOpaque) } _ => Rc::new(ParserResultSource::ParserResultCall { - input: input_progress, + input: input_progress.clone(), callee: name.clone(), }), } @@ -786,7 +786,9 @@ pub fn parser_result_source_for_expr( ); match progress.clone() { DescentEvidence::DescentUnknown => Rc::new(ParserResultSource::ParserResultOpaque), - _ => Rc::new(ParserResultSource::ParserResultDirectState { input: progress }), + _ => Rc::new(ParserResultSource::ParserResultDirectState { + input: progress.clone(), + }), } } } @@ -1013,7 +1015,7 @@ pub fn collect_parser_progress_edges( consumed_true_set.clone(), si.clone(), ); - let then_consumed = match parser_progress_flag_var(cond, si.clone()) { + let then_consumed = match parser_progress_flag_var(cond.clone(), si.clone()) { Some(name) => { v1_rt::rc_map_insert(consumed_true_set.clone(), name.clone(), true) } @@ -1058,7 +1060,7 @@ pub fn collect_parser_progress_edges( ); let next_env = parser_env_with_binding( let_binding_name_at(body.clone(), si.clone()), - value_expr, + value_expr.clone(), env.clone(), state_param.clone(), parser_always_advancing.clone(), @@ -1298,7 +1300,7 @@ pub fn parser_success_progress( Some(body) => parser_success_progress( body.clone(), state_param.clone(), - next_env, + next_env.clone(), parser_always_advancing.clone(), consumed_true_set.clone(), si.clone(), @@ -1424,7 +1426,7 @@ pub fn infer_parser_always_advancing_members_worklist( ); if set_has(proven.clone(), name.clone()) { { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } @@ -1442,8 +1444,7 @@ pub fn infer_parser_always_advancing_members_worklist( None => Rc::new(vec![]), }; { - let __tco_0 = - deduplicate(v1_rt::concat(rest.clone(), callers.clone())); + let __tco_0 = deduplicate(v1_rt::concat(rest, callers)); let __tco_1 = v1_rt::rc_map_insert(proven, name.clone(), true); queue = __tco_0; proven = __tco_1; @@ -1451,14 +1452,14 @@ pub fn infer_parser_always_advancing_members_worklist( } } else { { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } } } None => { - let __tco_0 = rest.clone(); + let __tco_0 = rest; queue = __tco_0; continue; } @@ -1617,7 +1618,7 @@ pub fn same_progress_subgraph_has_cycle( { let same_cross_edges = Rc::new({ let mut __result = Vec::new(); - for edge in same_edges.iter().cloned() { + for edge in same_edges.clone().iter().cloned() { if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } @@ -1722,7 +1723,7 @@ pub fn classify_parser_scc_recursion_pattern( __all }; if (all_known - && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) { Some(lower_call_pattern(Rc::new( CallPattern::ParserAdvanceCall { @@ -1863,9 +1864,9 @@ pub fn max_path_self_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls + then_calls.clone() } else { - else_calls + else_calls.clone() }; (cond_calls + branch_max) } @@ -1971,12 +1972,12 @@ pub fn max_path_self_calls_block( continue_calls: i64, si: Rc>>, ) -> i64 { - v1_rt::reverse(stmts) - .iter() - .cloned() - .fold(continue_calls, |acc: i64, stmt: Rc| { + v1_rt::reverse(stmts).iter().cloned().fold( + continue_calls.clone(), + |acc: i64, stmt: Rc| { max_path_self_calls_with_cont(stmt.clone(), func_name.clone(), acc, si.clone()) - }) + }, + ) } pub fn count_target_calls( @@ -2090,9 +2091,9 @@ pub fn max_path_target_calls_with_cont( None => continue_calls.clone(), }; let branch_max = if (then_calls.clone() > else_calls.clone()) { - then_calls + then_calls.clone() } else { - else_calls + else_calls.clone() }; (cond_calls + branch_max) } @@ -2206,11 +2207,7 @@ pub fn build_scc_measure_params( Some(entry) => v1_rt::rc_map_insert( acc.clone(), name.clone(), - recursive_measure_param_names( - entry.body.clone(), - entry.params.clone(), - si.clone(), - ), + recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), ), None => acc.clone(), }, @@ -2231,10 +2228,11 @@ pub fn target_call_has_arithmetic_descent( } else { match v1_rt::map_get(&func_index, callee.clone()) { Some(callee_entry) => { - let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee) { - Some(params) => params.clone(), - None => v1_rt::rc_empty_map::(), - }; + let callee_measure_params = + match v1_rt::map_get(&scc_measure_params, callee.clone()) { + Some(params) => params.clone(), + None => v1_rt::rc_empty_map::(), + }; { let mut __found = false; for pair in Rc::new( @@ -2370,7 +2368,7 @@ pub fn expr_descending_witness_source( } => { break v1_rt::map_get( &descending_witness_names, - expr_var_name_at(expr.clone(), si.clone()), + expr_var_name_at(expr.clone(), si), ); } ExprData::ExprBinOp { op, .. } => match op.clone() { @@ -2405,9 +2403,9 @@ pub fn condition_param_names( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(expr.clone(), si); + let name = expr_var_name_at(expr.clone(), si.clone()); match v1_rt::map_get(¶m_set, name.clone()) { - Some(_) => seed_string_map(name.clone(), name), + Some(_) => seed_string_map(name.clone(), name.clone()), None => v1_rt::rc_empty_map::(), } } @@ -2662,18 +2660,18 @@ pub fn is_children_of_param( ExprData::ExprFieldAccess { .. } => { let base = field_access_base(expr.clone()); let field = field_access_field_at(expr.clone(), si.clone()); - break (is_children_list_field(field.clone()) + break (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name.clone()), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }); } ExprData::ExprVar { binding_kind: _, .. } => { - break set_has(vars.clone(), expr_var_name_at(expr.clone(), si.clone())); + break set_has(vars, expr_var_name_at(expr.clone(), si.clone())); } ExprData::ExprMethodCall { method_semantics: ms, @@ -2711,7 +2709,7 @@ pub fn is_structural_children( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => set_has(vars.clone(), expr_var_name_at(base, si.clone())), + } => set_has(vars.clone(), expr_var_name_at(base.clone(), si.clone())), _ => false, }) } @@ -2781,7 +2779,7 @@ pub fn is_tree_size_preserving_wrapper( pub fn wrapper_inner_arg(expr: Rc) -> Rc { match expr.children.clone().first().cloned() { Some(arg_node) => arg_value(arg_node.clone()), - None => expr, + None => expr.clone(), } } @@ -2798,7 +2796,7 @@ pub fn is_sub_value_extractor(expr: Rc, si: Rc) -> Rc { match expr.children.clone().first().cloned() { Some(arg_node) => arg_value(arg_node.clone()), - None => expr, + None => expr.clone(), } } @@ -2942,12 +2940,11 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone() == param_name.clone()) - || set_has(vars.clone(), vname.clone())); + break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field.clone() == param_name.clone()) { + if (field == param_name.clone()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2957,7 +2954,7 @@ pub fn is_tokens_input_expr( } => { let bname = expr_var_name_at(base.clone(), si.clone()); break ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname.clone())); + || set_has(vars, bname.clone())); } _ => { break false; @@ -3098,9 +3095,9 @@ pub fn expr_contains_descent( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3393,7 +3390,7 @@ pub fn collect_descent_vars( } _ => false, }; - ((inner_is_descent || inner_is_var) || inner_is_param) + ((inner_is_descent.clone() || inner_is_var.clone()) || inner_is_param) } } else { false @@ -3407,9 +3404,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3448,7 +3445,12 @@ pub fn collect_descent_vars( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); + && is_tokens_consuming_call( + val.clone(), + param_name.clone(), + vars.clone(), + si.clone(), + )); let val_is_descent = ((((((((is_direct_descent || is_descent_var) || is_option_descent) || is_match_descent) @@ -3492,8 +3494,9 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -3663,15 +3666,15 @@ pub fn all_self_calls_descend_inc( let is_children_list = match (*val.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(val.clone()); - let field = field_access_field_at(val, si.clone()); + let field = field_access_field_at(val.clone(), si.clone()); (is_children_list_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3692,7 +3695,7 @@ pub fn all_self_calls_descend_inc( b.clone(), func_name.clone(), param_name.clone(), - next_vars, + next_vars.clone(), check_child.clone(), check_list.clone(), si.clone(), @@ -3724,8 +3727,9 @@ pub fn all_self_calls_descend_inc( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -3917,7 +3921,7 @@ pub fn all_self_calls_descend_inc( if (is_iter && is_struct) { { let recv_ok = all_self_calls_descend_inc( - receiver, + receiver.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -4060,12 +4064,12 @@ pub fn matches_on_sub_value_field( match (*scrut.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let base = field_access_base(scrut.clone()); - let field = field_access_field_at(scrut, si.clone()); + let field = field_access_field_at(scrut.clone(), si.clone()); (is_sub_value_field(field) && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base, si.clone()) == param_name), + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }) } @@ -4146,7 +4150,7 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left, si) == param_name) + ((expr_var_name_at(left.clone(), si) == param_name) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4201,7 +4205,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname == param_name.clone()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4233,7 +4237,7 @@ pub fn classify_self_call_evidence( DescentEvidence::NonIncreasing => { DescentEvidence::Strict } - _ => inner_ev, + _ => inner_ev.clone(), } } } else { @@ -4264,9 +4268,9 @@ pub fn classify_self_call_evidence( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname == param_name.clone())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { @@ -4479,7 +4483,7 @@ pub fn collect_evidence_incremental( } _ => false, }; - ((inner_d || inner_v) || inner_p) + ((inner_d.clone() || inner_v.clone()) || inner_p) } } else { false @@ -4493,9 +4497,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(vars.clone(), bname)) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -4534,7 +4538,12 @@ pub fn collect_evidence_incremental( false }; let is_consuming_helper = (check_list.clone() - && is_tokens_consuming_call(val, param_name.clone(), vars.clone(), si.clone())); + && is_tokens_consuming_call( + val.clone(), + param_name.clone(), + vars.clone(), + si.clone(), + )); let next_vars = if ((((((((is_direct || is_var) || is_option) || is_match_descent) || is_wrapped) @@ -4556,7 +4565,7 @@ pub fn collect_evidence_incremental( b.clone(), func_name.clone(), param_name.clone(), - next_vars, + next_vars.clone(), check_child.clone(), check_list.clone(), branching_only.clone(), @@ -4590,8 +4599,9 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - let sname = expr_var_name_at(scrut, si.clone()); - ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname)) + let sname = expr_var_name_at(scrut.clone(), si.clone()); + ((sname.clone() == param_name.clone()) + || set_has(vars.clone(), sname.clone())) } _ => false, }; @@ -4688,7 +4698,7 @@ pub fn collect_evidence_incremental( None } else { collect_evidence_incremental( - then_branch, + then_branch.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -4701,7 +4711,7 @@ pub fn collect_evidence_incremental( let else_ev = if (branching_only.clone() && (else_path == 0)) { None } else { - match else_opt { + match else_opt.clone() { Some(eb) => collect_evidence_incremental( eb.clone(), func_name.clone(), @@ -4816,7 +4826,7 @@ pub fn collect_evidence_incremental( if (is_iter && is_struct) { { let recv_ev = collect_evidence_incremental( - receiver, + receiver.clone(), func_name.clone(), param_name.clone(), vars.clone(), @@ -5044,7 +5054,7 @@ pub fn construct_termination_proof( } }); let single_dim_proof = match structural_proof.clone() { - Some(_) => structural_proof, + Some(_) => structural_proof.clone(), None => match parser_state_param(params.clone(), si.clone()) { Some(state_param) => { let self_set = seed_bool_map(func_name.clone()); @@ -5060,7 +5070,7 @@ pub fn construct_termination_proof( ); if (((edges.clone().len() as i64) > 0) && { let mut __all = true; - for edge in edges.iter().cloned() { + for edge in edges.clone().iter().cloned() { if !(edge.progress.clone() == DescentEvidence::Strict) { __all = false; break; @@ -5081,7 +5091,7 @@ pub fn construct_termination_proof( }, }; match single_dim_proof.clone() { - Some(_) => single_dim_proof, + Some(_) => single_dim_proof.clone(), None => { let self_set = seed_bool_map(func_name.clone()); let func_entry = Rc::new(FuncEntry { @@ -5095,7 +5105,7 @@ pub fn construct_termination_proof( construct_scc_termination_proof( Rc::new(vec![func_name.clone()]), func_index, - self_set, + self_set.clone(), si.clone(), ) } @@ -5323,7 +5333,7 @@ pub fn classify_recursion_pattern( let first_call = if all_calls_arithmetic_only { Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.iter().cloned() { + for call_ev in all_evidence.clone().iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5372,10 +5382,10 @@ pub fn classify_recursion_pattern( __result }); match tree_rels.clone().first().cloned() { - Some(_) => tree_rels.first().cloned(), + Some(_) => tree_rels.clone().first().cloned(), None => Rc::new({ let mut __result = Vec::new(); - for call_ev in all_evidence.iter().cloned() { + for call_ev in all_evidence.clone().iter().cloned() { __result.extend( (*Rc::new({ let mut __result = Vec::new(); @@ -5400,7 +5410,9 @@ pub fn classify_recursion_pattern( }; let is_arithmetic_branching = match first_call.clone() { Some(rel) => match (*rel.clone()).clone() { - SubValueRelation::ArithmeticDescent { .. } => (path_calls > 1), + SubValueRelation::ArithmeticDescent { .. } => { + (path_calls.clone() > 1) + } _ => false, }, None => false, @@ -5408,7 +5420,7 @@ pub fn classify_recursion_pattern( if is_arithmetic_branching { lower_call_pattern(Rc::new(CallPattern::SameArgumentCall)) } else { - match first_call { + match first_call.clone() { Some(rel) => match sub_value_to_lowering_target(rel.clone()) { Some(target) => target.clone(), None => { @@ -5489,13 +5501,13 @@ pub fn classify_recursion_pattern( } None => false, }; - match proof { + match proof.clone() { Some(p) => { - if ((path_calls == 1) || proof_safe_for_branching) { + if ((path_calls.clone() == 1) || proof_safe_for_branching.clone()) { lower_call_pattern(proof_to_call_pattern(p.clone())) } else { if branching_proof_safe { - match branching_proof { + match branching_proof.clone() { Some(bp) => lower_call_pattern(proof_to_call_pattern( bp.clone(), )), @@ -5509,8 +5521,8 @@ pub fn classify_recursion_pattern( } } None => { - if (path_calls > 1) { - match branching_proof { + if (path_calls.clone() > 1) { + match branching_proof.clone() { Some(bp) => { if branching_proof_safe { lower_call_pattern(proof_to_call_pattern( @@ -5550,7 +5562,7 @@ pub fn bounded_recursive_cost( let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var }), + upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), body: simplify_cost(per_iter), }) } @@ -5573,7 +5585,7 @@ pub fn bounded_scc_cost( let var = v1_rt::concat("n_".to_string(), v.clone()); Rc::new(CostExpr::CostSum { binder: var.clone(), - upper: Rc::new(SizeExpr::SizeVar { name: var }), + upper: Rc::new(SizeExpr::SizeVar { name: var.clone() }), body: simplify_cost(per_iter), }) } @@ -5609,7 +5621,7 @@ pub fn is_unknown_cost(expr: Rc) -> bool { pub fn extract_unknown_reason(mut expr: Rc) -> String { loop { - match (*expr.clone()).clone() { + match (*expr).clone() { CostExpr::CostUnknown { reason: r, .. } => { break r.clone(); } @@ -5689,7 +5701,7 @@ pub fn collect_local_call_edges_in_expr( if set_has(local_func_set.clone(), callee.clone()) { Rc::new(vec![Rc::new(CallEdge { caller: caller.clone(), - callee: callee, + callee: callee.clone(), })]) } else { Rc::new(vec![]) @@ -5810,7 +5822,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname == param_name.clone()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5836,7 +5848,7 @@ pub fn classify_scc_call_progress( ); match inner_progress.clone() { DescentEvidence::NonIncreasing => DescentEvidence::Strict, - _ => inner_progress, + _ => inner_progress.clone(), } } } else { @@ -5862,9 +5874,9 @@ pub fn classify_scc_call_progress( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname == param_name.clone())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { @@ -5971,7 +5983,7 @@ pub fn collect_scc_child_edges( ); Rc::new(vec![Rc::new(ParserProgressEdge { caller: caller.clone(), - callee: callee, + callee: callee.clone(), progress: progress, })]) } @@ -6016,7 +6028,7 @@ pub fn collect_scc_child_edges( if (is_iter && is_struct) { { let recv_edges = collect_scc_child_edges( - receiver, + receiver.clone(), caller.clone(), param_name.clone(), descent_vars.clone(), @@ -6213,7 +6225,7 @@ pub fn collect_scc_child_edges( } _ => false, }; - ((inner_d || inner_v) || inner_p) + ((inner_d.clone() || inner_v.clone()) || inner_p) } } else { false @@ -6227,9 +6239,9 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - let bname = expr_var_name_at(base, si.clone()); + let bname = expr_var_name_at(base.clone(), si.clone()); ((bname.clone() == param_name.clone()) - || set_has(descent_vars.clone(), bname)) + || set_has(descent_vars.clone(), bname.clone())) } _ => false, }) @@ -6269,7 +6281,7 @@ pub fn collect_scc_child_edges( }; let is_consuming_helper = (check_list.clone() && is_tokens_consuming_call( - val, + val.clone(), param_name.clone(), descent_vars.clone(), si.clone(), @@ -6295,7 +6307,7 @@ pub fn collect_scc_child_edges( b.clone(), caller.clone(), param_name.clone(), - next_vars, + next_vars.clone(), target_set.clone(), check_child.clone(), check_list.clone(), @@ -6504,7 +6516,7 @@ pub fn is_scc_container_child_descent( }); let unknown_edge_count = count_unknown_progress_edges(edges.clone()); (((unknown_edge_count == 0) && ((edges.clone().len() as i64) > 0)) - && (same_progress_subgraph_has_cycle(members.clone(), edges) == false)) + && (same_progress_subgraph_has_cycle(members.clone(), edges.clone()) == false)) } } @@ -6616,9 +6628,9 @@ pub fn pick_best_param_edges( candidate: Rc>, ) -> Rc> { if (count_known_in_edge_map(candidate.clone()) > count_known_in_edge_map(current.clone())) { - candidate + candidate.clone() } else { - current + current.clone() } } @@ -6929,17 +6941,20 @@ pub fn construct_scc_termination_proof( let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { param: if (cx_l2_param.clone() != "".to_string()) { - cx_l2_param + cx_l2_param.clone() } else { "scc".to_string() }, })]), }); if ((cx_l2_all_known && ((cx_l2_edges.clone().len() as i64) > 0)) - && (proof_has_non_descending_cycle(cx_l2_proof.clone(), members.clone(), cx_l2_edges) - == false)) + && (proof_has_non_descending_cycle( + cx_l2_proof.clone(), + members.clone(), + cx_l2_edges.clone(), + ) == false)) { - Some(cx_l2_proof) + Some(cx_l2_proof.clone()) } else { { let tree_edges = collect_scc_proof_edges_for_dim( @@ -6972,10 +6987,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tree_proof.clone(), members.clone(), - tree_edges, + tree_edges.clone(), ) == false)) { - Some(tree_proof) + Some(tree_proof.clone()) } else { { let list_edges = collect_scc_proof_edges_for_dim( @@ -7008,10 +7023,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( list_proof.clone(), members.clone(), - list_edges, + list_edges.clone(), ) == false)) { - Some(list_proof) + Some(list_proof.clone()) } else { { let parser_edges = collect_scc_parser_proof_edges( @@ -7044,10 +7059,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( parser_proof.clone(), members.clone(), - parser_edges, + parser_edges.clone(), ) == false)) { - Some(parser_proof) + Some(parser_proof.clone()) } else { { let lex_edges = collect_scc_independent_dim_edges( @@ -7087,10 +7102,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( lex_proof.clone(), members.clone(), - lex_edges, + lex_edges.clone(), ) == false)) { - Some(lex_proof) + Some(lex_proof.clone()) } else { { let tree_parser_edges = @@ -7141,10 +7156,10 @@ pub fn construct_scc_termination_proof( && (proof_has_non_descending_cycle( tp_proof.clone(), members.clone(), - tree_parser_edges, + tree_parser_edges.clone(), ) == false)) { - Some(tp_proof) + Some(tp_proof.clone()) } else { None } @@ -7344,9 +7359,9 @@ pub fn build_scc_index( ); Rc::new(SccResult { index: result.index.clone(), - topo_order: topo_order, + topo_order: topo_order.clone(), processing_order: finish.order.clone(), - call_graph: graph, + call_graph: graph.clone(), }) } } @@ -7355,9 +7370,9 @@ pub fn cost_seq(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a, + CostExpr::CostConst { value: 0, .. } => a.clone(), _ => Rc::new(CostExpr::CostAdd { - left: a, + left: a.clone(), right: b.clone(), }), }, @@ -7368,9 +7383,9 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { match (*a.clone()).clone() { CostExpr::CostConst { value: 0, .. } => b.clone(), _ => match (*b.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => a, + CostExpr::CostConst { value: 0, .. } => a.clone(), _ => Rc::new(CostExpr::CostMax { - left: a, + left: a.clone(), right: b.clone(), }), }, @@ -7437,12 +7452,12 @@ pub fn receiver_size_var( match (*recv.expr_data.clone()).clone() { ExprData::ExprVar { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: expr_var_name_at(recv.clone(), si.clone()), + collection: expr_var_name_at(recv.clone(), si), }); } ExprData::ExprFieldAccess { .. } => { break Rc::new(SizeExpr::SizeLen { - collection: field_access_field_at(recv.clone(), si.clone()), + collection: field_access_field_at(recv.clone(), si), }); } ExprData::ExprMethodCall { @@ -7455,7 +7470,7 @@ pub fn receiver_size_var( }; if method_preserves_collection_size(method_semantics.clone()) { { - let __tco_0 = inner_recv.clone(); + let __tco_0 = inner_recv; recv = __tco_0; continue; } @@ -7528,7 +7543,7 @@ pub fn resolve_callback_cost( let fn_ref = expr_var_name_at(la.clone(), si.clone()); match v1_rt::map_get(&func_index, fn_ref.clone()) { Some(_) => get_or_compute_summary( - fn_ref, + fn_ref.clone(), func_index.clone(), scc_index, recv_r.table.clone(), @@ -7617,7 +7632,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: os, certainty: body_result.summary.clone().certainty.clone(), }), @@ -7650,9 +7665,9 @@ pub fn cost_of_method_by_shape( base: 2, argument: size.clone(), }); - let per_comparison = (*key_result.summary.clone().work).clone(); + let per_comparison = key_result.summary.clone().work.clone(); let sort_work = Rc::new(CostExpr::CostMul { - left: cost_loop(binder.clone(), size.clone(), Rc::new(per_comparison)), + left: cost_loop(binder.clone(), size.clone(), per_comparison), right: log_factor, }); let sort_os = seed_cost_map( @@ -7666,7 +7681,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), sort_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), sort_work), + span: cost_seq(recv_r.summary.clone().span.clone(), sort_work.clone()), output_size: sort_os, certainty: key_result.summary.clone().certainty.clone(), }), @@ -7694,7 +7709,7 @@ pub fn cost_of_method_by_shape( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(recv_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(recv_r.summary.clone().span.clone(), loop_work), + span: cost_seq(recv_r.summary.clone().span.clone(), loop_work.clone()), output_size: scan_os, certainty: recv_r.summary.clone().certainty.clone(), }), @@ -7753,29 +7768,29 @@ pub fn empty_complexity_report() -> Rc { pub fn simplify_cost(expr: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr, + CostExpr::CostConst { value: _, .. } => expr.clone(), CostExpr::CostAdd { left: l, right: r, .. } => { let sl = simplify_cost(l.clone()); let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr, + CostExpr::CostConst { value: 0, .. } => sr.clone(), CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), CostExpr::CostConst { value: b, .. } => Rc::new(CostExpr::CostConst { value: (a.clone() + b.clone()), }), _ => Rc::new(CostExpr::CostAdd { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), _ => Rc::new(CostExpr::CostAdd { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7790,15 +7805,15 @@ pub fn simplify_cost(expr: Rc) -> Rc { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sr, + CostExpr::CostConst { value: 1, .. } => sr.clone(), _ => match (*sr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: 1, .. } => sl, + CostExpr::CostConst { value: 1, .. } => sl.clone(), _ => Rc::new(CostExpr::CostMul { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7810,26 +7825,26 @@ pub fn simplify_cost(expr: Rc) -> Rc { let sl = simplify_cost(l.clone()); let sr = simplify_cost(r.clone()); let simplified = match (*sl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sr, + CostExpr::CostConst { value: 0, .. } => sr.clone(), CostExpr::CostConst { value: a, .. } => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), CostExpr::CostConst { value: b, .. } => { if (a.clone() > b.clone()) { - sl + sl.clone() } else { - sr + sr.clone() } } _ => Rc::new(CostExpr::CostMax { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, _ => match (*sr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => sl, + CostExpr::CostConst { value: 0, .. } => sl.clone(), _ => Rc::new(CostExpr::CostMax { - left: sl, - right: sr, + left: sl.clone(), + right: sr.clone(), }), }, }; @@ -7849,7 +7864,7 @@ pub fn simplify_cost(expr: Rc) -> Rc { _ => Rc::new(CostExpr::CostSum { binder: b.clone(), upper: u.clone(), - body: sbd, + body: sbd.clone(), }), } } @@ -7861,8 +7876,8 @@ pub fn simplify_cost(expr: Rc) -> Rc { base: b.clone(), argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -7911,23 +7926,23 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { let nl = normalize_asymptotic(l.clone()); let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl + nl.clone() } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr, + CostExpr::CostConst { value: 0, .. } => nr.clone(), CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr, + _ => nr.clone(), }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostAdd { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7939,23 +7954,23 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { let nl = normalize_asymptotic(l.clone()); let nr = normalize_asymptotic(r.clone()); if (nl.clone() == nr.clone()) { - nl + nl.clone() } else { match (*nl.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nr, + CostExpr::CostConst { value: 0, .. } => nr.clone(), CostExpr::CostConst { value: _, .. } => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), CostExpr::CostConst { value: _, .. } => { Rc::new(CostExpr::CostConst { value: 1 }) } - _ => nr, + _ => nr.clone(), }, _ => match (*nr.clone()).clone() { - CostExpr::CostConst { value: 0, .. } => nl, - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: 0, .. } => nl.clone(), + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostMax { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7970,15 +7985,15 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nr, + CostExpr::CostConst { value: _, .. } => nr.clone(), _ => match (*nr.clone()).clone() { CostExpr::CostConst { value: 0, .. } => { Rc::new(CostExpr::CostConst { value: 0 }) } - CostExpr::CostConst { value: _, .. } => nl, + CostExpr::CostConst { value: _, .. } => nl.clone(), _ => Rc::new(CostExpr::CostMul { - left: nl, - right: nr, + left: nl.clone(), + right: nr.clone(), }), }, } @@ -7995,11 +8010,11 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { Rc::new(CostExpr::CostConst { value: 0 }) } _ => match (*u.clone()).clone() { - SizeExpr::SizeConst { value: _, .. } => nbd, + SizeExpr::SizeConst { value: _, .. } => nbd.clone(), _ => Rc::new(CostExpr::CostSum { binder: b.clone(), upper: u.clone(), - body: nbd, + body: nbd.clone(), }), }, } @@ -8012,8 +8027,8 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { base: b.clone(), argument: a.clone(), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -8220,7 +8235,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { }) } else { if ((unique.clone().len() as i64) == 1) { - match unique.first().cloned() { + match unique.clone().first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( v1_rt::rc_empty_map::(), @@ -8236,7 +8251,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { } } else { { - let indexed = unique.iter().cloned().fold( + let indexed = unique.clone().iter().cloned().fold( Rc::new(Legend { substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), @@ -8288,13 +8303,13 @@ pub fn substitute_size(size: Rc, legend: Rc>) Some(short) => Rc::new(SizeExpr::SizeVar { name: short.clone(), }), - None => size, + None => size.clone(), }, SizeExpr::SizeVar { name: n, .. } => match v1_rt::map_get(&legend, n.clone()) { Some(short) => Rc::new(SizeExpr::SizeVar { name: short.clone(), }), - None => size, + None => size.clone(), }, SizeExpr::SizeAdd { left: l, right: r, .. @@ -8308,7 +8323,7 @@ pub fn substitute_size(size: Rc, legend: Rc>) left: substitute_size(l.clone(), legend.clone()), right: substitute_size(r.clone(), legend.clone()), }), - SizeExpr::SizeConst { value: _, .. } => size, + SizeExpr::SizeConst { value: _, .. } => size.clone(), } }) } @@ -8316,7 +8331,7 @@ pub fn substitute_size(size: Rc, legend: Rc>) pub fn substitute_cost(expr: Rc, legend: Rc>) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.clone()).clone() { - CostExpr::CostConst { value: _, .. } => expr, + CostExpr::CostConst { value: _, .. } => expr.clone(), CostExpr::CostAdd { left: l, right: r, .. } => Rc::new(CostExpr::CostAdd { @@ -8353,8 +8368,8 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) base: b.clone(), argument: substitute_size(a.clone(), legend.clone()), }), - CostExpr::CostExtern { name: _, .. } => expr, - CostExpr::CostUnknown { reason: _, .. } => expr, + CostExpr::CostExtern { name: _, .. } => expr.clone(), + CostExpr::CostUnknown { reason: _, .. } => expr.clone(), } }) } @@ -8364,7 +8379,7 @@ pub fn classify_complexity(expr: Rc) -> String { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); let legend = build_legend(size_names); - let substituted = substitute_cost(normalized, legend.substitution.clone()); + let substituted = substitute_cost(normalized.clone(), legend.substitution.clone()); v1_rt::concat(format_cost_class(substituted), legend.suffix.clone()) } } @@ -8569,7 +8584,7 @@ pub fn cost_of_expr( let fname = expr_call_func_at(texpr.clone(), si.clone()); let callee_result = match v1_rt::map_get(&func_index, fname.clone()) { Some(entry) => get_or_compute_summary( - fname, + fname.clone(), func_index.clone(), scc_index.clone(), table, @@ -8609,13 +8624,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8626,13 +8641,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*args_result.summary.clone().work).clone(), - (*callee_result.summary.clone().work).clone(), + work: cost_seq( + args_result.summary.clone().work.clone(), + callee_result.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*args_result.summary.clone().span).clone(), - (*callee_result.summary.clone().span).clone(), + span: cost_seq( + args_result.summary.clone().span.clone(), + callee_result.summary.clone().span.clone(), ), output_size: callee_result.summary.clone().output_size.clone(), certainty: callee_result.summary.clone().certainty.clone(), @@ -8655,7 +8670,7 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(recv, si.clone()); + let size = receiver_size_var(recv.clone(), si.clone()); let binder = size_binder_name(size.clone()); let method_cost_result = if (ms.clone() == None) { None @@ -8673,7 +8688,7 @@ pub fn cost_of_expr( pc, recv_r.clone(), mc_args.clone(), - size, + size.clone(), binder, func_index.clone(), scc_index.clone(), @@ -8704,7 +8719,7 @@ pub fn cost_of_expr( match method_cost_result { Some(result) => result.clone(), _ => { - let args_result = mc_args.iter().cloned().fold( + let args_result = mc_args.clone().iter().cloned().fold( Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), @@ -8726,13 +8741,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, @@ -8795,7 +8810,7 @@ pub fn cost_of_expr( arm_body(arm_node.clone()), func_index.clone(), scc_index.clone(), - (*acc.result).clone().table.clone(), + acc.result.clone().table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone(), @@ -8803,13 +8818,13 @@ pub fn cost_of_expr( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par)))))))( - (*(*acc.result).clone().summary.clone().work).clone(), - (*ar.summary.clone().work).clone(), + work: cost_par( + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_par)))))))( - (*(*acc.result).clone().summary.clone().span).clone(), - (*ar.summary.clone().span).clone(), + span: cost_par( + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), ), output_size: ar.summary.clone().output_size.clone(), certainty: ar.summary.clone().certainty.clone(), @@ -8831,31 +8846,25 @@ pub fn cost_of_expr( ), span: cost_conditional( s_r.summary.clone().span.clone(), - Rc::new(vec![ - (*arms_accum.result).clone().summary.clone().span.clone() - ]), + Rc::new(vec![arms_accum.result.clone().summary.clone().span.clone()]), ), - output_size: (*arms_accum.result) + output_size: arms_accum + .result .clone() .summary .clone() .output_size .clone(), - certainty: (*arms_accum.result) - .clone() - .summary - .clone() - .certainty - .clone(), + certainty: arms_accum.result.clone().summary.clone().certainty.clone(), }), - table: (*arms_accum.result).clone().table.clone(), + table: arms_accum.result.clone().table.clone(), }) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); let t = if_then_branch(texpr.clone()); let c_r = cost_of_expr( - c, + c.clone(), func_index.clone(), scc_index.clone(), table, @@ -8944,13 +8953,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*v_r.summary.clone().work).clone(), - (*b_r.summary.clone().work).clone(), + work: cost_seq( + v_r.summary.clone().work.clone(), + b_r.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*v_r.summary.clone().span).clone(), - (*b_r.summary.clone().span).clone(), + span: cost_seq( + v_r.summary.clone().span.clone(), + b_r.summary.clone().span.clone(), ), output_size: b_r.summary.clone().output_size.clone(), certainty: b_r.summary.clone().certainty.clone(), @@ -8958,7 +8967,7 @@ pub fn cost_of_expr( table: b_r.table.clone(), }) } - None => v_r, + None => v_r.clone(), } } ExprData::ExprBlock => texpr.children.clone().iter().cloned().fold( @@ -8983,13 +8992,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().work).clone(), - (*sr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + sr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().span).clone(), - (*sr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + sr.summary.clone().span.clone(), ), output_size: sr.summary.clone().output_size.clone(), certainty: sr.summary.clone().certainty.clone(), @@ -9019,13 +9028,13 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let size = receiver_size_var(c, si.clone()); + let size = receiver_size_var(c.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let loop_work = cost_loop(binder, size, bd_r.summary.clone().work.clone()); + let loop_work = cost_loop(binder, size.clone(), bd_r.summary.clone().work.clone()); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), - span: cost_seq(c_r.summary.clone().span.clone(), loop_work), + span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), @@ -9054,13 +9063,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9091,13 +9100,13 @@ pub fn cost_of_expr( ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().work).clone(), - (*cr.summary.clone().work).clone(), + work: cost_seq( + acc.summary.clone().work.clone(), + cr.summary.clone().work.clone(), ), - span: Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(cost_seq)))))))( - (*acc.summary.clone().span).clone(), - (*cr.summary.clone().span).clone(), + span: cost_seq( + acc.summary.clone().span.clone(), + cr.summary.clone().span.clone(), ), output_size: cr.summary.clone().output_size.clone(), certainty: cr.summary.clone().certainty.clone(), @@ -9173,7 +9182,7 @@ pub fn get_or_compute_summary( None => Rc::new(vec![]), }; let is_scc = ((scc_members.clone().len() as i64) > 1); - let bounded = match target { + let bounded = match target.clone() { Some(t) => { if is_scc { Rc::new(ComplexitySummary { @@ -9185,7 +9194,7 @@ pub fn get_or_compute_summary( span: bounded_scc_cost( t.clone(), result.summary.clone().span.clone(), - scc_members, + scc_members.clone(), ), output_size: result.summary.clone().output_size.clone(), certainty: Certainty::Conservative, @@ -9215,13 +9224,10 @@ pub fn get_or_compute_summary( output_size: bounded.output_size.clone(), certainty: bounded.certainty.clone(), }); - let final_table = cache_summary( - result.table.clone(), - func_name.clone(), - simplified.clone(), - ); + let final_table = + cache_summary(result.table.clone(), func_name.clone(), simplified.clone()); Rc::new(SummaryResult { - summary: simplified, + summary: simplified.clone(), table: final_table, }) } @@ -9501,9 +9507,9 @@ pub fn max_path_descending( None => 0, }; let branch_max = if (then_count.clone() > else_count.clone()) { - then_count + then_count.clone() } else { - else_count + else_count.clone() }; (cond_count + branch_max) } @@ -9714,8 +9720,7 @@ pub fn build_complexity_report( ) { Some(_) => acc.clone(), None => { - if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) - > 0) + if (max_path_self_calls(entry.body.clone(), entry.name.clone(), si.clone()) > 0) { { let pattern = classify_recursion_pattern( @@ -9840,7 +9845,7 @@ pub fn build_complexity_report( }, ); let evicted_table = unique_callees.clone().iter().cloned().fold( - (*sr.table).clone(), + sr.table.clone(), |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), @@ -9860,9 +9865,9 @@ pub fn build_complexity_report( None => 0, }; let final_table = if (self_fan_in.clone() <= 0) { - evict_summary(Rc::new(evicted_table.clone()), func_name.clone()) + evict_summary(evicted_table.clone(), func_name.clone()) } else { - Rc::new(evicted_table.clone()) + evicted_table.clone() }; Rc::new(TopoBuildAcc { table: final_table.clone(), @@ -9875,7 +9880,7 @@ pub fn build_complexity_report( None => acc.clone(), }, ); - let structural_bounds = analyze_structural_bounds(func_entries.clone(), si); + let structural_bounds = analyze_structural_bounds(func_entries.clone(), si.clone()); Rc::new(ComplexityReport { function_classes: result.classes.clone(), violations: result.violations.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 9858b6c2687..b45fa7ffa52 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -88,8 +88,8 @@ pub use crate::v1_compiler_languages::{ pub use crate::v1_compiler_languages::{ItemKeywords, TestConventions, VisibilitySpec}; pub use crate::v1_compiler_ownership::OwnershipProof; pub use crate::v1_compiler_ownership::{ - analyze_ownership, analyze_single_fold, build_movable_set, build_move_site_licenses, - build_read_only_params, collect_callable_refs, move_site_key, + analyze_ownership, analyze_single_fold, build_movable_set, build_read_only_params, + collect_callable_refs, }; pub use crate::v1_compiler_resolve::get_exported_names; pub use crate::v1_compiler_runtime_rust::rust_runtime_source; @@ -267,7 +267,7 @@ pub fn render_rust_type_without_applied_binding( ) { { let elem_name = - authored_name_at(source_indices.clone(), elem_node); + authored_name_at(source_indices.clone(), elem_node.clone()); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("Set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -516,7 +516,8 @@ pub fn is_host_text_carrier_type( if (nm.clone() == "String".to_string()) { true } else { - if ((nm.clone() == "FreeMonoid".to_string()) || (nm == "List".to_string())) { + if ((nm.clone() == "FreeMonoid".to_string()) || (nm.clone() == "List".to_string())) + { (rust_host_text_carrier_elem_name(n.clone(), source_indices.clone()) == "Char".to_string()) } else { @@ -637,7 +638,7 @@ pub fn type_leaf_name_for_collapse( if (a.clone() == "".to_string()) { n.name.clone() } else { - a + a.clone() } } } @@ -833,7 +834,7 @@ pub fn render_rust_applied_type( if ((n.children.clone().len() as i64) == 0) { match rust_seed_host_container_base(base_name.clone(), corpus_repr.clone()) { Some(host) => host.clone(), - None => rust_named_type_base(base_name, corpus_repr.clone()), + None => rust_named_type_base(base_name.clone(), corpus_repr.clone()), } } else { { @@ -842,7 +843,7 @@ pub fn render_rust_applied_type( Some(host) => host.clone(), None => rust_applied_type_base(base_name.clone(), corpus_repr.clone()), }; - let peel = is_parametric_opaque_type_by_name(env.clone(), base_name); + let peel = is_parametric_opaque_type_by_name(env.clone(), base_name.clone()); let args = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { @@ -952,7 +953,7 @@ pub fn render_rust_decl_type( shared_types.clone(), corpus_repr.clone(), source_indices.clone(), - variant_to_enum, + variant_to_enum.clone(), env.clone(), ), None => { @@ -970,7 +971,7 @@ pub fn render_rust_decl_type( __found }) { - to_pascal(name) + to_pascal(name.clone()) } else { if (((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -985,14 +986,16 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop == None)) + && (applied_prop.clone() == None)) && v1_rt::set_contains(&shared_types, name.clone())) { { - let rendered = - rust_render_type_leaf_name(name.clone(), variant_to_enum); + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); render_rust_shared_type_if_needed( - name, + name.clone(), rendered, shared_types.clone(), ) @@ -1006,7 +1009,7 @@ pub fn render_rust_decl_type( { render_rust_shared_type_if_needed( name.clone(), - name, + name.clone(), shared_types.clone(), ) } else { @@ -1056,7 +1059,7 @@ pub fn render_rust_decl_type( __result }); let applied_ty = if (name.clone() == tuple_type_name()) { - render_tuple_parts(arg_list, RenderTarget::Rust) + render_tuple_parts(arg_list.clone(), RenderTarget::Rust) } else { if node_is_keyed_collection( n.clone(), @@ -1079,7 +1082,9 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1087,7 +1092,9 @@ pub fn render_rust_decl_type( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1110,7 +1117,9 @@ pub fn render_rust_decl_type( base, "<".to_string(), ), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ), @@ -1119,7 +1128,9 @@ pub fn render_rust_decl_type( v1_rt::concat( v1_rt::concat( v1_rt::concat(base, "<".to_string()), - arg_list.join(&", ".to_string()), + arg_list + .clone() + .join(&", ".to_string()), ), ">".to_string(), ) @@ -1127,7 +1138,7 @@ pub fn render_rust_decl_type( } }; render_rust_shared_type_if_needed( - name, + name.clone(), applied_ty, shared_types.clone(), ) @@ -1159,7 +1170,7 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { Some(b) => b.clone(), None => { let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { + match lookup_type_by_name(env.clone(), name.clone()) { Some(b) => b.clone(), None => return false, } @@ -1225,7 +1236,7 @@ pub fn render_rust_fn_sig_type( && !is_container_type(name.clone())) && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) { - render_rust_shared_type_if_needed(name.clone(), name, shared_types.clone()) + render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) } else { if ((generic_param_names.clone().len() as i64) > 0) { render_rust_decl_type( @@ -1274,7 +1285,7 @@ pub fn render_rust_fn_sig_type_applied_binding( { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types, ) } else { @@ -1313,10 +1324,10 @@ pub fn alias_rhs_container_arg( if node_is_collection(rt.clone(), source_indices) { rt.clone() } else { - arg + arg.clone() } } - _ => arg, + _ => arg.clone(), } } @@ -1353,7 +1364,7 @@ pub fn render_rust_alias_rhs_type( __found }) { - to_pascal(name) + to_pascal(name.clone()) } else { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -1372,10 +1383,12 @@ pub fn render_rust_alias_rhs_type( match rust_opaque_kernel_alias_carrier(name.clone()) { Some(carrier) => carrier.clone(), None => { - let rendered = - rust_render_type_leaf_name(name.clone(), variant_to_enum); + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); render_rust_shared_type_if_needed( - name, + name.clone(), rendered, shared_types.clone(), ) @@ -1388,6 +1401,11 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { + if let Some(host) = + rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) + { + return host; + } { let local_mod = module_to_filename(module_name.clone()); let def_mod = alias_rhs_rust_qualify_module_filename( @@ -1422,7 +1440,7 @@ pub fn render_rust_alias_rhs_type( }; let peel = is_parametric_opaque_type_base( name.clone(), - def_mod, + def_mod.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone(), @@ -1474,12 +1492,12 @@ pub fn render_rust_alias_rhs_type( v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), ">".to_string(), ); - if (v1_rt::set_contains(&shared_types, name) + if (v1_rt::set_contains(&shared_types, name.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, applied_ty) + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty + applied_ty.clone() } } } else { @@ -1669,7 +1687,8 @@ pub fn rust_nominal_ord_type_ref_eligible( (((((elem_node.children.clone().len() as i64) == 0) && ((elem_node.params.clone().len() as i64) == 0)) && (elem_node.connective.clone() == Connective::NoConnective)) - && ((type_name.clone() == "Symbol".to_string()) || (type_name == "DiffId".to_string()))) + && ((type_name.clone() == "Symbol".to_string()) + || (type_name.clone() == "DiffId".to_string()))) } } @@ -1909,7 +1928,7 @@ pub fn rust_string_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name, + naming_name.clone(), )) } } @@ -2012,7 +2031,7 @@ pub fn rust_internal_policy_for_naming( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), - naming_name, + naming_name.clone(), )) } } @@ -2073,7 +2092,7 @@ pub fn resolve_wire_serde_policy_from_encoding_node( } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantEncoding: ".to_string(), - encoding_name, + encoding_name.clone(), )) } } @@ -2126,7 +2145,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( "wire_contract: VariantEncoding alias chain exceeded recursion limit".to_string(), ); } else { - match wire_contract_item.clone() { + match wire_contract_item { None => { break rust_tagged_object_policy(); } @@ -2548,7 +2567,7 @@ pub fn resolve_local_coproduct_wire_policy( None } else { if ((contracts.clone().len() as i64) == 1) { - match contracts.first().cloned() { + match contracts.clone().first().cloned() { Some(contract) => match coproduct_wire_contract_encoding( contract.clone(), source_indices.clone(), @@ -2589,7 +2608,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); Rc::new({ @@ -2606,10 +2625,8 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>, item: Rc| { - let item_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), - item.clone(), - ); + let item_name = + authored_name_at(tm.type_env.clone().source_indices.clone(), item.clone()); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), item_name.clone(), @@ -2645,7 +2662,7 @@ pub fn build_scoped_data_item_index( ) -> Rc>>>> { { let module_name = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ); let local = Rc::new({ @@ -2665,7 +2682,7 @@ pub fn build_scoped_data_item_index( insert_scoped_data_item( acc, authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), item.clone(), ), item.clone(), @@ -2676,10 +2693,10 @@ pub fn build_scoped_data_item_index( .iter() .cloned() .fold( - local, + local.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at( - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), imp.clone(), ); if import_is_all(imp.clone()) { @@ -2687,7 +2704,7 @@ pub fn build_scoped_data_item_index( } else { import_specific_names_at( imp.clone(), - (*typed_module.type_env).clone().source_indices.clone(), + typed_module.type_env.clone().source_indices.clone(), ) .iter() .cloned() @@ -2722,7 +2739,7 @@ pub fn augment_scoped_data_item_index_with_imports( data_items: Rc>>, ) -> Rc>>>> { imports.iter().cloned().fold( - scoped, + scoped.clone(), |acc: Rc>>>>, imp: Rc| { let import_path = authored_name_at(source_indices.clone(), imp.clone()); if import_is_all(imp.clone()) { @@ -2822,7 +2839,7 @@ pub fn emit_rust_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2845,8 +2862,8 @@ pub fn emit_rust_block_stmts( .skip(1 as usize) .collect::>(), ); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -2870,7 +2887,7 @@ pub fn emit_rust_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2886,7 +2903,7 @@ pub fn emit_rust_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -2904,16 +2921,16 @@ pub fn emit_rust_init_block_stmts( ExprData::ExprLet => true, _ => false, }; - let line = if is_let.clone() { - raw_line.clone() + let line = if is_let { + raw_line } else { - v1_rt::concat(raw_line.clone(), ";".to_string()) + v1_rt::concat(raw_line, ";".to_string()) }; let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -3220,7 +3237,7 @@ pub fn build_shared_types( __result }); collection_keys.iter().cloned().fold( - user_shared, + user_shared.clone(), |acc: Rc>, key: String| { let pascal = to_pascal(key.clone()); v1_rt::rc_set_insert(acc, pascal.clone()) @@ -3234,14 +3251,12 @@ pub struct OwnershipProofEntry { pub name: String, pub proof: Rc, pub param_names: Rc>, - pub move_sites: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipBuildResult { pub ownership_index: Rc>>>, pub read_only_params_index: Rc>>>, - pub move_sites_index: Rc>>>, } pub fn build_ownership_results(modules: Rc>>) -> Rc { @@ -3265,7 +3280,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc>>) -> Rc>>) -> Rc>, >(), - move_sites_index: v1_rt::rc_empty_map::>>(), }), |acc: Rc, entry: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/05_emit_rust.dag:78228:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let read_only = if v1_rt::set_contains( &callable_set, @@ -3357,7 +3367,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>) -> Rc) -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: ownership.move_sites_index.clone(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: ownership.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3418,7 +3421,7 @@ pub fn emit_rust(typed: Rc) -> Rc { if ((workflow_default_diags.clone().len() as i64) > 0) { return Rc::new(EmitResult { files: Rc::new(vec![]), - diagnostics: workflow_default_diags, + diagnostics: workflow_default_diags.clone(), }); } let svc_module_map = typed.modules.clone().iter().cloned().fold( @@ -3434,7 +3437,7 @@ pub fn emit_rust(typed: Rc) -> Rc { __result }); let mod_filename = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); svc_items.clone().iter().cloned().fold( @@ -3443,7 +3446,7 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::rc_map_insert( a, authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), svc.clone(), ), mod_filename.clone(), @@ -3479,7 +3482,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for tm in typed.modules.clone().iter().cloned() { __result.push(emit_test_file( authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), Rc::new({ @@ -3487,7 +3490,7 @@ pub fn emit_rust(typed: Rc) -> Rc { for p in test_projections.clone().iter().cloned() { if (p.module_name.clone() == authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )) { @@ -3514,10 +3517,8 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -3532,11 +3533,11 @@ pub fn emit_rust(typed: Rc) -> Rc { }; let cargo = emit_cargo_toml(crate_name.clone(), has_services.clone()); let main_file = emit_main_rs( - workflow_funcs, + workflow_funcs.clone(), typed.modules.clone(), has_services.clone(), - crate_name, - svc_module_map, + crate_name.clone(), + svc_module_map.clone(), ); let rt_file = emit_v2_rt_module(); let compiler_tests_file = if has_pipeline.clone() { @@ -3544,7 +3545,7 @@ pub fn emit_rust(typed: Rc) -> Rc { } else { Rc::new(vec![]) }; - let dry_run_file = if has_services { + let dry_run_file = if has_services.clone() { Rc::new(vec![emit_dry_run_module()]) } else { Rc::new(vec![]) @@ -3553,10 +3554,13 @@ pub fn emit_rust(typed: Rc) -> Rc { v1_rt::concat(module_files, Rc::new(vec![rt_file])), dry_run_file, ); - let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline); + let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline.clone()); let files = v1_rt::concat( v1_rt::concat( - v1_rt::concat(Rc::new(vec![cargo, lib_file, main_file]), all_mod_files), + v1_rt::concat( + Rc::new(vec![cargo, lib_file, main_file]), + all_mod_files.clone(), + ), compiler_tests_file, ), test_files, @@ -3665,8 +3669,6 @@ pub fn emit_module( movable: base_info.movable.clone(), variant_to_enum: base_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: base_info.move_sites_index.clone(), - move_sites: base_info.move_sites.clone(), read_only_params_index: base_info.read_only_params_index.clone(), read_only_params: v1_rt::rc_empty_set::(), corpus_repr: base_info.corpus_repr.clone(), @@ -3677,7 +3679,7 @@ pub fn emit_module( emit_module_full( typed_module.clone(), registry, - emit_info, + emit_info.clone(), shared_types, v1_rt::rc_empty_map::(), build_data_item_index(Rc::new(vec![typed_module.clone()])), @@ -3695,12 +3697,12 @@ pub fn build_module_export_sets( v1_rt::rc_empty_map::>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); let exported = get_exported_names( tm.module.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -3725,26 +3727,26 @@ pub fn emit_module_full( module_index: Rc, ) -> Rc { { - let m = (*typed_module.module).clone(); + let m = typed_module.module.clone(); let scope = module_emit_scope(typed_module.clone()); let scoped_data_items = augment_scoped_data_item_index_with_imports( build_scoped_data_item_index(typed_module.clone(), data_items.clone()), contracts_imports_for_module( - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), data_items.clone(), ); let prelude_imported_names = Rc::new({ let mut __result = Vec::new(); - for imp in module_imports(Rc::new(m.clone())).iter().cloned() { + for imp in module_imports(m.clone()).iter().cloned() { __result.extend( (*import_specific_names_at( imp.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) .iter() .cloned(), @@ -3761,11 +3763,11 @@ pub fn emit_module_full( if ((is_type_def_item(item.clone()) || is_type_alias_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) || is_type_decl_item( item.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __result.push(item); @@ -3781,22 +3783,22 @@ pub fn emit_module_full( __result }); let imports_str = emit_imports( - module_imports(Rc::new(m.clone())), + module_imports(m.clone()), emit_info.clone(), registry.clone(), local_type_names, export_sets.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ); let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n".to_string(), imports_str) + v1_rt::concat("\n".to_string(), imports_str.clone()) }; let this_mod_filename = - module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone())); + module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let all_svc_names = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -3852,7 +3854,10 @@ pub fn emit_module_full( let svc_imports_str = if ((extern_svc_imports.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat("\n".to_string(), extern_svc_imports.join(&"\n".to_string())) + v1_rt::concat( + "\n".to_string(), + extern_svc_imports.clone().join(&"\n".to_string()), + ) }; let local_enum_uses = Rc::new({ let mut __result = Vec::new(); @@ -3901,23 +3906,23 @@ pub fn emit_module_full( } __result }); - let module_import_items = module_imports(Rc::new(m.clone())); - let this_module_name = Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()); + let module_import_items = module_imports(m.clone()); + let this_module_name = authored_name(scope.type_env.clone(), m.clone()); let wire_context_items = v1_rt::concat( typed_module.items.clone(), contracts_items_for_module( this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); let wire_context_imports = v1_rt::concat( module_import_items, contracts_imports_for_module( - this_module_name, + this_module_name.clone(), typed_modules.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), module_index.clone(), ), ); @@ -3925,27 +3930,31 @@ pub fn emit_module_full( wire_context_items.clone(), wire_context_imports.clone(), local_coproduct_names, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat(coproduct_wire_contract_validations, "\n\n".to_string()) + v1_rt::concat( + coproduct_wire_contract_validations.clone(), + "\n\n".to_string(), + ) }; let local_uses_str = if ((local_enum_uses.clone().len() as i64) == 0) { "".to_string() } else { - v1_rt::concat("\n".to_string(), local_enum_uses.join(&"\n".to_string())) + v1_rt::concat( + "\n".to_string(), + local_enum_uses.clone().join(&"\n".to_string()), + ) }; let wire_contract_item = Rc::new({ let mut __result = Vec::new(); for i in wire_context_items.clone().iter().cloned() { if (is_data_def_item(i.clone()) - && (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - i.clone(), - ) == "wire_contract".to_string())) + && (authored_name_at(scope.type_env.clone().source_indices.clone(), i.clone()) + == "wire_contract".to_string())) { __result.push(i); } @@ -3959,7 +3968,7 @@ pub fn emit_module_full( for item in typed_module.items.clone().iter().cloned() { __result.push(emit_typed_item( item.clone(), - Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()), + authored_name(scope.type_env.clone(), m.clone()), registry.clone(), scope.clone(), shared_types.clone(), @@ -3981,22 +3990,22 @@ pub fn emit_module_full( let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = module_to_filename(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone())); + let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone() == "main".to_string()) { "main_mod".to_string() } else { - raw_filename + raw_filename.clone() }; - let module_attrs = if (Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m.clone()) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) == "std.error_primitives".to_string()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() }; - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(Rc::new(authored_name)))))))((*scope.type_env).clone(), m)), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs), prelude), imports_section), svc_imports_str), local_uses_str), "\n\n".to_string()), coproduct_wire_contract_validation_section), items_str), phantom_section), "\n".to_string()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), filename), @@ -4114,7 +4123,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ); match v1_rt::map_get(&acc, nm.clone()) { @@ -4127,7 +4136,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )); match v1_rt::map_get(&acc, fname.clone()) { @@ -4202,10 +4211,7 @@ pub fn module_name_from_filename( Some(mods) => Rc::new({ let mut __result = Vec::new(); for tm in mods.clone().iter().cloned() { - __result.push(authored_name_at( - source_indices.clone(), - tm.module.clone(), - )); + __result.push(authored_name_at(source_indices.clone(), tm.module.clone())); } __result }) @@ -4419,7 +4425,7 @@ pub fn imported_name_is_non_emittable_type( module_index.clone(), ) && (type_name_is_rust_importable_in_module( name.clone(), - defining_module, + defining_module.clone(), typed_modules.clone(), registry, export_sets.clone(), @@ -4580,8 +4586,7 @@ pub fn reexport_source_module_name_with_visited( let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); - for imp in - module_imports(tm.module.clone()).iter().cloned() + for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; @@ -5028,7 +5033,7 @@ pub fn graph_type_import_module_filename( source_indices.clone(), module_index.clone(), ) { - mod_name + mod_name.clone() } else { match reexport_source_module_name( name.clone(), @@ -5039,7 +5044,7 @@ pub fn graph_type_import_module_filename( module_index.clone(), ) { Some(src) => module_to_filename(src.clone()), - None => mod_name, + None => mod_name.clone(), } } } @@ -5081,11 +5086,11 @@ pub fn variant_defining_module_filename_for_import( continue; } } else { - break fallback.clone(); + break fallback; } } None => { - break fallback.clone(); + break fallback; } } } @@ -5247,7 +5252,7 @@ pub fn reexport_variant_parent_in_import_module( loop { match reexport_source_module_name( variant_name.clone(), - import_module.clone(), + import_module, typed_modules.clone(), export_sets.clone(), source_indices.clone(), @@ -5328,7 +5333,7 @@ pub fn alias_rhs_rust_qualify_module_filename( source_indices.clone(), module_index.clone(), ) { - spell_mod + spell_mod.clone() } else { match module_name_from_filename( spell_mod.clone(), @@ -5345,9 +5350,9 @@ pub fn alias_rhs_rust_qualify_module_filename( module_index.clone(), ) { Some(src) => module_to_filename(src.clone()), - None => spell_mod, + None => spell_mod.clone(), }, - None => spell_mod, + None => spell_mod.clone(), } } } @@ -5582,7 +5587,7 @@ pub fn type_item_has_rust_nominal_shell_authority( && ((rhs.children.clone().len() as i64) > 0)) { alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -5603,9 +5608,9 @@ pub fn type_item_has_rust_nominal_shell_authority( rhs.clone(), ); (((rhs_name.clone() != item_text.clone()) - && (rhs_name != "".to_string())) + && (rhs_name.clone() != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -5684,7 +5689,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( def_module_name.clone(), module_imports(tm.module.clone()), module_emit_scope(tm.clone()), - registry.clone(), + registry, export_sets.clone(), typed_modules.clone(), source_indices.clone(), @@ -5775,7 +5780,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); (rhs_base_has_rust_type_authority_in_module( - name, + name.clone(), def_mod, module_name.clone(), imports.clone(), @@ -5839,7 +5844,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( module_index.clone(), ); rhs_base_has_rust_type_authority_in_module( - name, + name.clone(), def_mod, module_name.clone(), imports.clone(), @@ -5870,7 +5875,7 @@ pub fn is_self_referential_opaque_type_resolved( let item_text = authored_name_at(source_indices.clone(), item.clone()); let rhs = resolved_type(item.clone()); (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), rhs) == item_text)) + && (authored_name_at(source_indices.clone(), rhs.clone()) == item_text)) } } @@ -5955,9 +5960,9 @@ pub fn is_emittable_parametric_type_alias_item( ((rhs_name.clone() != item_text) && (((rhs.children.clone().len() as i64) > 0) || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name != "".to_string())) + && (rhs_name.clone() != "".to_string())) && alias_rhs_nominal_shell_has_rust_authority( - rhs, + rhs.clone(), module_name, imports, scope, @@ -6272,7 +6277,7 @@ pub fn emit_specific_import_block( __result }); let merged_direct_names = - unique_strings(v1_rt::concat(direct_names, local_parent_names)); + unique_strings(v1_rt::concat(direct_names.clone(), local_parent_names)); let type_direct_names = Rc::new({ let mut __result = Vec::new(); for n in merged_direct_names.clone().iter().cloned() { @@ -6293,7 +6298,7 @@ pub fn emit_specific_import_block( }); let other_direct_names = Rc::new({ let mut __result = Vec::new(); - for n in merged_direct_names.iter().cloned() { + for n in merged_direct_names.clone().iter().cloned() { if (is_import_graph_type_name( n.clone(), import_module.clone(), @@ -6388,7 +6393,7 @@ pub fn emit_specific_import_block( { let names_str = Rc::new({ let mut __result = Vec::new(); - for n in other_direct_names.iter().cloned() { + for n in other_direct_names.clone().iter().cloned() { __result.push(emit_import_name(n.clone(), registry.clone())); } __result @@ -6425,7 +6430,7 @@ pub fn emit_specific_import_block( __result }), if (other_direct_line.clone() != "".to_string()) { - Rc::new(vec![other_direct_line]) + Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) }, @@ -6519,7 +6524,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib }); let main_lines = if ((direct_lines.clone().len() as i64) > 0) { v1_rt::concat( - direct_lines, + direct_lines.clone(), Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { @@ -6579,7 +6584,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con }); let imported_enums = Rc::new({ let mut __result = Vec::new(); - for n in top_level.iter().cloned() { + for n in top_level.clone().iter().cloned() { if is_enum_in_summaries(type_summaries.clone(), n.clone()) { __result.push(n); } @@ -6590,7 +6595,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con let mut __result = Vec::new(); for en in Rc::new({ let mut __result = Vec::new(); - for en in imported_enums.iter().cloned() { + for en in imported_enums.clone().iter().cloned() { if (({ let mut __found = false; for p in parent_list.clone().iter().cloned() { @@ -7161,10 +7166,10 @@ pub fn emit_prelude(imported_names: Rc>) -> String { let variant_line = if (has_holds.clone() && has_violates.clone()) { "".to_string() } else { - if has_holds { + if has_holds.clone() { "\nuse crate::v1_rt::Witness::Violates;".to_string() } else { - if has_violates { + if has_violates.clone() { "\nuse crate::v1_rt::Witness::Holds;".to_string() } else { "\nuse crate::v1_rt::Witness::{Holds, Violates};".to_string() @@ -7203,18 +7208,18 @@ pub fn emit_typed_item( module_index: Rc, ) -> String { { - let env = (*scope.type_env).clone(); + let env = scope.type_env.clone(); let qualified_name = v1_rt::concat( v1_rt::concat(module_name.clone(), ".".to_string()), - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), ); - let item_text = authored_name(Rc::new(env.clone()), item.clone()); + let item_text = authored_name(env.clone(), item.clone()); if is_type_def_item(item.clone()) { emit_type_def_from_connective( item.clone(), emit_info.recursive_type_set.clone(), shared_types, - Rc::new(env), + env.clone(), emit_info.clone(), wire_contract_item, data_items, @@ -7237,7 +7242,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text) + rust_nominal_identity_carrier_def(item_text.clone()) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -7263,7 +7268,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), " = ".to_string(), ), @@ -7282,7 +7287,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), " = ".to_string(), ), @@ -7313,7 +7318,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { - rust_nominal_identity_carrier_def(item_text) + rust_nominal_identity_carrier_def(item_text.clone()) } else { match rust_seed_host_container_base( item_text.clone(), @@ -7344,7 +7349,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), @@ -7356,7 +7361,7 @@ pub fn emit_typed_item( ), Rc::new({ let mut __result = Vec::new(); - for n in generic_names.iter().cloned() { + for n in generic_names.clone().iter().cloned() { __result.push(to_pascal(n.clone())); } __result @@ -7399,14 +7404,16 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( "std::marker::PhantomData<".to_string(), - rust_phantom_marker_inner(unused_params), + rust_phantom_marker_inner( + unused_params.clone(), + ), ), ">".to_string(), ) } else { render_rust_alias_rhs_type( - alias_rhs, - generic_names, + alias_rhs.clone(), + generic_names.clone(), shared_types, emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -7434,7 +7441,7 @@ pub fn emit_typed_item( ), " ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), @@ -7472,12 +7479,12 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), }; let item_is_tco = is_tco_eligible( - authored_name(Rc::new(env.clone()), item.clone()), + authored_name(env.clone(), item.clone()), item.body.clone().clone().unwrap(), registry.clone(), env.source_indices.clone(), ); - let fn_read_only = if item_is_tco.clone() { + let fn_read_only = if item_is_tco { v1_rt::rc_empty_set::() } else { match v1_rt::map_get( @@ -7488,17 +7495,6 @@ pub fn emit_typed_item( None => v1_rt::rc_empty_set::(), } }; - let fn_move_sites = if item_is_tco { - v1_rt::rc_empty_map::() - } else { - match v1_rt::map_get( - &emit_info.move_sites_index.clone(), - qualified_name, - ) { - Some(m) => m.clone(), - None => v1_rt::rc_empty_map::(), - } - }; let fn_emit_info = Rc::new(EmitGraphInfo { type_summaries: emit_info.type_summaries.clone(), recursive_type_set: emit_info.recursive_type_set.clone(), @@ -7511,15 +7507,13 @@ pub fn emit_typed_item( movable: fn_movable, variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: fn_move_sites, read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: fn_read_only, corpus_repr: emit_info.corpus_repr.clone(), }); let is_effectful = match lookup_item( registry.clone(), - authored_name(Rc::new(env), item.clone()), + authored_name(env.clone(), item.clone()), ) { Some(info) => { (((info.service_names.clone().len() as i64) > 0) @@ -7529,7 +7523,7 @@ pub fn emit_typed_item( }; if is_effectful { emit_func_def( - item_text, + item_text.clone(), item.params.clone(), resolved_type(item.clone()), item.uses.clone(), @@ -7541,7 +7535,7 @@ pub fn emit_typed_item( ) } else { emit_fn_def( - item_text, + item_text.clone(), item.params.clone(), resolved_type(item.clone()), item.body.clone().clone().unwrap(), @@ -7555,7 +7549,7 @@ pub fn emit_typed_item( } else { if is_data_def_item(item.clone()) { emit_data_def( - item_text, + item_text.clone(), item.type_annotation.clone().clone().unwrap(), item.body.clone().clone().unwrap(), registry.clone(), @@ -7571,7 +7565,7 @@ pub fn emit_typed_item( registry.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env), + env.clone(), ) } else { if is_resource_def_item(item.clone()) { @@ -7579,13 +7573,13 @@ pub fn emit_typed_item( item.clone(), shared_types, emit_info.corpus_repr.clone(), - Rc::new(env), + env.clone(), ) } else { v1_rt::concat( v1_rt::concat( "compile_error!(\"unhandled item: ".to_string(), - item_text, + item_text.clone(), ), "\");".to_string(), ) @@ -7599,15 +7593,6 @@ pub fn emit_typed_item( } } -pub fn needs_box_wrapping_shared_dominates() -> String { - thread_local! { - static CACHED: String = { - "A shared (Rc-rendered) type NEVER needs Box: Rc is already the cycle-breaking indirection, so Box> is a double wrap that no committed seed ever carried. shared_types must dominate the recursive_types check — the old ordering short-circuited recursive->Box first, which was benign only while emit-time recursive_types stayed module-local; once build_type_env propagated imported recursive types (B1), every Rc field of Node/TypeEnv/... would have double-wrapped.".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn needs_box_wrapping( mut n: Rc, mut recursive_types: Rc>, @@ -7615,32 +7600,35 @@ pub fn needs_box_wrapping( mut source_indices: Rc>>, ) -> bool { loop { + // HAND-PATCH (seed two-step): shared (Rc-rendered) types never need Box + // — shared_types dominates the recursive check. Replaced by regen's + // true emission of the reordered dag source in the convergence commit. let name = authored_name_at(source_indices.clone(), n.clone()); if v1_rt::set_contains(&shared_types, name.clone()) { break false; - } else { - if v1_rt::set_contains(&recursive_types, name.clone()) { - break true; - } else { - if ((n.children.clone().len() as i64) == 0) { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { - break false; - } else { - break v1_rt::set_contains(&recursive_types, name.clone()); - } + } + if v1_rt::set_contains(&recursive_types, name.clone()) { + break true; + } + if ((n.children.clone().len() as i64) == 0) { + { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + break false; } else { - let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); - if is_optional.clone() { - { - let __tco_0 = with_required_cardinality(n); - n = __tco_0; - continue; - } - } else { - break false; - } + break v1_rt::set_contains(&recursive_types, name.clone()); } } + } else { + let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); + if is_optional { + { + let __tco_0 = with_required_cardinality(n); + n = __tco_0; + continue; + } + } else { + break false; + } } } } @@ -7752,7 +7740,7 @@ pub fn function_type_params_have_collision(type_params: Rc>>) -> bo } __result }); - ((names.clone().len() as i64) > (unique_strings(names).len() as i64)) + ((names.clone().len() as i64) > (unique_strings(names.clone()).len() as i64)) } } @@ -7781,7 +7769,7 @@ pub fn emit_type_def_from_connective( __result }); emit_struct_from_children( - item_text, + item_text.clone(), type_params, generic_param_names, item.children.clone(), @@ -7814,7 +7802,7 @@ pub fn emit_type_def_from_connective( rust_visibility_prefix(), "type ".to_string(), ), - item_text, + item_text.clone(), ), type_params, ), @@ -7846,7 +7834,7 @@ pub fn emit_type_def_from_connective( ) { Some(local_policy) => local_policy.clone(), None => { - if all_unit_variants { + if all_unit_variants.clone() { match wire_contract_item.clone() { Some(_) => resolve_wire_serde_policy_for_coproduct( wire_contract_item.clone(), @@ -7870,14 +7858,14 @@ pub fn emit_type_def_from_connective( None => "".to_string(), }; let validations = if (policy_validation.clone() == "".to_string()) { - rename_validations + rename_validations.clone() } else { if (rename_validations.clone() == "".to_string()) { - policy_validation + policy_validation.clone() } else { v1_rt::concat( - v1_rt::concat(policy_validation, "\n".to_string()), - rename_validations, + v1_rt::concat(policy_validation.clone(), "\n".to_string()), + rename_validations.clone(), ) } }; @@ -7890,20 +7878,23 @@ pub fn emit_type_def_from_connective( __result }); let enum_text = emit_enum_from_children( - item_text, + item_text.clone(), type_params, generic_param_names, item.children.clone(), recursive_types, shared_types, env.clone(), - serde_policy, + serde_policy.clone(), emit_info.clone(), ); if (validations.clone() == "".to_string()) { enum_text } else { - v1_rt::concat(v1_rt::concat(validations, "\n".to_string()), enum_text) + v1_rt::concat( + v1_rt::concat(validations.clone(), "\n".to_string()), + enum_text, + ) } } } @@ -7989,10 +7980,13 @@ pub fn rust_phantom_marker_inner(unused: Rc>) -> String { __result }); if ((pascal_unused.clone().len() as i64) == 1) { - pascal_unused.join(&", ".to_string()) + pascal_unused.clone().join(&", ".to_string()) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), pascal_unused.join(&", ".to_string())), + v1_rt::concat( + "(".to_string(), + pascal_unused.clone().join(&", ".to_string()), + ), ")".to_string(), ) } @@ -8094,7 +8088,7 @@ pub fn emit_struct_from_children( ), ": std::marker::PhantomData<".to_string(), ), - rust_phantom_marker_inner(unused_params), + rust_phantom_marker_inner(unused_params.clone()), ), ">,".to_string(), )]), @@ -8161,14 +8155,14 @@ pub fn render_rust_type_with_applied_binding( if (outer_name.clone() != applied_name) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types.clone(), ) } else { if v1_rt::set_contains(&shared_types, outer_name.clone()) { render_rust_shared_type_if_needed( outer_name.clone(), - outer_name, + outer_name.clone(), shared_types.clone(), ) } else { @@ -8294,7 +8288,7 @@ pub fn render_rust_field_type_with_applied_binding( ) != None) { render_rust_type_with_applied_binding( - authored_type, + authored_type.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -8304,7 +8298,7 @@ pub fn render_rust_field_type_with_applied_binding( && ((authored_type.children.clone().len() as i64) > 0)) { render_rust_type( - authored_type, + authored_type.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -8366,7 +8360,7 @@ pub fn emit_struct_field_from_child( ) != None) { render_rust_type_with_applied_binding( - authored_child_type, + authored_child_type.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), env.source_indices.clone(), @@ -8421,7 +8415,7 @@ pub fn emit_struct_field_from_child( ">".to_string(), ); render_rust_shared_type_if_needed( - rt_child_name, + rt_child_name.clone(), with_params, shared_types.clone(), ) @@ -8467,20 +8461,20 @@ pub fn emit_struct_field_from_child( env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), generic_ty), + v1_rt::concat("Box<".to_string(), generic_ty.clone()), ">".to_string(), ) } else { if (((rt_child.return_cardinality.clone() != Cardinality::CardOptional) && v1_rt::set_contains( &shared_types, - authored_name_at(env.source_indices.clone(), rt_child), + authored_name_at(env.source_indices.clone(), rt_child.clone()), )) && !rust_type_is_rc_wrapped(generic_ty.clone())) { - wrap_shared_type(RenderTarget::Rust, generic_ty) + wrap_shared_type(RenderTarget::Rust, generic_ty.clone()) } else { - generic_ty + generic_ty.clone() } }; let rename_attr = match Rc::new({ @@ -8537,7 +8531,7 @@ pub fn emit_rust_field_definition( v1_rt::concat( v1_rt::concat( v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake, + snake.clone(), ), "\")]\n".to_string(), ) @@ -8555,7 +8549,7 @@ pub fn emit_rust_field_definition( ), visibility, ), - emitted, + emitted.clone(), ), ": ".to_string(), ), @@ -8660,7 +8654,10 @@ pub fn emit_enum_from_children( if (accessor_impl.clone() == "".to_string()) { enum_def } else { - v1_rt::concat(v1_rt::concat(enum_def, "\n".to_string()), accessor_impl) + v1_rt::concat( + v1_rt::concat(enum_def, "\n".to_string()), + accessor_impl.clone(), + ) } } } @@ -8759,7 +8756,7 @@ pub fn emit_enum_shared_accessors( let first_fielded = fielded.clone().first().cloned().clone().unwrap(); let shared = Rc::new({ let mut __result = Vec::new(); - for fname in all_shared.iter().cloned() { + for fname in all_shared.clone().iter().cloned() { if { let types = Rc::new({ let mut __result = Vec::new(); @@ -8818,7 +8815,7 @@ pub fn emit_enum_shared_accessors( } let accessor_fns = Rc::new({ let mut __result = Vec::new(); - for fname in shared.iter().cloned() { + for fname in shared.clone().iter().cloned() { __result.push({ let ty = match Rc::new({ let mut __result = Vec::new(); @@ -9113,7 +9110,7 @@ pub fn policy_serde_tag_field(policy: Rc) -> Option { ) { Some(end) => Some(v1_rt::substring( &policy.enum_attr.clone(), - after, + after.clone(), end.clone(), )), None => None, @@ -9301,7 +9298,12 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type(n.clone(), shared_types, corpus_repr, source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } @@ -9335,7 +9337,10 @@ pub fn emit_variant_from_child( wire_variant_rename_attr_for_policy(child_text.clone(), serde_policy.clone()); if ((child.children.clone().len() as i64) == 0) { v1_rt::concat( - v1_rt::concat(v1_rt::concat(rename_attr, " ".to_string()), child_text), + v1_rt::concat( + v1_rt::concat(rename_attr, " ".to_string()), + child_text.clone(), + ), ",".to_string(), ) } else { @@ -9363,7 +9368,7 @@ pub fn emit_variant_from_child( } else { fallback }; - let raw_ty = if positional_payload { + let raw_ty = if positional_payload.clone() { render_variant_payload_type( type_node.clone(), shared_types.clone(), @@ -9394,28 +9399,28 @@ pub fn emit_variant_from_child( raw_ty }; let final_ty = if needs_box_wrapping( - type_node, - recursive_types, + type_node.clone(), + recursive_types.clone(), shared_types.clone(), env.source_indices.clone(), ) { v1_rt::concat( - v1_rt::concat("Box<".to_string(), ty), + v1_rt::concat("Box<".to_string(), ty.clone()), ">".to_string(), ) } else { - ty + ty.clone() }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), "(".to_string(), ), - final_ty, + final_ty.clone(), ), "),".to_string(), ) @@ -9423,7 +9428,7 @@ pub fn emit_variant_from_child( None => v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), ",".to_string(), ), @@ -9474,7 +9479,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), " {\n".to_string(), ), @@ -9531,7 +9536,7 @@ pub fn emit_variant_from_child( v1_rt::concat( v1_rt::concat( v1_rt::concat(rename_attr, " ".to_string()), - child_text, + child_text.clone(), ), " {\n".to_string(), ), @@ -9556,14 +9561,14 @@ pub fn emit_fn_def( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let host_text_op = if corpus_repr_is_host(emit_info.corpus_repr.clone()) { rust_host_string_op_fn_emit(name.clone()) } else { None }; if (host_text_op.clone() != None) { - return match host_text_op { + return match host_text_op.clone() { Some(op_fn) => op_fn.clone(), None => "".to_string(), }; @@ -9621,9 +9626,13 @@ pub fn emit_fn_def( > 0); let needs_clone_bound = (return_is_bare_generic && !body_is_param_ref); let type_params_str = if needs_clone_bound { - emit_type_params_with_clone_bound(type_params, ret_name, si.clone()) + emit_type_params_with_clone_bound( + type_params.clone(), + ret_name.clone(), + si.clone(), + ) } else { - emit_type_params(type_params, si.clone()) + emit_type_params(type_params.clone(), si.clone()) }; let params_str = emit_params( value_params.clone(), @@ -9651,21 +9660,21 @@ pub fn emit_fn_def( let needs_stacker = (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) && (use_tco.clone() == false)); - if use_tco { + if use_tco.clone() { { let tco_params_str = emit_tco_params( value_params.clone(), - generic_param_names, + generic_param_names.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - si, + si.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_str = emit_typed_tco_body( body.clone(), name.clone(), - value_params, + value_params.clone(), registry.clone(), body_scope, (depth.clone() + 1), @@ -9707,7 +9716,7 @@ pub fn emit_fn_def( ), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ), @@ -9723,7 +9732,7 @@ pub fn emit_fn_def( body.clone(), registry.clone(), body_scope, - depth, + depth.clone(), shared_types.clone(), emit_info.clone(), needs_stacker, @@ -9890,7 +9899,7 @@ pub fn emit_func_def( service_names, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), @@ -9899,10 +9908,10 @@ pub fn emit_func_def( inferred, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let body_scope = uses.clone().iter().cloned().fold( body_scope.clone(), |s: Rc, u: Rc| { @@ -9917,7 +9926,7 @@ pub fn emit_func_def( let body_str = emit_func_body( body, registry.clone(), - body_scope, + body_scope.clone(), (depth.clone() + 1), shared_types.clone(), emit_info.clone(), @@ -9954,7 +9963,7 @@ pub fn emit_func_def( ), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_str, ), @@ -9972,7 +9981,7 @@ pub fn emit_func_body( emit_info: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at(body.clone(), si); @@ -9990,8 +9999,8 @@ pub fn emit_func_body( let let_line = emit_let_binding(n.clone(), val_str, RenderTarget::Rust); let next_scope = extend_scope( scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match inner { @@ -10024,7 +10033,7 @@ pub fn emit_func_body( shared_types.clone(), emit_info.clone(), ); - let last_stmt = ss.last().cloned(); + let last_stmt = ss.clone().last().cloned(); let last_str = match last_stmt { Some(s) => match (*s.expr_data.clone()).clone() { ExprData::ExprReturn => v1_rt::concat( @@ -10150,7 +10159,7 @@ pub fn emit_tco_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored, + authored.clone(), generic_param_names, shared_types, corpus_repr, @@ -10395,7 +10404,7 @@ pub fn emit_param( let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { emit_rust_param_type( - authored, + authored.clone(), generic_param_names, shared_types, corpus_repr, @@ -10572,7 +10581,7 @@ pub fn collect_pattern_string_guards( mut source_indices: Rc>>, ) -> String { loop { - match (*pattern.clone()).clone() { + match (*pattern).clone() { MatchPattern::VariantPattern { name: n, parent_enum: parent, @@ -10626,18 +10635,18 @@ pub fn collect_pattern_string_guards( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), "0".to_string(), ); if is_string_lit_pattern(fb_pat.clone()) { break positional_payload_string_guard( fb_pat.clone(), - pattern_string_binding_name(pos_path.clone()), + pattern_string_binding_name(pos_path), ); } else { { let __tco_0 = fb_pat.clone(); - let __tco_1 = pos_path.clone(); + let __tco_1 = pos_path; pattern = __tco_0; path_prefix = __tco_1; continue; @@ -10646,7 +10655,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), source_indices.clone(), ); } @@ -10658,7 +10667,7 @@ pub fn collect_pattern_string_guards( } else { break collect_field_binding_string_guards( fbs.clone(), - v1_rt::rc_list_push(path_prefix.clone(), n.clone()), + v1_rt::rc_list_push(path_prefix, n.clone()), source_indices.clone(), ); } @@ -10766,7 +10775,7 @@ pub fn pattern_parent_enum( let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { - parent_enum + parent_enum.clone() } else { if scrut_is_known_enum { Some(scrut_type.clone()) @@ -10798,7 +10807,7 @@ pub fn unique_variant_parent( __result }); if ((parent_matches.clone().len() as i64) == 1) { - parent_matches.first().cloned() + parent_matches.clone().first().cloned() } else { None } @@ -10894,7 +10903,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10905,9 +10914,9 @@ pub fn emit_variant_pattern( } else { { let inner_pat = emit_pattern( - fb_pat, - v1_rt::rc_list_push(path_prefix, rust_name), - shared_types, + fb_pat.clone(), + v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), + shared_types.clone(), scrut_type.clone(), source_indices.clone(), emit_info.clone(), @@ -10919,7 +10928,7 @@ pub fn emit_variant_pattern( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -10931,38 +10940,38 @@ pub fn emit_variant_pattern( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(ref ".to_string()), - bind_name, + v1_rt::concat(qualified.clone(), "(ref ".to_string()), + bind_name.clone(), ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent, + resolved_parent.clone(), name.clone(), fb.clone(), emit_info.clone(), source_indices.clone(), ); let inner_pat = emit_pattern( - fb_pat, - pos_path, - shared_types, + fb_pat.clone(), + pos_path.clone(), + shared_types.clone(), payload_scrut, source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(".to_string()), + v1_rt::concat(qualified.clone(), "(".to_string()), inner_pat, ), ")".to_string(), @@ -10979,13 +10988,19 @@ pub fn emit_variant_pattern( { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), - fb_name, + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), )); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - bind_name, + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + bind_name.clone(), ), ", .. }".to_string(), ) @@ -10993,25 +11008,31 @@ pub fn emit_variant_pattern( } else { { let pat_str = emit_pattern( - fb_pat, + fb_pat.clone(), v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), fb_name.clone(), ), - shared_types, + shared_types.clone(), "".to_string(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), v1_rt::concat( v1_rt::concat( - emit_ident(fb_name, RenderTarget::Rust), + emit_ident( + fb_name.clone(), + RenderTarget::Rust, + ), ": ".to_string(), ), - pat_str, + pat_str.clone(), ), ), ", .. }".to_string(), @@ -11021,12 +11042,12 @@ pub fn emit_variant_pattern( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent { + let shape_key = match resolved_parent.clone() { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11040,19 +11061,20 @@ pub fn emit_variant_pattern( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = - (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) - || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = (v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + shape_key.clone(), + ) || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11072,7 +11094,7 @@ pub fn emit_variant_pattern( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent { + let shape_key2 = match resolved_parent.clone() { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11088,18 +11110,18 @@ pub fn emit_variant_pattern( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2, + shape_key2.clone(), ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11107,7 +11129,7 @@ pub fn emit_variant_pattern( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.iter().cloned() { + for fb in effective_bindings.clone().iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11206,7 +11228,7 @@ pub fn emit_variant_pattern( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11279,7 +11301,7 @@ pub fn analyze_rc_pattern( "".to_string(), shared_types.clone(), emit_info.clone(), - source_indices, + source_indices.clone(), ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, @@ -11349,7 +11371,7 @@ pub fn analyze_rc_pattern( matches_rc_variant: matches_rc_variant, matches_option_rc_variant: false, needs_rc_pattern: ((ref_bound_fields.clone().len() as i64) > 0), - ref_bound_fields: ref_bound_fields, + ref_bound_fields: ref_bound_fields.clone(), }) } } @@ -11411,7 +11433,7 @@ pub fn analyze_rc_match( }; let arms_want_deref = { let mut __found = false; - for a in arm_analyses.iter().cloned() { + for a in arm_analyses.clone().iter().cloned() { if a.matches_rc_variant.clone() { __found = true; break; @@ -11508,7 +11530,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -11526,9 +11548,9 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat, - v1_rt::rc_list_push(path_prefix, rust_name), - inner_analysis, + fb_pat.clone(), + v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), + inner_analysis.clone(), shared_types.clone(), scrut_type.clone(), source_indices.clone(), @@ -11541,7 +11563,7 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 1) { @@ -11553,22 +11575,22 @@ pub fn emit_variant_pattern_rc_aware( { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string(), ); let bind_name = pattern_string_binding_name(pos_path.clone()); if is_string_lit_pattern(fb_pat.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(ref ".to_string()), - bind_name, + v1_rt::concat(qualified.clone(), "(ref ".to_string()), + bind_name.clone(), ), ")".to_string(), ) } else { { let payload_scrut = positional_payload_scrut_type( - resolved_parent, + resolved_parent.clone(), name.clone(), fb.clone(), emit_info.clone(), @@ -11582,17 +11604,17 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let inner_pat = emit_pattern_rc_aware( - fb_pat, - pos_path, - inner_analysis, + fb_pat.clone(), + pos_path.clone(), + inner_analysis.clone(), shared_types.clone(), - payload_scrut, + payload_scrut.clone(), source_indices.clone(), emit_info.clone(), ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, "(".to_string()), + v1_rt::concat(qualified.clone(), "(".to_string()), inner_pat, ), ")".to_string(), @@ -11609,23 +11631,32 @@ pub fn emit_variant_pattern_rc_aware( { let bind_name = pattern_string_binding_name(v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), - fb_name, + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), )); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - bind_name, + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + bind_name.clone(), ), ", .. }".to_string(), ) } } else { - if field_needs_rc_ref(fb_name.clone(), rc_analysis) { + if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ref ".to_string()), - emit_ident(fb_name, RenderTarget::Rust), + v1_rt::concat( + qualified.clone(), + " { ref ".to_string(), + ), + emit_ident(fb_name.clone(), RenderTarget::Rust), ), ", .. }".to_string(), ) @@ -11639,12 +11670,15 @@ pub fn emit_variant_pattern_rc_aware( source_indices.clone(), ); let pat_str = emit_pattern_rc_aware( - fb_pat, + fb_pat.clone(), v1_rt::rc_list_push( - v1_rt::rc_list_push(path_prefix, name.clone()), + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), fb_name.clone(), ), - inner_analysis, + inner_analysis.clone(), shared_types.clone(), "".to_string(), source_indices.clone(), @@ -11652,13 +11686,19 @@ pub fn emit_variant_pattern_rc_aware( ); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat( + qualified.clone(), + " { ".to_string(), + ), v1_rt::concat( v1_rt::concat( - emit_ident(fb_name, RenderTarget::Rust), + emit_ident( + fb_name.clone(), + RenderTarget::Rust, + ), ": ".to_string(), ), - pat_str, + pat_str.clone(), ), ), ", .. }".to_string(), @@ -11669,12 +11709,12 @@ pub fn emit_variant_pattern_rc_aware( } } } - None => qualified, + None => qualified.clone(), } } else { if ((field_bindings.clone().len() as i64) == 0) { { - let shape_key = match resolved_parent { + let shape_key = match resolved_parent.clone() { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11688,19 +11728,20 @@ pub fn emit_variant_pattern_rc_aware( &emit_info.positional_payload_variants.clone(), qualified.clone(), )); - let is_fielded = - (v1_rt::set_contains(&emit_info.fielded_variants.clone(), shape_key) - || v1_rt::set_contains( - &emit_info.fielded_variants.clone(), - qualified.clone(), - )); + let is_fielded = (v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + shape_key.clone(), + ) || v1_rt::set_contains( + &emit_info.fielded_variants.clone(), + qualified.clone(), + )); if is_positional { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11720,7 +11761,7 @@ pub fn emit_variant_pattern_rc_aware( }); if ((effective_bindings.clone().len() as i64) == 0) { { - let shape_key2 = match resolved_parent { + let shape_key2 = match resolved_parent.clone() { Some(parent) => v1_rt::concat( v1_rt::concat(parent.clone(), "::".to_string()), name.clone(), @@ -11736,18 +11777,18 @@ pub fn emit_variant_pattern_rc_aware( )); let is_fielded2 = (v1_rt::set_contains( &emit_info.fielded_variants.clone(), - shape_key2, + shape_key2.clone(), ) || v1_rt::set_contains( &emit_info.fielded_variants.clone(), qualified.clone(), )); if is_positional2 { - v1_rt::concat(qualified, "(_)".to_string()) + v1_rt::concat(qualified.clone(), "(_)".to_string()) } else { if is_fielded2 { - v1_rt::concat(qualified, " { .. }".to_string()) + v1_rt::concat(qualified.clone(), " { .. }".to_string()) } else { - qualified + qualified.clone() } } } @@ -11755,7 +11796,7 @@ pub fn emit_variant_pattern_rc_aware( { let binding_strs = Rc::new({ let mut __result = Vec::new(); - for fb in effective_bindings.iter().cloned() { + for fb in effective_bindings.clone().iter().cloned() { __result.push({ let fb_name = field_binding_name_at( fb.clone(), @@ -11878,7 +11919,7 @@ pub fn emit_variant_pattern_rc_aware( let bindings_str = binding_strs.join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(qualified, " { ".to_string()), + v1_rt::concat(qualified.clone(), " { ".to_string()), bindings_str, ), ", .. }".to_string(), @@ -11919,8 +11960,8 @@ pub fn rc_pattern_preludes( source_indices.clone(), ); rc_pattern_preludes( - fb_pat, - inner_analysis, + fb_pat.clone(), + inner_analysis.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -12055,27 +12096,27 @@ pub fn explicit_record_struct_name( }; let nname = authored_name_at(source_indices, n.clone()); if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { - type_name + type_name.clone() } else { if n_is_error { - type_name + type_name.clone() } else { if is_product { if (n.ident_span.clone() == None) { - type_name + type_name.clone() } else { - Some(nname) + Some(nname.clone()) } } else { if is_coproduct { - type_name + type_name.clone() } else { if (((n.children.clone().len() as i64) == 0) && (n.ident_span.clone() != None)) { - Some(nname) + Some(nname.clone()) } else { - type_name + type_name.clone() } } } @@ -12159,7 +12200,7 @@ pub fn effective_variant_parent( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { variant_parent_from_binding_kind(binding_kind) } @@ -12181,28 +12222,10 @@ pub fn variant_ref_self_wraps( || v1_rt::set_contains(&shared_types, enum_name.clone())) } -pub fn move_licensed_at_site(emit_info: Rc, name: String, use_span: i64) -> bool { - if (use_span.clone() == 0) { - false - } else { - match v1_rt::map_get( - &emit_info.move_sites.clone(), - move_site_key(name.clone(), use_span.clone()), - ) { - Some(v) => { - (v.clone() - && !v1_rt::set_contains(&emit_info.read_only_params.clone(), name.clone())) - } - None => false, - } - } -} - pub fn emit_var_ref( name: String, binding_kind: Option>, resolved_type: Option>, - use_span: i64, shared_types: Rc>, registry: Rc>>, emit_info: Rc, @@ -12215,16 +12238,7 @@ pub fn emit_var_ref( emit_keyword(name.clone(), RenderTarget::Rust) } else { { - let site_move_kind_allowed = match binding_kind.clone().as_deref().cloned() { - Some(VarBindingKind::MatchBoundBinding) => false, - Some(VarBindingKind::FunctionValueBinding) => false, - Some(VarBindingKind::VariantValueBinding { parent_enum: _, .. }) => false, - _ => true, - }; - let moves_by_value = - (v1_rt::set_contains(&emit_info.movable.clone(), name.clone()) - || (site_move_kind_allowed - && move_licensed_at_site(emit_info.clone(), name.clone(), use_span))); + let moves_by_value = v1_rt::set_contains(&emit_info.movable.clone(), name.clone()); let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let variant_parent = effective_variant_parent( name.clone(), @@ -12333,7 +12347,7 @@ pub fn emit_typed_expr_base( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -12344,7 +12358,7 @@ pub fn emit_typed_expr_base( emit_keyword("null".to_string(), RenderTarget::Rust) } else { if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { - emit_keyword(n, RenderTarget::Rust) + emit_keyword(n.clone(), RenderTarget::Rust) } else { { let variant_parent = effective_variant_parent( @@ -12352,7 +12366,7 @@ pub fn emit_typed_expr_base( binding_kind.clone(), texpr.inferred.clone(), emit_info.clone(), - si, + si.clone(), ); match variant_parent { Some(enum_name) => { @@ -12366,7 +12380,7 @@ pub fn emit_typed_expr_base( let qualified = if (is_optional_variant_name(n.clone()) && (enum_name.clone() == "Optional".to_string())) { - if (n == "Present".to_string()) { + if (n.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -12377,7 +12391,7 @@ pub fn emit_typed_expr_base( enum_name.clone(), "::".to_string(), ), - n, + n.clone(), ) }; if v1_rt::set_contains(&shared_types, enum_name.clone()) @@ -12399,12 +12413,12 @@ pub fn emit_typed_expr_base( Some(info) => { let is_data = (info.kind.clone() == ItemKind::DataItem); if is_data { - v1_rt::concat(to_snake(n), "()".to_string()) + v1_rt::concat(to_snake(n.clone()), "()".to_string()) } else { - emit_ident(n, RenderTarget::Rust) + emit_ident(n.clone(), RenderTarget::Rust) } } - None => emit_ident(n, RenderTarget::Rust), + None => emit_ident(n.clone(), RenderTarget::Rust), }, } } @@ -12440,12 +12454,12 @@ pub fn field_access_field_is_boxed( match find_child_named( base_struct, field, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_child) => { let field_ty = resolved_type(field_child.clone()); let field_ty_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), field_ty.clone(), ); let grounds_to_host_scalar = (rust_seed_host_numeric_alias( @@ -12455,20 +12469,18 @@ pub fn field_access_field_is_boxed( if grounds_to_host_scalar { false } else { - { - let faithful_nat_field = ((emit_info.corpus_repr.clone() - == RustCorpusRepr::FaithfulFreeMonoid) - && ((field_ty_name.clone() == "Nat".to_string()) - || (v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()))); - ((faithful_nat_field - || needs_box_wrapping( - field_ty, - emit_info.recursive_type_set.clone(), - shared_types, - (*scope.type_env).clone().source_indices.clone(), - )) - || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name)) - } + let faithful_nat_field = + matches!(emit_info.corpus_repr.clone(), FaithfulFreeMonoid) + && (field_ty_name.clone() == "Nat".to_string() + || v1_rt::substring(&field_ty_name, 0, 4) == "Nat<".to_string()); + faithful_nat_field + || needs_box_wrapping( + field_ty.clone(), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ) + || is_recursive_type_by_name(scope.type_env.clone(), field_ty_name.clone()) } } None => false, @@ -12536,7 +12548,7 @@ pub fn emit_typed_field_access( .cloned() { if (authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), pair.1.clone(), ) == field.clone()) { @@ -12599,7 +12611,7 @@ pub fn emit_typed_field_access( } => { let base_name = expr_var_name_at( base.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::set_contains( &emit_info.owned_bindings.clone(), @@ -12675,13 +12687,13 @@ pub fn type_needs_rc_seen( mut source_indices: Rc>>, ) -> bool { loop { - let normed = normalize_access_type_node(type_node.clone()); + let normed = normalize_access_type_node(type_node); let is_product = is_product_type(normed.clone()); let is_coproduct = is_coproduct_type(normed.clone()); - if is_product.clone() { + if is_product { break true; } else { - if is_coproduct.clone() { + if is_coproduct { break { let mut __found = false; for child in normed.children.clone().iter().cloned() { @@ -12702,7 +12714,7 @@ pub fn type_needs_rc_seen( }; { let __tco_0 = resolved_type(normed.clone()); - let __tco_1 = next_seen.clone(); + let __tco_1 = next_seen; type_node = __tco_0; seen = __tco_1; continue; @@ -12719,13 +12731,12 @@ pub fn type_needs_rc_seen( v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; let has_structure = (normed.connective.clone() != Connective::NoConnective); - if (!has_structure.clone() && ((normed.children.clone().len() as i64) == 0)) - { + if (!has_structure && ((normed.children.clone().len() as i64) == 0)) { break false; } else { { let __tco_0 = normed.clone(); - let __tco_1 = next_seen.clone(); + let __tco_1 = next_seen; type_node = __tco_0; seen = __tco_1; continue; @@ -12745,7 +12756,7 @@ pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> bool pub fn rust_runtime_bridge_name(function_name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), function_name.clone()) { Some(runtime_name) => runtime_name.clone(), - None => function_name, + None => function_name.clone(), } } @@ -12766,7 +12777,7 @@ pub fn rust_empty_map_value_type_str( if (rendered.clone() == "".to_string()) { "".to_string() } else { - rendered + rendered.clone() } } None => "".to_string(), @@ -12796,7 +12807,10 @@ pub fn rust_empty_map_kv_type_str( source_indices.clone(), ); if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { - v1_rt::concat(v1_rt::concat(key_str, ", ".to_string()), val_str) + v1_rt::concat( + v1_rt::concat(key_str.clone(), ", ".to_string()), + val_str.clone(), + ) } else { "".to_string() } @@ -12825,7 +12839,7 @@ pub fn rust_btree_set_element_ord_eligible( || (elem_name.clone() == "Bool".to_string())) || (elem_name.clone() == "Unit".to_string())) || (elem_name.clone() == "Secret".to_string())) - || (elem_name == "Bytes".to_string())) + || (elem_name.clone() == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12855,7 +12869,7 @@ pub fn rust_empty_set_element_type_str( "".to_string() } else { render_node_type( - elem_node, + elem_node.clone(), RenderTarget::Rust, shared_types, source_indices.clone(), @@ -12885,7 +12899,7 @@ pub fn emit_rust_empty_set_expr( } else { if !rust_btree_set_element_ord_eligible(elem_node.clone(), source_indices.clone()) { { - let elem_name = authored_name_at(source_indices.clone(), elem_node); + let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); emit_rust_compile_error_expr(v1_rt::concat( v1_rt::concat("empty_set element type ".to_string(), elem_name), " is not Ord-eligible for BTreeSet".to_string(), @@ -12900,7 +12914,10 @@ pub fn emit_rust_empty_set_expr( ); if (elem_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat("v1_rt::rc_empty_set::<".to_string(), elem_str), + v1_rt::concat( + "v1_rt::rc_empty_set::<".to_string(), + elem_str.clone(), + ), ">()".to_string(), ) } else { @@ -12968,7 +12985,6 @@ pub fn emit_rust_expr_var( n, binding_kind.clone(), expr.inferred.clone(), - expr.span.clone().start.clone(), shared_types, registry, emit_info, @@ -12991,7 +13007,7 @@ pub fn emit_rust_expr_field_access( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: summary, .. @@ -13000,11 +13016,11 @@ pub fn emit_rust_expr_field_access( let b = field_access_base(expr.clone()); if is_typed_service_call_receiver( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { match extract_typed_service_name( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(svc_name) => service_var_name(svc_name.clone()), None => emit_typed_field_access( @@ -13049,10 +13065,7 @@ pub fn emit_rust_expr_call( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let f = expr_call_func_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_call_expr( f, expr.children.clone(), @@ -13086,10 +13099,8 @@ pub fn emit_rust_expr_method_call( } => { let r = method_receiver(expr.clone()); let a = method_arg_nodes(expr.clone()); - let m = expr_method_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let m = + expr_method_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); emit_typed_method_call( expr.clone(), r, @@ -13164,10 +13175,8 @@ pub fn emit_rust_expr_let( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(expr.clone()); let bd = let_body(expr.clone()); emit_typed_let( @@ -13203,10 +13212,10 @@ pub fn emit_rust_expr_record_lit( } => { let tn = record_lit_type_name_at( expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.clone(); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let resolved_rt = resolved_type(expr.clone()); let expanded_rt = expand_type_for_field_access( resolved_rt, @@ -13226,13 +13235,13 @@ pub fn emit_rust_expr_record_lit( if ((concrete.clone() != "".to_string()) && (concrete.clone() != variant_name.clone())) { - Some(concrete) + Some(concrete.clone()) } else { - tn + tn.clone() } } } else { - tn + tn.clone() }; let raw = emit_typed_record_lit( peeled_type_name, @@ -13256,20 +13265,21 @@ pub fn emit_rust_expr_record_lit( ) { Some(p) => p.clone(), None => { - let expanded_name = authored_name_at(si, expanded_rt.clone()); + let expanded_name = authored_name_at(si.clone(), expanded_rt.clone()); if ((((expanded_rt.ident_span.clone() != None) && (expanded_name.clone() != "".to_string())) && (expanded_name.clone() != variant_name.clone())) && v1_rt::set_contains(&shared_types, expanded_name.clone())) { - expanded_name + expanded_name.clone() } else { - variant_name + variant_name.clone() } } }, }; - if ((rc_name.clone() != "".to_string()) && v1_rt::set_contains(&shared_types, rc_name)) + if ((rc_name.clone() != "".to_string()) + && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -13369,7 +13379,7 @@ pub fn emit_rust_expr_cast( 1024, ) }, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), _ => emit_error_expr( "emit_rust_expr_cast expected ExprCast".to_string(), @@ -13388,10 +13398,8 @@ pub fn emit_rust_expr_for_each( ) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { - let v = foreach_variable_at( - expr.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let v = + foreach_variable_at(expr.clone(), scope.type_env.clone().source_indices.clone()); let c = foreach_collection(expr.clone()); let bd = foreach_body(expr.clone()); emit_typed_for_each( @@ -13499,7 +13507,7 @@ pub fn emit_typed_expr( emit_shared_expr( texpr, RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |result| result.clone(), |child| { emit_typed_expr( @@ -13518,7 +13526,7 @@ pub fn emit_typed_expr( registry.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }, |expr| { @@ -13712,7 +13720,7 @@ pub fn contextual_variant_parent( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { None } @@ -13751,7 +13759,8 @@ pub fn emit_discriminant_call_lowering( emit_info.clone(), 1024, ); - let ty_name = resolved_type_name(arg, (*scope.type_env).clone().source_indices.clone()); + let ty_name = + resolved_type_name(arg.clone(), scope.type_env.clone().source_indices.clone()); match lookup_type_by_name(scope.type_env.clone(), ty_name.clone()) { Some(enum_node) => { if is_coproduct_type(enum_node.clone()) { @@ -13770,7 +13779,7 @@ pub fn emit_discriminant_call_lowering( } else { if variant_is_synthetic_positional_payload( child.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -13818,7 +13827,7 @@ pub fn emit_discriminant_call_lowering( } __result }); - let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name) { + let scrut_ref = if v1_rt::set_contains(&shared_types, ty_name.clone()) { v1_rt::concat( v1_rt::concat("&*(".to_string(), scrutinee), ")".to_string(), @@ -13842,13 +13851,19 @@ pub fn emit_discriminant_call_lowering( } } else { emit_rust_host_to_dag_string_via_seam( - v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), + v1_rt::concat( + v1_rt::concat("\"".to_string(), ty_name.clone()), + "\"".to_string(), + ), emit_info.corpus_repr.clone(), ) } } None => emit_rust_host_to_dag_string_via_seam( - v1_rt::concat(v1_rt::concat("\"".to_string(), ty_name), "\"".to_string()), + v1_rt::concat( + v1_rt::concat("\"".to_string(), ty_name.clone()), + "\"".to_string(), + ), emit_info.corpus_repr.clone(), ), } @@ -13873,11 +13888,14 @@ pub fn emit_typed_call_expr( ret_type.clone(), shared_types, emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( - v1_rt::concat("v1_rt::rc_empty_map::<".to_string(), kv_type_str), + v1_rt::concat( + "v1_rt::rc_empty_map::<".to_string(), + kv_type_str.clone(), + ), ">()".to_string(), ) } else { @@ -13895,7 +13913,7 @@ pub fn emit_typed_call_expr( emit_rust_empty_set_expr( ret_type.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } _ => "v1_rt::rc_empty_set::<_>()".to_string(), @@ -13965,7 +13983,7 @@ pub fn emit_typed_call( { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); - let get_idx = get_args.get(1 as usize).cloned(); + let get_idx = get_args.clone().get(1 as usize).cloned(); let get_result = match get_list { Some(list_arg) => match get_idx { Some(idx_arg) => { @@ -14015,7 +14033,8 @@ pub fn emit_typed_call( if ((with_args.clone().len() as i64) < 2) { return "compile_error!(\"with call missing update record\")".to_string(); } - let update_arg = arg_value(with_args.get(1 as usize).cloned().clone().unwrap()); + let update_arg = + arg_value(with_args.clone().get(1 as usize).cloned().clone().unwrap()); let base_str = emit_typed_expr( base_arg.clone(), registry.clone(), @@ -14027,8 +14046,8 @@ pub fn emit_typed_call( ); let type_name = if (base_arg.inferred.clone() != None) { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - resolved_type(base_arg), + scope.type_env.clone().source_indices.clone(), + resolved_type(base_arg.clone()), ) } else { "compile_error!(\"with call missing resolved record type\")".to_string() @@ -14042,7 +14061,7 @@ pub fn emit_typed_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -14062,7 +14081,7 @@ pub fn emit_typed_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg, + update_arg.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -14082,14 +14101,17 @@ pub fn emit_typed_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), + v1_rt::concat( + v1_rt::concat(type_name.clone(), " { ".to_string()), + fields_str, + ), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc { + if needs_rc.clone() { return v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string(), @@ -14168,7 +14190,7 @@ pub fn emit_typed_call( ExprData::ExprLambda => { let lps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); lambda_scope_from_children( scope.clone(), @@ -14315,13 +14337,13 @@ pub fn emit_typed_call( let all_args = v1_rt::concat(arg_strs, extra_args); let args_str = all_args.clone().join(&", ".to_string()); let runtime_name = rust_runtime_bridge_name(func.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let callee_self_capture = if is_rt.clone() { false } else { { let mut __found = false; - for a in filled_args.iter().cloned() { + for a in filled_args.clone().iter().cloned() { if expr_references_var(arg_value(a.clone()), func.clone(), si.clone()) { __found = true; break; @@ -14343,21 +14365,21 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt && (func.clone() == "concat".to_string())) + let call_str = if ((is_rt.clone() && (func.clone() == "concat".to_string())) && ((all_args.clone().len() as i64) > 2)) { - emit_nested_rt_concat(all_args, "".to_string(), shared_types.clone()) + emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) } else { v1_rt::concat( v1_rt::concat(v1_rt::concat(func_name, "(".to_string()), args_str), ")".to_string(), ) }; - match callee { + match callee.clone() { Some(info) => { let has_effects = (((info.service_names.clone().len() as i64) > 0) || ((info.resource_names.clone().len() as i64) > 0)); - if has_effects { + if has_effects.clone() { v1_rt::concat(call_str, ".await?".to_string()) } else { call_str @@ -14383,10 +14405,8 @@ pub fn fill_default_args( let mut __result = Vec::new(); for a in ordered.clone().iter().cloned() { __result.push( - match arg_name_at( - a.clone(), - (*scope.type_env).clone().source_indices.clone(), - ) { + match arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) + { Some(n) => n.clone(), None => "".to_string(), }, @@ -14404,7 +14424,7 @@ pub fn fill_default_args( if (n.clone() == param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) { __found = true; @@ -14430,7 +14450,7 @@ pub fn fill_default_args( __result.push(make_arg_node( Some(param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )), param_node_default_value(p.clone()).clone().unwrap(), p.span.clone(), @@ -14455,7 +14475,7 @@ pub fn fill_op_default_args( emit_info: Rc, ) -> Rc>> { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), |acc: Rc>>, a: Rc| match arg_name_at( @@ -14540,7 +14560,7 @@ pub fn emit_nested_rt_concat( .skip(1 as usize) .collect::>(), ); - let __tco_1 = next_acc.clone(); + let __tco_1 = next_acc; remaining = __tco_0; acc = __tco_1; continue; @@ -14573,7 +14593,7 @@ pub fn emit_typed_for_each( ); let elem_type = for_each_element_type_node( resolved_type(collection.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let body_scope = extend_scope( scope.clone(), @@ -14594,7 +14614,7 @@ pub fn emit_typed_for_each( let ind2 = make_indent((depth.clone() + 2)); let ind0 = make_indent(depth.clone()); let iter_str = apply_type_template1(sharing.iter_owned.clone(), coll_str); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\n".to_string(), ind1.clone()), "let mut __collect = Vec::new();\n".to_string()), ind1.clone()), "for ".to_string()), emit_ident(variable.clone(), RenderTarget::Rust)), " in ".to_string()), iter_str), " {\n".to_string()), ind2), "__collect.push(".to_string()), body_str), ");\n".to_string()), ind1.clone()), "}\n".to_string()), ind1.clone()), "Rc::new(__collect)\n".to_string()), ind0), "}".to_string()) } } @@ -14630,9 +14650,12 @@ pub fn emit_typed_index( let base_node = normalize_access_type_node(resolved_type(base.clone())); let is_map = node_is_keyed_collection( base_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like( + base_node.clone(), + scope.type_env.clone().source_indices.clone(), + ) { apply_type_template2( spec.indexing.clone().string_index.clone(), base_str, @@ -14692,7 +14715,7 @@ pub fn emit_typed_slice( 1024, ); let base_node = normalize_access_type_node(resolved_type(base.clone())); - if is_rust_string_like(base_node, (*scope.type_env).clone().source_indices.clone()) { + if is_rust_string_like(base_node, scope.type_env.clone().source_indices.clone()) { match spec.indexing.clone().string_slice.clone() { Some(tmpl) => apply_type_template3(tmpl.clone(), base_str, start_str, end_str), None => emit_error_expr( @@ -14739,7 +14762,7 @@ pub fn collection_element_type( "_".to_string() } else { render_rust_type( - elem_node, + elem_node.clone(), shared_types, corpus_repr, source_indices.clone(), @@ -14771,7 +14794,7 @@ pub fn lambda_scope_from_children( ) .iter() .cloned() - .fold(scope, |acc: Rc, pair: (i64, String)| { + .fold(scope.clone(), |acc: Rc, pair: (i64, String)| { let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes.clone().get(idx.clone() as usize).cloned() { @@ -14885,7 +14908,7 @@ pub fn emit_typed_collection_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14903,10 +14926,10 @@ pub fn emit_typed_collection_lambda( Rc::new(vec![elem_type_str]), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); - let lambda_scope = lambda_scope_from_children(scope.clone(), ps, pn); + let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn.clone()); let body_str = emit_typed_expr( bd, registry, @@ -14947,7 +14970,7 @@ pub fn emit_typed_fold_lambda( ExprData::ExprLambda => { let ps = lambda_param_names_at( lambda_expr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let bd = lambda_body(lambda_expr.clone()); let pn = Rc::new( @@ -14994,7 +15017,7 @@ pub fn emit_typed_fold_lambda( fallback_types, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); let lambda_scope = lambda_scope_from_children(scope.clone(), ps.clone(), pn); @@ -15007,7 +15030,7 @@ pub fn emit_typed_fold_lambda( emit_info.clone(), 1024, ); - let acc_name = match ps.first().cloned() { + let acc_name = match ps.clone().first().cloned() { Some(n) => n.clone(), None => "".to_string(), }; @@ -15016,19 +15039,6 @@ pub fn emit_typed_fold_lambda( if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); - let site = v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - lambda_expr.span.clone().file.clone(), - ":".to_string(), - ), - (lambda_expr.span.clone().start.clone()).to_string(), - ), - ":".to_string(), - ), - acc_name, - ); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -15036,22 +15046,16 @@ pub fn emit_typed_fold_lambda( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("|".to_string(), params_str), - "| { let ".to_string(), - ), - acc_ident.clone(), - ), - " = v1_rt::take_owned_counted(".to_string(), + v1_rt::concat("|".to_string(), params_str), + "| { let ".to_string(), ), - acc_ident, + acc_ident.clone(), ), - ", \"".to_string(), + " = Rc::try_unwrap(".to_string(), ), - site, + acc_ident.clone(), ), - "\"); ".to_string(), + ").unwrap_or_else(|rc| (*rc).clone()); ".to_string(), ), body_str, ), @@ -15103,7 +15107,7 @@ pub fn emit_rust_fold_method_call( receiver.inferred.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { Some(InferredNode::Resolved { @@ -15144,33 +15148,33 @@ pub fn emit_rust_fold_method_call( }); let is_under_resolved_map = (node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) || acc_children_have_unit.clone())); let is_under_resolved_list = ((node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && ((acc_type.children.clone().len() as i64) == 0)); let is_under_resolved_set = (node_is_set_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && (((acc_type.children.clone().len() as i64) == 0) - || acc_children_have_unit)); + || acc_children_have_unit.clone())); let is_under_resolved_non_collection = ((!node_is_keyed_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !node_is_element_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )) && !node_is_collection( acc_type.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); if (((is_under_resolved_map || is_under_resolved_list) || is_under_resolved_set) || is_under_resolved_non_collection) @@ -15198,7 +15202,7 @@ pub fn emit_rust_fold_method_call( }, }; let acc_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), acc_type_node.clone(), ); let fold_lambda_node = match args.clone().get(1 as usize).cloned() { @@ -15208,7 +15212,7 @@ pub fn emit_rust_fold_method_call( let acc_param_name = match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => match lambda_param_names_at( fold_lambda_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) .first() .cloned() @@ -15220,7 +15224,7 @@ pub fn emit_rust_fold_method_call( }; let fold_proof = analyze_single_fold( method_call_node, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let structural_unwrap = ((fold_proof.eligible.clone() && fold_proof.body_constructs_acc.clone()) @@ -15233,8 +15237,8 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node, - (*scope.type_env).clone().source_indices.clone(), + fold_lambda_node.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15252,8 +15256,6 @@ pub fn emit_rust_fold_method_call( emit_info.owned_bindings.clone(), acc_name.clone(), ), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15268,8 +15270,8 @@ pub fn emit_rust_fold_method_call( match (*fold_lambda_node.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( - fold_lambda_node, - (*scope.type_env).clone().source_indices.clone(), + fold_lambda_node.clone(), + scope.type_env.clone().source_indices.clone(), ); match ps.first().cloned() { Some(acc_name) => Rc::new(EmitGraphInfo { @@ -15287,8 +15289,6 @@ pub fn emit_rust_fold_method_call( ), variant_to_enum: emit_info.variant_to_enum.clone(), owned_bindings: emit_info.owned_bindings.clone(), - move_sites_index: emit_info.move_sites_index.clone(), - move_sites: emit_info.move_sites.clone(), read_only_params_index: emit_info.read_only_params_index.clone(), read_only_params: emit_info.read_only_params.clone(), corpus_repr: emit_info.corpus_repr.clone(), @@ -15306,7 +15306,7 @@ pub fn emit_rust_fold_method_call( acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) @@ -15324,7 +15324,7 @@ pub fn emit_rust_fold_method_call( __found }; let is_bare_container = (((acc_type_node.children.clone().len() as i64) == 0) - && is_container_type(acc_type_name)); + && is_container_type(acc_type_name.clone())); let lambda_acc_type_str = if ((is_bare_container || acc_type_is_type_var) || acc_child_is_type_var) { "_".to_string() @@ -15364,7 +15364,7 @@ pub fn emit_rust_fold_method_call( ExprData::ExprCall { .. } => { let init_func = expr_call_func_at( arg_value(init_arg.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((((init_func.clone() == "empty_map".to_string()) && (acc_type_str.clone() != "_".to_string())) @@ -15373,16 +15373,16 @@ pub fn emit_rust_fold_method_call( { { let kv_type_str = rust_empty_map_kv_type_str( - acc_type_node, + acc_type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), - kv_type_str, + kv_type_str.clone(), ), ">()".to_string(), ) @@ -15396,16 +15396,16 @@ pub fn emit_rust_fold_method_call( } else { if ((((init_func.clone() == "empty_set".to_string()) && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str != "".to_string())) - && !acc_has_unit_child) + && (acc_type_str.clone() != "".to_string())) + && !acc_has_unit_child.clone()) { emit_rust_empty_set_expr( - acc_type_node, + acc_type_node.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func == "empty_set".to_string()) { + if (init_func.clone() == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -15443,7 +15443,7 @@ pub fn emit_rust_fold_method_call( scope.clone(), depth.clone(), shared_types.clone(), - fold_emit_info, + fold_emit_info.clone(), ), None => "compile_error!(\"missing fold function argument\")".to_string(), }; @@ -15451,7 +15451,7 @@ pub fn emit_rust_fold_method_call( let elem_unused = match args.clone().get(1 as usize).cloned() { Some(a) => fold_lambda_element_unused( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, }; @@ -15523,7 +15523,7 @@ pub fn emit_rust_sort_by_method_call( let resolved = rt.clone(); let elem = for_each_element_type_node( resolved, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let elem_is_type_var = if (elem.inferred.clone() != None) { is_type_variable(elem.inferred.clone().clone().unwrap()) @@ -15532,10 +15532,10 @@ pub fn emit_rust_sort_by_method_call( }; if ((elem.ident_span.clone() != None) && !elem_is_type_var) { render_rust_type( - elem, + elem.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { "_".to_string() @@ -15562,7 +15562,7 @@ pub fn emit_rust_sort_by_method_call( if (elem_type_str.clone() == "_".to_string()) { v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a, b| { a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str.clone()), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn.clone()), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } } } @@ -15610,7 +15610,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15619,7 +15619,7 @@ pub fn emit_rust_map_method_call( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( arg_value(a.clone()) .children @@ -15675,7 +15675,7 @@ pub fn emit_rust_map_method_call( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15684,7 +15684,7 @@ pub fn emit_rust_map_method_call( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( arg_value(a.clone()) .children @@ -15773,7 +15773,7 @@ pub fn emit_rust_higher_order_method( }; let ps = lambda_param_names_at( arg_value(a.clone()), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let dag_name = match ps.clone().first().cloned() { Some(n) => n.clone(), @@ -15782,7 +15782,7 @@ pub fn emit_rust_higher_order_method( let p = emit_ident(dag_name, RenderTarget::Rust); let lambda_scope = lambda_scope_from_children( scope.clone(), - ps, + ps.clone(), Rc::new( arg_value(a.clone()) .children @@ -15814,7 +15814,7 @@ pub fn emit_rust_higher_order_method( v1_rt::rc_map_insert( seed_bindings("param".to_string(), p), "body".to_string(), - body_str, + body_str.clone(), ), "iter".to_string(), iter_str, @@ -15897,7 +15897,7 @@ pub fn emit_rust_get_method_call( }; if is_map_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { v1_rt::concat( v1_rt::concat( @@ -15954,7 +15954,7 @@ pub fn emit_rust_with_method_call( if (rt_is_error || (rt.ident_span.clone() == None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "compile_error!(\"with method missing resolved record type\")".to_string(), @@ -15972,7 +15972,7 @@ pub fn emit_rust_with_method_call( emit_ident( field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), RenderTarget::Rust, ), @@ -15992,7 +15992,7 @@ pub fn emit_rust_with_method_call( __result }), _ => Rc::new(vec![emit_typed_expr( - update_arg, + update_arg.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -16012,14 +16012,17 @@ pub fn emit_rust_with_method_call( let raw = v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(type_name, " { ".to_string()), fields_str), + v1_rt::concat( + v1_rt::concat(type_name.clone(), " { ".to_string()), + fields_str, + ), ", ..".to_string(), ), spread, ), " }".to_string(), ); - if needs_rc { + if needs_rc.clone() { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16042,7 +16045,7 @@ pub fn emit_rust_first_method_call( } => { if (expr_method_name_at( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == "skip".to_string()) { { @@ -16149,7 +16152,7 @@ pub fn emit_rust_generic_method_call( v1_rt::concat("(".to_string(), recv_str), ".".to_string(), ), - emit_ident(function_name, RenderTarget::Rust), + emit_ident(function_name.clone(), RenderTarget::Rust), ), ")(".to_string(), ), @@ -16212,7 +16215,7 @@ pub fn emit_rust_generic_method_call( ), ")".to_string(), ); - if rust_runtime_bridge_wraps_collection_result_in_rc(function_name) { + if rust_runtime_bridge_wraps_collection_result_in_rc(function_name.clone()) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), lowered), ")".to_string(), @@ -16246,7 +16249,7 @@ pub fn emit_typed_method_call( .. } => { let var_name = service_var_name(svc_name.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let filled_args = fill_op_default_args( args.clone(), op_params.clone(), @@ -16375,20 +16378,20 @@ pub fn emit_typed_method_call( .. } => { let method_name_raw = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), method_def.clone(), ); let method_name = if (method_name_raw.clone() == "length".to_string()) { if is_string_typed_expr( receiver.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { "string_length".to_string() } else { "count".to_string() } } else { - method_name_raw + method_name_raw.clone() }; if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( @@ -16581,7 +16584,7 @@ pub fn emit_typed_method_call( tmpl.clone(), bindings, ); - if rust_runtime_bridge_wraps_collection_result_in_rc(method_name) { + if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw @@ -16589,7 +16592,7 @@ pub fn emit_typed_method_call( } None => { emit_rust_generic_method_call( - method_name, + method_name.clone(), receiver.clone(), args.clone(), result_type, @@ -16812,7 +16815,7 @@ pub fn arms_are_freemonoid_coproduct( }; let is_fm = (empty_is_fm || cons_is_fm); let empty_fillable = (has_empty || has_catchall.clone()); - let cons_fillable = (has_cons || has_catchall); + let cons_fillable = (has_cons || has_catchall.clone()); ((is_fm && empty_fillable) && cons_fillable) } } @@ -16843,7 +16846,7 @@ pub fn freemonoid_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; @@ -16883,7 +16886,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind), + v1_rt::concat("let ".to_string(), head_bind.clone()), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -16891,7 +16894,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind), + v1_rt::concat("let ".to_string(), tail_bind.clone()), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; @@ -16915,7 +16918,7 @@ pub fn freemonoid_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; @@ -16947,7 +16950,7 @@ pub fn emit_native_freemonoid_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -16962,7 +16965,7 @@ pub fn emit_native_freemonoid_match( ); let nonempty_body = freemonoid_nonempty_branch_body( cons_arm, - catchall, + catchall.clone(), si, registry.clone(), scope.clone(), @@ -16981,11 +16984,11 @@ pub fn emit_native_freemonoid_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body, + empty_body.clone(), ), " } else { ".to_string(), ), - nonempty_body, + nonempty_body.clone(), ), " } }".to_string(), ) @@ -17017,11 +17020,11 @@ pub fn emit_typed_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { - authored_name_at((*scope.type_env).clone().source_indices.clone(), rt.clone()) + authored_name_at(scope.type_env.clone().source_indices.clone(), rt.clone()) } } _ => "".to_string(), @@ -17045,7 +17048,7 @@ pub fn emit_typed_match( "".to_string() }; if (native_fm.clone() != "".to_string()) { - return native_fm; + return native_fm.clone(); } let rc_match = analyze_rc_match( scrutinee.clone(), @@ -17053,7 +17056,7 @@ pub fn emit_typed_match( scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let match_result_type = match arms.clone().first().cloned() { Some(first_arm) => resolved_type(arm_body(first_arm.clone())), @@ -17086,7 +17089,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -17106,7 +17109,10 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( "match ".to_string(), - apply_type_template1(sharing.deref_clone.clone(), scrut_str), + apply_type_template1( + sharing.deref_clone.clone(), + scrut_str.clone(), + ), ), " {\n".to_string(), ), @@ -17120,7 +17126,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_str() {\n".to_string(), ), arms_str, @@ -17151,7 +17157,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), sf_arms_str, @@ -17163,7 +17169,7 @@ pub fn emit_typed_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), arms_str, @@ -17192,7 +17198,7 @@ pub fn emit_typed_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -17262,17 +17268,17 @@ pub fn emit_typed_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards), + v1_rt::concat(" if ".to_string(), field_guards.clone()), " && ".to_string(), ), - arm_guard_str, + arm_guard_str.clone(), ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards) + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str) + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() } @@ -17291,7 +17297,6 @@ pub fn emit_typed_match_arm( Some(Rc::new(InferredNode::Resolved { node: match_result_type, })), - arm_b.span.clone().start.clone(), shared_types.clone(), registry.clone(), emit_info.clone(), @@ -17299,7 +17304,7 @@ pub fn emit_typed_match_arm( ) } else { emit_typed_expr( - arm_b, + arm_b.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -17310,7 +17315,7 @@ pub fn emit_typed_match_arm( } } _ => emit_typed_expr( - arm_b, + arm_b.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -17322,10 +17327,10 @@ pub fn emit_typed_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat, - rc_analysis, + arm_pat.clone(), + rc_analysis.clone(), shared_types.clone(), - si, + si.clone(), emit_info.clone(), ); v1_rt::concat( @@ -17390,7 +17395,7 @@ pub fn emit_typed_if( None, depth.clone(), RenderTarget::Rust, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), |node, d| { emit_typed_expr( node.clone(), @@ -17474,7 +17479,7 @@ pub fn rust_struct_field_type_node( Some(struct_node) => match find_child_named( struct_node.clone(), field_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(field_node) => Some(resolved_type(field_node.clone())), None => None, @@ -17501,10 +17506,8 @@ pub fn rust_receiver_has_callable_method_field( ) -> bool { { let receiver_type = resolved_type(receiver); - let receiver_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - receiver_type, - ); + let receiver_type_name = + authored_name_at(scope.type_env.clone().source_indices.clone(), receiver_type); rust_record_field_needs_fn_rc(scope.clone(), receiver_type_name, method_name) } } @@ -17521,7 +17524,7 @@ pub fn rust_record_field_needs_box( field_type.clone(), emit_info.recursive_type_set.clone(), shared_types, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => false, } @@ -17568,10 +17571,10 @@ pub fn is_already_optional( scope: Rc, ) -> bool { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let n = expr_var_name_at(texpr.clone(), si.clone()); let tn = record_lit_type_name_at(texpr.clone(), si.clone()); - let f = field_access_field_at(texpr.clone(), si); + let f = field_access_field_at(texpr.clone(), si.clone()); match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, @@ -17594,9 +17597,9 @@ pub fn is_already_optional( Some(InferredNode::Resolved { node: rt, .. }) => { (rt.return_cardinality.clone() == Cardinality::CardOptional) } - _ => match v1_rt::map_get(&scope.locals.clone(), n) { + _ => match v1_rt::map_get(&scope.locals.clone(), n.clone()) { Some(binding) => { - ((*binding.resolved).clone().return_cardinality.clone() + (binding.resolved.clone().return_cardinality.clone() == Cardinality::CardOptional) } None => false, @@ -17639,7 +17642,7 @@ pub fn is_already_optional( if is_optional_struct_field( emit_info, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_base, ), f, @@ -17707,7 +17710,7 @@ pub fn lookup_struct_field_type_name( None => None, }; match direct.clone() { - Some(_) => direct, + Some(_) => direct.clone(), None => match variant_name { Some(vn) => { match find_child_named(struct_node.clone(), vn.clone(), source_indices.clone()) @@ -17730,11 +17733,11 @@ pub fn lookup_struct_field_type_name( false }; if ((field_type.ident_span.clone() != None) - && !ft_is_type_var) + && !ft_is_type_var.clone()) { Some(authored_name_at( source_indices.clone(), - field_type, + field_type.clone(), )) } else { None @@ -17773,7 +17776,7 @@ pub fn emit_field_value_with_context( let inner_fields = field_value.children.clone(); let tn = record_lit_type_name_at( field_value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match tn.clone() { Some(variant_name) => { @@ -17781,16 +17784,16 @@ pub fn emit_field_value_with_context( struct_node.clone(), field_name.clone(), outer_type_name, - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let expected_type = match node_lookup.clone() { - Some(_) => node_lookup, + Some(_) => node_lookup.clone(), None => { if (struct_node.ident_span.clone() != None) { match lookup_emit_type_summary( emit_info.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), struct_node.clone(), ), ) { @@ -17820,7 +17823,7 @@ pub fn emit_field_value_with_context( None => pe.clone(), }; let raw = emit_typed_record_lit( - tn, + tn.clone(), inner_fields, corrected_parent.clone(), resolved_type(field_value.clone()), @@ -17830,12 +17833,12 @@ pub fn emit_field_value_with_context( shared_types.clone(), emit_info.clone(), ); - let rc_name = match corrected_parent { + let rc_name = match corrected_parent.clone() { Some(en) => en.clone(), None => variant_name.clone(), }; if ((rc_name.clone() != "".to_string()) - && v1_rt::set_contains(&shared_types, rc_name)) + && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -17916,7 +17919,7 @@ pub fn find_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) <= 1) { - match candidates.first().cloned() { + match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -17951,13 +17954,13 @@ pub fn find_struct_name_by_fields( __result }); if ((typed_candidates.clone().len() as i64) == 1) { - match typed_candidates.first().cloned() { + match typed_candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } } else { match Rc::new({ - let mut __sorted: Vec<_> = candidates.iter().cloned().collect(); + let mut __sorted: Vec<_> = candidates.clone().iter().cloned().collect(); __sorted.sort_by(|a: &Rc, b: &Rc| { let __ka = (|c: Rc| c.name.clone())(a.clone()); let __kb = (|c: Rc| c.name.clone())(b.clone()); @@ -17984,7 +17987,7 @@ pub fn find_unique_struct_name_by_fields( { let candidates = struct_candidates_by_field_names(field_names, type_summaries); if ((candidates.clone().len() as i64) == 1) { - match candidates.first().cloned() { + match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), None => None, } @@ -18010,13 +18013,13 @@ pub fn emit_typed_record_lit( type_name.clone(), resolved_type.clone(), shared_types.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let qualified_name = match struct_name { Some(sn) => Some(sn.clone()), None => { let rt_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type.clone(), ); if ((resolved_type.ident_span.clone() != None) @@ -18037,7 +18040,7 @@ pub fn emit_typed_record_lit( Some(f) => { let fname0 = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval0 = emit_typed_expr( field_init_node_value(f.clone()), @@ -18053,7 +18056,7 @@ pub fn emit_typed_record_lit( for ff in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( ff.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18086,7 +18089,7 @@ pub fn emit_typed_record_lit( " {\n ".to_string(), ), emit_ident( - fname0, + fname0.clone(), RenderTarget::Rust, ), ), @@ -18127,7 +18130,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18137,7 +18140,7 @@ pub fn emit_typed_record_lit( |acc: Rc>, f: Rc| { let fname = field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = field_init_node_value(f.clone()); match fval.inferred.clone().as_deref().cloned() { @@ -18147,7 +18150,7 @@ pub fn emit_typed_record_lit( acc.clone(), fname.clone(), authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ), @@ -18167,10 +18170,7 @@ pub fn emit_typed_record_lit( __result.push({ let fname = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let fval = emit_typed_expr( field_init_node_value(f.clone()), @@ -18251,20 +18251,20 @@ pub fn emit_typed_record_lit( } } Some(tn) => { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let tn_is_known_struct = v1_rt::map_contains_key(&emit_info.type_summaries.clone(), tn.clone()); let ctor_name = if tn_is_known_struct { tn.clone() } else { { - let resolved_struct = (*resolve_node( + let resolved_struct = resolve_node( resolved_type.clone(), scope.type_env.clone(), scope.module_name.clone(), ) - .resolved) - .clone(); + .resolved + .clone(); if (resolved_struct.connective.clone() == Connective::Conj) { { let resolved_field_names = Rc::new({ @@ -18320,7 +18320,7 @@ pub fn emit_typed_record_lit( rt_name.clone(), )) { - Some(rt_name) + Some(rt_name.clone()) } else { parent_enum.clone() } @@ -18423,7 +18423,7 @@ pub fn emit_typed_record_lit( None => ctor_name.clone(), } }; - if ((optional_variant && (tn.clone() == "Present".to_string())) + if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -18448,7 +18448,7 @@ pub fn emit_typed_record_lit( if ((fields.clone().len() as i64) == 0) { { let host_freemonoid_carrier = - authored_name_at(si, resolved_type.clone()); + authored_name_at(si.clone(), resolved_type.clone()); match rust_seed_host_freemonoid_empty( host_freemonoid_carrier, emit_info.corpus_repr.clone(), @@ -18459,7 +18459,7 @@ pub fn emit_typed_record_lit( } } else { { - let variant_summary_name = match effective_parent { + let variant_summary_name = match effective_parent.clone() { Some(parent) => variant_summary_key(parent.clone(), tn.clone()), None => ctor_name.clone(), }; @@ -18488,25 +18488,25 @@ pub fn emit_typed_record_lit( ); let needs_wrap = (is_optional_struct_field( emit_info.clone(), - variant_summary_name, + variant_summary_name.clone(), "0".to_string(), ) && (is_already_optional( - f_value, + f_value.clone(), emit_info.clone(), scope.clone(), ) == false)); - let field_val = if needs_wrap { + let field_val = if needs_wrap.clone() { v1_rt::concat( - v1_rt::concat("Some(".to_string(), val_str), + v1_rt::concat("Some(".to_string(), val_str.clone()), ")".to_string(), ) } else { - val_str + val_str.clone() }; v1_rt::concat( v1_rt::concat( v1_rt::concat(display_tn, "(".to_string()), - field_val, + field_val.clone(), ), ")".to_string(), ) @@ -18521,10 +18521,7 @@ pub fn emit_typed_record_lit( __result.push({ let f_name = field_init_node_name_at( f.clone(), - (*scope.type_env) - .clone() - .source_indices - .clone(), + scope.type_env.clone().source_indices.clone(), ); let f_value = field_init_node_value(f.clone()); let val_str = emit_field_value_with_context( @@ -18591,7 +18588,7 @@ pub fn emit_typed_record_lit( for f in fields.clone().iter().cloned() { __result.push(field_init_node_name_at( f.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -18657,7 +18654,7 @@ pub fn emit_typed_record_lit( if all_defaultable { Rc::new({ let mut __result = Vec::new(); - for fname in missing.iter().cloned() { + for fname in missing.clone().iter().cloned() { __result.extend((*if is_optional_struct_field(emit_info.clone(), variant_summary_name.clone(), fname.clone()) { Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { @@ -18699,7 +18696,7 @@ pub fn emit_typed_record_lit( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - si, + si.clone(), ); let has_unused = ((unused.len() as i64) > 0); if (is_struct && has_unused) { @@ -18729,7 +18726,7 @@ pub fn emit_typed_record_lit( "\n}".to_string(), ); if (ctor_alias_resolved - && v1_rt::set_contains(&shared_types, ctor_name)) + && v1_rt::set_contains(&shared_types, ctor_name.clone())) { v1_rt::concat( v1_rt::concat("Rc::new(".to_string(), raw), @@ -18810,14 +18807,14 @@ pub fn emit_typed_bin_op( op.clone(), left.clone(), right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { { let l_optional = is_optional_typed_expr(left.clone()); let r_optional = is_optional_typed_expr(right.clone()); if (l_optional.clone() || r_optional.clone()) { { - let l_cmp = if l_optional { + let l_cmp = if l_optional.clone() { v1_rt::concat(l_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18831,7 +18828,7 @@ pub fn emit_typed_bin_op( ").as_deref()".to_string(), ) }; - let r_cmp = if r_optional { + let r_cmp = if r_optional.clone() { v1_rt::concat(r_str, ".as_deref()".to_string()) } else { v1_rt::concat( @@ -18853,7 +18850,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_cmp), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -18877,7 +18874,7 @@ pub fn emit_typed_bin_op( ), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -18894,10 +18891,10 @@ pub fn emit_typed_bin_op( { let both_string = (is_string_typed_expr( left.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && is_string_typed_expr( right.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string); if is_str_concat { @@ -18909,7 +18906,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str, + op_str.clone(), ), " &".to_string(), ), @@ -18926,7 +18923,7 @@ pub fn emit_typed_bin_op( v1_rt::concat("(".to_string(), l_str), " ".to_string(), ), - op_str, + op_str.clone(), ), " ".to_string(), ), @@ -19037,7 +19034,7 @@ pub fn emit_typed_string_interp( let mut __result = Vec::new(); for a in Rc::new({ let mut __result = Vec::new(); - for p in fmt_parts.iter().cloned() { + for p in fmt_parts.clone().iter().cloned() { __result.push(p.arg_expr.clone()); } __result @@ -19058,7 +19055,7 @@ pub fn emit_typed_string_interp( ) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); emit_rust_host_to_dag_string_via_seam( v1_rt::concat( v1_rt::concat( @@ -19155,7 +19152,7 @@ pub fn emit_tco_init_block_stmts( match remaining.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -19171,7 +19168,7 @@ pub fn emit_tco_init_block_stmts( match rest.clone().first().cloned() { None => { break Rc::new(BlockEmitState { - text: text.clone(), + text: text, scope: scope.clone(), }); } @@ -19188,8 +19185,8 @@ pub fn emit_tco_init_block_stmts( let next_scope = scope_after_expr(stmt.clone(), scope.clone()); { let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line.clone()); - let __tco_2 = next_scope.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; remaining = __tco_0; text = __tco_1; scope = __tco_2; @@ -19213,10 +19210,8 @@ pub fn emit_tco_init_stmt( ) -> String { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { - let n = let_binding_name_at( - stmt.clone(), - (*scope.type_env).clone().source_indices.clone(), - ); + let n = + let_binding_name_at(stmt.clone(), scope.type_env.clone().source_indices.clone()); let v = let_value(stmt.clone()); let val_str = emit_typed_expr( v, @@ -19232,7 +19227,7 @@ pub fn emit_tco_init_stmt( for p in params.iter().cloned() { if (param_node_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19244,13 +19239,13 @@ pub fn emit_tco_init_stmt( if is_param { v1_rt::concat( v1_rt::concat( - v1_rt::concat(emit_ident(n, RenderTarget::Rust), " = ".to_string()), + v1_rt::concat(emit_ident(n.clone(), RenderTarget::Rust), " = ".to_string()), val_str, ), ";".to_string(), ) } else { - emit_let_binding(n, val_str, RenderTarget::Rust) + emit_let_binding(n.clone(), val_str, RenderTarget::Rust) } } _ => emit_typed_expr( @@ -19302,18 +19297,15 @@ pub fn emit_rust_tco_non_self_call( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let call_str = emit_typed_call( f, - (*frame.expr).clone().children.clone(), + frame.expr.clone().children.clone(), registry, frame.scope.clone(), frame.depth.clone(), @@ -19340,7 +19332,7 @@ pub fn emit_rust_tco_if( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); let t = if_then_branch(frame.expr.clone()); @@ -19450,7 +19442,7 @@ pub fn freemonoid_tco_empty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; @@ -19493,7 +19485,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), head_bind), + v1_rt::concat("let ".to_string(), head_bind.clone()), " = (*__fm)[0].clone(); ".to_string(), ) }; @@ -19501,7 +19493,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), tail_bind), + v1_rt::concat("let ".to_string(), tail_bind.clone()), ": Rc> = Rc::new((*__fm)[1..].to_vec()); ".to_string(), ) }; @@ -19526,7 +19518,7 @@ pub fn freemonoid_tco_nonempty_branch_body( "".to_string() } else { v1_rt::concat( - v1_rt::concat("let ".to_string(), bn), + v1_rt::concat("let ".to_string(), bn.clone()), " = __fm.clone(); ".to_string(), ) }; @@ -19561,7 +19553,7 @@ pub fn emit_native_freemonoid_tco_match( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let empty_arm = freemonoid_match_arm_for(arms.clone(), "Empty".to_string()); let cons_arm = freemonoid_match_arm_for(arms.clone(), "Cons".to_string()); let catchall = freemonoid_catchall_arm(arms.clone()); @@ -19578,7 +19570,7 @@ pub fn emit_native_freemonoid_tco_match( ); let nonempty_body = freemonoid_tco_nonempty_branch_body( cons_arm, - catchall, + catchall.clone(), si, fn_name.clone(), params.clone(), @@ -19599,11 +19591,11 @@ pub fn emit_native_freemonoid_tco_match( v1_rt::concat("{ let __fm = ".to_string(), scrut_str), "; if __fm.is_empty() { ".to_string(), ), - empty_body, + empty_body.clone(), ), " } else { ".to_string(), ), - nonempty_body, + nonempty_body.clone(), ), " } }".to_string(), ) @@ -19619,7 +19611,7 @@ pub fn emit_rust_tco_match( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); let arm_list = match_arm_nodes(frame.expr.clone()); @@ -19637,18 +19629,12 @@ pub fn emit_rust_tco_match( let is_optional = (rt.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), with_required_cardinality(rt.clone()), ) } else { authored_name_at( - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), rt.clone(), ) } @@ -19676,19 +19662,16 @@ pub fn emit_rust_tco_match( "".to_string() }; if (native_tco_fm.clone() != "".to_string()) { - native_tco_fm + native_tco_fm.clone() } else { { let rc_match = analyze_rc_match( - s, + s.clone(), arm_list.clone(), tco_scrut_type.clone(), shared_types.clone(), emit_info.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let arm_strs = Rc::new({ let mut __result = Vec::new(); @@ -19709,14 +19692,14 @@ pub fn emit_rust_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let tco_needs_as_str = (all_arms_are_string_lit(arm_list.clone()) - && ((arm_list.len() as i64) > 0)); + && ((arm_list.clone().len() as i64) > 0)); if rc_match.needs_option_deref.clone() { v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_deref()".to_string(), ), clone_iterator_suffix(), @@ -19738,7 +19721,7 @@ pub fn emit_rust_tco_match( "match ".to_string(), apply_type_template1( sharing.deref_clone.clone(), - scrut_str, + scrut_str.clone(), ), ), " {\n".to_string(), @@ -19753,7 +19736,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), ".as_str() {\n".to_string(), ), arms_str, @@ -19764,7 +19747,7 @@ pub fn emit_rust_tco_match( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("match ".to_string(), scrut_str), + v1_rt::concat("match ".to_string(), scrut_str.clone()), " {\n".to_string(), ), arms_str, @@ -19792,14 +19775,11 @@ pub fn emit_rust_tco_let( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( frame.expr.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ); let v = let_value(frame.expr.clone()); let bd = let_body(frame.expr.clone()); @@ -19817,10 +19797,7 @@ pub fn emit_rust_tco_let( for p in params.clone().iter().cloned() { if (param_node_name_at( p.clone(), - (*frame.scope.clone().type_env) - .clone() - .source_indices - .clone(), + frame.scope.clone().type_env.clone().source_indices.clone(), ) == n.clone()) { __found = true; @@ -19854,8 +19831,8 @@ pub fn emit_rust_tco_let( }; let next_scope = extend_scope( frame.scope.clone(), - n, - resolved_type(v), + n.clone(), + resolved_type(v.clone()), Rc::new(SubValueRelation::SubValueUnknown), ); match bd { @@ -19890,9 +19867,9 @@ pub fn emit_rust_tco_block( shared_types: Rc>, emit_info: Rc, ) -> String { - match (*(*frame.expr).clone().expr_data.clone()).clone() { + match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { - let ss = (*frame.expr).clone().children.clone(); + let ss = frame.expr.clone().children.clone(); if ((ss.clone().len() as i64) == 0) { "break;".to_string() } else { @@ -19907,7 +19884,7 @@ pub fn emit_rust_tco_block( emit_info.clone(), params.clone(), ); - let last_str = match ss.last().cloned() { + let last_str = match ss.clone().last().cloned() { Some(last_expr) => emit_typed_tco_expr( last_expr.clone(), fn_name, @@ -20066,7 +20043,7 @@ pub fn emit_typed_tco_match_arm( let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); let arm_b = arm_body(arm.clone()); - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let rc_analysis = analyze_rc_pattern( arm_pat.clone(), scrut_type.clone(), @@ -20113,17 +20090,17 @@ pub fn emit_typed_tco_match_arm( { v1_rt::concat( v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards), + v1_rt::concat(" if ".to_string(), field_guards.clone()), " && ".to_string(), ), - arm_guard_str, + arm_guard_str.clone(), ) } else { if (field_guards.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), field_guards) + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { if (arm_guard_str.clone() != "".to_string()) { - v1_rt::concat(" if ".to_string(), arm_guard_str) + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() } @@ -20142,10 +20119,10 @@ pub fn emit_typed_tco_match_arm( if rc_analysis.needs_rc_pattern.clone() { { let prelude = rc_pattern_preludes( - arm_pat, - rc_analysis, + arm_pat.clone(), + rc_analysis.clone(), shared_types.clone(), - si, + si.clone(), emit_info.clone(), ); v1_rt::concat( @@ -20192,7 +20169,7 @@ pub fn expr_references_var( match (*node.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(node.clone(), source_indices) == var_name), + } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -20217,7 +20194,7 @@ pub fn emit_typed_tco_reassign( emit_info: Rc, ) -> String { { - let si = (*scope.type_env).clone().source_indices.clone(); + let si = scope.type_env.clone().source_indices.clone(); let arg_values = Rc::new({ let mut __result = Vec::new(); for a in args.iter().cloned() { @@ -20332,7 +20309,7 @@ pub fn emit_typed_tco_reassign( }); let ordered_args = Rc::new({ let mut __result = Vec::new(); - for av in filtered_arg_values.iter().cloned() { + for av in filtered_arg_values.clone().iter().cloned() { __result.push(emit_typed_expr( av.clone(), registry.clone(), @@ -20347,7 +20324,7 @@ pub fn emit_typed_tco_reassign( }); let param_names = Rc::new({ let mut __result = Vec::new(); - for p in filtered_params.iter().cloned() { + for p in filtered_params.clone().iter().cloned() { __result.push(emit_ident( param_node_name_at(p.clone(), si.clone()), RenderTarget::Rust, @@ -20394,9 +20371,9 @@ pub fn emit_service_def( env.source_indices.clone(), ); let impl_block = emit_service_impl( - safe_name, - fallback_transport, - op_children, + safe_name.clone(), + fallback_transport.clone(), + op_children.clone(), registry, shared_types, corpus_repr, @@ -20461,12 +20438,14 @@ pub fn emit_service_config_fields( } else { fs.clone() }; - let decls = - service_field_decls(fs, language_spec(RenderTarget::Rust).service_fields.clone()); + let decls = service_field_decls( + fs.clone(), + language_spec(RenderTarget::Rust).service_fields.clone(), + ); if ((decls.clone().len() as i64) == 0) { " // No configuration needed for local binding.\n".to_string() } else { - decls.join(&"".to_string()) + decls.clone().join(&"".to_string()) } } } @@ -20516,7 +20495,7 @@ pub fn emit_service_impl( v1_rt::concat("impl ".to_string(), name.clone()), " {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), methods_str, ), @@ -20567,7 +20546,7 @@ pub fn emit_service_new_method( None => "".to_string(), }; let base_url_default = if (from_config.clone() != "".to_string()) { - from_config + from_config.clone() } else { if fs.has_rest.clone() { { @@ -20592,7 +20571,7 @@ pub fn emit_service_new_method( "".to_string() }; if (from_fallback.clone() != "".to_string()) { - from_fallback + from_fallback.clone() } else { "http://localhost".to_string() } @@ -20601,8 +20580,10 @@ pub fn emit_service_new_method( "".to_string() } }; - let ctors = - service_field_ctors(fs, language_spec(RenderTarget::Rust).service_fields.clone()); + let ctors = service_field_ctors( + fs.clone(), + language_spec(RenderTarget::Rust).service_fields.clone(), + ); let ctors = Rc::new({ let mut __result = Vec::new(); for c in ctors.clone().iter().cloned() { @@ -20624,7 +20605,7 @@ pub fn emit_service_new_method( }), None => ctors.clone(), }; - let inits = ctors.join(&"".to_string()); + let inits = ctors.clone().join(&"".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -20684,7 +20665,10 @@ pub fn emit_modifier_doc_from_props( "".to_string() } else { v1_rt::concat( - v1_rt::concat("/// Modifiers: ".to_string(), names.join(&", ".to_string())), + v1_rt::concat( + "/// Modifiers: ".to_string(), + names.clone().join(&", ".to_string()), + ), "\n".to_string(), ) } @@ -20732,7 +20716,7 @@ pub fn emit_operation_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str) + v1_rt::concat("&self, ".to_string(), params_str.clone()) }; let ret_type = render_rust_type( resolved_type(op_node.clone()), @@ -20828,7 +20812,7 @@ pub fn emit_operation_method( ), " ".to_string(), ), - emit_ident(op_text, RenderTarget::Rust), + emit_ident(op_text.clone(), RenderTarget::Rust), ), "(".to_string(), ), @@ -20924,7 +20908,7 @@ match ch.return_cardinality.clone() { _ => raw.clone(), } }); } __result }); -let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); +let field_names = Rc::new({ let mut __result = Vec::new(); for ch in children.clone().iter().cloned() { __result.push(emit_ident(authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust)); } __result }); let result_body = v1_rt::concat(v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), ")".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(log_line, "\n".to_string()), prelude), extract_lines.join(&"\n".to_string())), "\nOk(".to_string()), result_body), ")".to_string()) } @@ -21168,7 +21152,7 @@ pub fn emit_rest_url_line( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.iter().cloned() { + for p in parts.clone().iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -21201,7 +21185,7 @@ pub fn emit_rest_url_line( ) } else { { - let args_str = args.join(&", ".to_string()); + let args_str = args.clone().join(&", ".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21356,7 +21340,7 @@ pub fn emit_rest_query_line( v1_rt::concat( v1_rt::concat( "let request = request.query(&[".to_string(), - pairs.join(&", ".to_string()), + pairs.clone().join(&", ".to_string()), ), "]);".to_string(), ) @@ -21383,11 +21367,11 @@ if (((req_strs.clone().len() as i64) == 0) && ((optional_fields.clone().len() as } else { { let body_init = if ((req_strs.clone().len() as i64) > 0) { - v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.join(&", ".to_string())), " });".to_string()) + v1_rt::concat(v1_rt::concat("let mut __body = serde_json::json!({ ".to_string(), req_strs.clone().join(&", ".to_string())), " });".to_string()) } else { "let mut __body = serde_json::json!({});".to_string() }; -let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.iter().cloned() { __result.push({ +let opt_lines = Rc::new({ let mut __result = Vec::new(); for fi in optional_fields.clone().iter().cloned() { __result.push({ let fname = field_init_node_name_at(fi.clone(), source_indices.clone()); let fexpr = emit_simple_expr(field_init_node_value(fi.clone()), RenderTarget::Rust, source_indices.clone()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("if let Some(ref __v) = ".to_string(), fexpr.clone()), " { __body[\"".to_string()), fname.clone()), "\"] = serde_json::json!(__v); }".to_string()) @@ -21508,12 +21492,14 @@ pub fn operation_response_200_resolved_type( match v.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: tn, .. }) => Some(tn.clone()), _ => { - let type_name = - authored_name_at(source_indices.clone(), normalize_access_type_node(v)); + let type_name = authored_name_at( + source_indices.clone(), + normalize_access_type_node(v.clone()), + ); if (type_name.clone() == "".to_string()) { None } else { - lookup_type_by_name(env, type_name) + lookup_type_by_name(env, type_name.clone()) } } } @@ -21533,7 +21519,8 @@ pub fn is_json_wire_declaration_type( } else { { let parts = Rc::new( - n.split(&".".to_string()) + n.clone() + .split(&".".to_string()) .map(|s| s.to_string()) .collect::>(), ); @@ -21830,7 +21817,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type == "bool".to_string()) { + if (rust_type.clone() == "bool".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -21945,7 +21932,7 @@ match ch.inferred.clone().as_deref().cloned() { }); let field_names = Rc::new({ let mut __result = Vec::new(); - for ch in children.iter().cloned() { + for ch in children.clone().iter().cloned() { __result.push(emit_ident( authored_name_at(source_indices.clone(), ch.clone()), RenderTarget::Rust, @@ -21957,13 +21944,13 @@ match ch.inferred.clone().as_deref().cloned() { v1_rt::concat( v1_rt::concat( "(".to_string(), - field_names.first().cloned().clone().unwrap(), + field_names.clone().first().cloned().clone().unwrap(), ), ",)".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("(".to_string(), field_names.join(&", ".to_string())), + v1_rt::concat("(".to_string(), field_names.clone().join(&", ".to_string())), ")".to_string(), ) }; @@ -22022,22 +22009,22 @@ pub fn emit_response_code_handling( __result }); if ((response_props.clone().len() as i64) == 0) { - if use_from_key { + if use_from_key.clone() { emit_from_key_extraction( op_node.clone(), source_indices.clone(), - shared_types, - corpus_repr, - env, + shared_types.clone(), + corpus_repr.clone(), + env.clone(), ) } else { - emit_plain_response_body(op_node.clone(), transport, source_indices.clone()) + emit_plain_response_body(op_node.clone(), transport.clone(), source_indices.clone()) } } else { { let arms = Rc::new({ let mut __result = Vec::new(); - for p in response_props.iter().cloned() { + for p in response_props.clone().iter().cloned() { __result.push(emit_response_arm( p.clone(), op_node.clone(), @@ -22097,12 +22084,15 @@ pub fn emit_response_arm( { let prefix = v1_rt::substring(&code_str, 0, 1); v1_rt::concat( - v1_rt::concat(v1_rt::concat(prefix.clone(), "00..=".to_string()), prefix), + v1_rt::concat( + v1_rt::concat(prefix.clone(), "00..=".to_string()), + prefix.clone(), + ), "99".to_string(), ) } } else { - code_str + code_str.clone() } }; if is_success { @@ -22166,7 +22156,7 @@ pub fn emit_exit_code_handling( __result }); if ((exit_props.clone().len() as i64) == 0) { - emit_shell_return(inferred, source_indices) + emit_shell_return(inferred.clone(), source_indices.clone()) } else { { let has_nonzero = { @@ -22183,7 +22173,7 @@ pub fn emit_exit_code_handling( }; let exit_arms = Rc::new({ let mut __result = Vec::new(); - for p in exit_props.iter().cloned() { + for p in exit_props.clone().iter().cloned() { __result.push(emit_exit_arm( p.clone(), inferred.clone(), @@ -22230,7 +22220,7 @@ pub fn emit_exit_arm( } else { code_str.clone() }; - let is_success = (code_str == "0".to_string()); + let is_success = (code_str.clone() == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -22326,9 +22316,15 @@ pub fn emit_shell_call( let arg_lines = if ((argv.clone().len() as i64) > 1) { Rc::new({ let mut __result = Vec::new(); - for arg in Rc::new(argv.iter().cloned().skip(1 as usize).collect::>()) - .iter() - .cloned() + for arg in Rc::new( + argv.clone() + .iter() + .cloned() + .skip(1 as usize) + .collect::>(), + ) + .iter() + .cloned() { __result.push(v1_rt::concat( v1_rt::concat( @@ -22373,7 +22369,7 @@ pub fn emit_shell_call( __result }); let wd_line = " .current_dir(self.working_dir.as_deref().unwrap_or(\".\"))".to_string(); - if has_stdin { + if has_stdin.clone() { { let stdin_expr = transport_stdin(transport.clone(), source_indices.clone()) .clone() @@ -22382,10 +22378,14 @@ pub fn emit_shell_call( ExprData::ExprVar { binding_kind: _, .. } => emit_ident( - expr_var_name_at(stdin_expr, source_indices.clone()), + expr_var_name_at(stdin_expr.clone(), source_indices.clone()), RenderTarget::Rust, ), - _ => emit_simple_expr(stdin_expr, RenderTarget::Rust, source_indices.clone()), + _ => emit_simple_expr( + stdin_expr.clone(), + RenderTarget::Rust, + source_indices.clone(), + ), }; let spawn_line = " .stdin(std::process::Stdio::piped())\n .stdout(std::process::Stdio::piped())\n .stderr(std::process::Stdio::piped())".to_string(); let spawn_exec = " .spawn()?;".to_string(); @@ -22483,7 +22483,7 @@ pub fn emit_shell_argv_element( let fmt_str = fmt_segments.join(&"".to_string()); let args = Rc::new({ let mut __result = Vec::new(); - for p in parts.iter().cloned() { + for p in parts.clone().iter().cloned() { __result.extend( (*match (*p.clone()).clone() { StringPart::Text { value: _, .. } => Rc::new(vec![]), @@ -22526,23 +22526,23 @@ pub fn emit_shell_argv_element( ExprData::ExprVar { binding_kind: _, .. } => { - let name = expr_var_name_at(arg.clone(), source_indices); + let name = expr_var_name_at(arg.clone(), source_indices.clone()); let var_name = emit_ident(name.clone(), RenderTarget::Rust); let is_opt = (is_optional_typed_expr(arg.clone()) - || match v1_rt::map_get(&optional_params, name) { + || match v1_rt::map_get(&optional_params, name.clone()) { Some(_) => true, None => false, }); - if is_opt { + if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( - v1_rt::concat(var_name, ".as_deref().unwrap_or(\"\")".to_string()), + v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name, corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) } } - _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices), + _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), } } @@ -22566,10 +22566,10 @@ pub fn emit_shell_return( Some(channel) => { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr(channel.clone(), is_optional) + emit_shell_channel_expr(channel.clone(), is_optional.clone()) } None => { - if (is_product && ((effective.children.clone().len() as i64) > 1)) { + if (is_product.clone() && ((effective.children.clone().len() as i64) > 1)) { { let needs_stderr = { let mut __found = false; @@ -22607,7 +22607,7 @@ pub fn emit_shell_return( __result }); let lines = if (stderr_line.clone() != "".to_string()) { - v1_rt::concat(stderr_line, "\n".to_string()) + v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() }; @@ -22623,7 +22623,7 @@ pub fn emit_shell_return( { let is_optional = (effective.return_cardinality.clone() == Cardinality::CardOptional); - emit_shell_channel_expr("stdout".to_string(), is_optional) + emit_shell_channel_expr("stdout".to_string(), is_optional.clone()) } } } @@ -22662,10 +22662,10 @@ pub fn unwrap_single_field_product(n: Rc) -> Rc { { match n.children.clone().first().cloned() { Some(field_node) => resolved_type(field_node.clone()), - None => n, + None => n.clone(), } } else { - n + n.clone() } } } @@ -22730,7 +22730,7 @@ pub fn emit_resource_def( let depth = 0; let cap_methods = Rc::new({ let mut __result = Vec::new(); - for c in cap_children.iter().cloned() { + for c in cap_children.clone().iter().cloned() { __result.push(emit_capability_method( c.clone(), shared_types.clone(), @@ -22797,7 +22797,7 @@ pub fn emit_capability_method( let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { - v1_rt::concat("&self, ".to_string(), params_str) + v1_rt::concat("&self, ".to_string(), params_str.clone()) }; let ret = render_rust_type( resolved_type(cap_node.clone()), @@ -22874,9 +22874,8 @@ pub fn data_def_annotation_is_named_refinement( ) -> bool { { let ann_name = authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) - && (annotation.type_annotation.clone() != None)) - && !is_container_type(ann_name)) + ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + && !is_container_type(ann_name.clone())) && !is_host_text_carrier_type( annotation.clone(), source_indices.clone(), @@ -22907,13 +22906,13 @@ pub fn emit_data_def( }; let raw_ty_str = if data_def_annotation_is_named_refinement( annotation_type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { coerce_primitive_type( RenderTarget::Rust, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), - annotation_type_node, + scope.type_env.clone().source_indices.clone(), + annotation_type_node.clone(), ), ) } else { @@ -22921,7 +22920,7 @@ pub fn emit_data_def( render_type_node, shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) }; let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) @@ -22930,39 +22929,42 @@ pub fn emit_data_def( match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(top_value) => { let top_type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); if (top_type_name.clone() == "".to_string()) { - raw_ty_str + raw_ty_str.clone() } else { - if (raw_ty_str == "Rc".to_string()) { + if (raw_ty_str.clone() == "Rc".to_string()) { v1_rt::concat( - v1_rt::concat("Rc>".to_string(), ) } else { v1_rt::concat( - v1_rt::concat("BoundedLattice<".to_string(), top_type_name), + v1_rt::concat("BoundedLattice<".to_string(), top_type_name.clone()), ">".to_string(), ) } } } - None => raw_ty_str, + None => raw_ty_str.clone(), } } else { - raw_ty_str + raw_ty_str.clone() }; let fn_name = to_snake(name); let needs_rc = v1_rt::set_contains( &shared_types, authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ), ); @@ -22973,16 +22975,16 @@ pub fn emit_data_def( }; if (is_simple_type_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) || rust_nominal_identity_carrier_type_eligible(authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ))) { { let val_str = match rust_nominal_identity_data_expr( type_node.clone(), value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(identity_expr) => identity_expr.clone(), None => emit_typed_expr( @@ -23010,7 +23012,7 @@ pub fn emit_data_def( ), "() -> ".to_string(), ), - ty_str, + ty_str.clone(), ), " { ".to_string(), ), @@ -23029,10 +23031,10 @@ pub fn emit_data_def( depth, shared_types.clone(), emit_info.clone(), - needs_rc, + needs_rc.clone(), ); let kw = rust_items().func_keyword.clone(); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str), "| c.clone())\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw), " ".to_string()), fn_name), "() -> ".to_string()), ty_str.clone()), " {\n".to_string()), " thread_local! {\n".to_string()), " static CACHED: ".to_string()), ty_str.clone()), " = {\n".to_string()), body), "\n".to_string()), " };\n".to_string()), " }\n".to_string()), " CACHED.with(|c: &".to_string()), ty_str.clone()), "| c.clone())\n".to_string()), "}".to_string()) } } } @@ -23057,7 +23059,7 @@ pub fn rust_nominal_identity_data_expr( let symbol_name = expr_var_name_at(value.clone(), source_indices.clone()); Some(v1_rt::concat( v1_rt::concat( - v1_rt::concat(type_name, "(\"".to_string()), + v1_rt::concat(type_name.clone(), "(\"".to_string()), escape_string_literal_body(symbol_name), ), "\".to_string())".to_string(), @@ -23086,10 +23088,10 @@ pub fn emit_data_def_body( type_node.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let type_name = authored_name_at( - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), type_node.clone(), ); if (type_name == "BoundedLattice".to_string()) { @@ -23098,19 +23100,19 @@ pub fn emit_data_def_body( let lattice_value = field_value_by_name( value.clone(), "lattice".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let meet_value = match field_value_by_name( value.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "meet".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23118,14 +23120,14 @@ pub fn emit_data_def_body( let join_value = match field_value_by_name( value.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => match lattice_value { + None => match lattice_value.clone() { Some(lattice) => field_value_by_name( lattice.clone(), "join".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ), None => None, }, @@ -23157,7 +23159,7 @@ pub fn emit_data_def_body( let top_str = match field_value_by_name( value.clone(), "top".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23173,7 +23175,7 @@ pub fn emit_data_def_body( let bottom_str = match field_value_by_name( value.clone(), "bottom".to_string(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(n) => emit_typed_expr( n.clone(), @@ -23198,7 +23200,7 @@ pub fn emit_data_def_body( for p in struct_decl.params.clone().iter().cloned() { __result.push(generic_param_name_at( p.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), )); } __result @@ -23206,7 +23208,7 @@ pub fn emit_data_def_body( let unused = struct_unused_param_names( pnames, struct_decl.children.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if ((struct_decl.connective.clone() == Connective::Conj) && ((unused.len() as i64) > 0)) @@ -23226,13 +23228,13 @@ pub fn emit_data_def_body( } else { if (has_nested_records_node( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) && !data_value_has_cross_refs(value.clone())) { { let json_str = emit_data_value_json( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); v1_rt::concat( v1_rt::concat( @@ -23249,14 +23251,14 @@ pub fn emit_data_def_body( { let is_map = node_is_keyed_collection( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); if is_map { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let key_is_string = map_literal_key_is_string( type_node.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); let inserts = Rc::new({ let mut __result = Vec::new(); @@ -23279,7 +23281,8 @@ pub fn emit_data_def_body( emit_rust_map_literal_key( field_init_node_name_at( f.clone(), - (*scope.type_env) + scope + .type_env .clone() .source_indices .clone(), @@ -23321,7 +23324,7 @@ pub fn emit_data_def_body( emit_info.clone(), 1024, ); - v1_rt::concat(" ".to_string(), val_str) + v1_rt::concat(" ".to_string(), val_str.clone()) } } } else { @@ -23343,17 +23346,17 @@ pub fn emit_data_def_body( } => { let vname = expr_var_name_at( value.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ); match effective_variant_parent( vname.clone(), bk.clone(), value.inferred.clone(), emit_info.clone(), - (*scope.type_env).clone().source_indices.clone(), + scope.type_env.clone().source_indices.clone(), ) { Some(enum_name) => variant_ref_self_wraps( - vname, + vname.clone(), enum_name.clone(), shared_types.clone(), emit_info.corpus_repr.clone(), @@ -23368,7 +23371,7 @@ pub fn emit_data_def_body( } else { "".to_string() }; - let wrap_end = if (needs_rc.clone() && !is_already_wrapped) { + let wrap_end = if (needs_rc.clone() && !is_already_wrapped.clone()) { ")".to_string() } else { "".to_string() @@ -23376,7 +23379,7 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat(" ".to_string(), wrap_start), - val_str, + val_str.clone(), ), wrap_end, ) @@ -23414,7 +23417,7 @@ pub fn emit_test_file( } else { { let filename = module_to_filename(module_name.clone()); - let tests_str = test_fns.join(&"\n\n".to_string()); + let tests_str = test_fns.clone().join(&"\n\n".to_string()); let content = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -23436,7 +23439,7 @@ pub fn emit_test_file( ), " use super::*;\n\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), tests_str, ), @@ -23544,9 +23547,9 @@ pub fn emit_operation_test( let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { - args_str + args_str.clone() }; - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent), "assert!(result.is_ok(), \"".to_string()), struct_name), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_async_test_decorator(), "\nasync fn ".to_string()), test_name), "() {\n".to_string()), indent.clone()), rust_test_signature_comment(projection.clone(), corpus_repr)), "\n".to_string()), indent.clone()), "let service = ".to_string()), struct_name.clone()), "::new(crate::dry_run::DryRunMode(true));\n".to_string()), indent.clone()), "let result = service.".to_string()), emit_ident(op_method, RenderTarget::Rust)), "(".to_string()), call_args), ").await;\n".to_string()), indent.clone()), "assert!(result.is_ok(), \"".to_string()), struct_name.clone()), ".".to_string()), projection.operation_name.clone()), " should succeed in dry-run mode: {:?}\", result.err());\n".to_string()), "}".to_string()) } } @@ -23562,7 +23565,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name, + type_name.clone(), ), "\")".to_string(), ), @@ -23570,7 +23573,7 @@ pub fn emit_rust_default_value( None => v1_rt::concat( v1_rt::concat( "compile_error!(\"no test default for type: ".to_string(), - type_name, + type_name.clone(), ), "\")".to_string(), ), @@ -23826,7 +23829,7 @@ pub fn to_workflow_func( None => v1_rt::rc_empty_set::(), }; Rc::new(WorkflowFunc { - name: item_name, + name: item_name.clone(), module_name: module_name.clone(), params: item.params.clone(), inferred: resolved_type(item.clone()), @@ -23878,7 +23881,7 @@ pub fn collect_workflow_funcs( if is_workflow_item( item.clone(), registry.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), ) { __result.push(item); } @@ -23891,12 +23894,12 @@ pub fn collect_workflow_funcs( __result.push(to_workflow_func( item.clone(), authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), ), registry.clone(), tm.items.clone(), - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), read_only_params_index.clone(), )); } @@ -23969,7 +23972,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc module_to_filename(authored_name_at( - (*tm.type_env).clone().source_indices.clone(), + tm.type_env.clone().source_indices.clone(), tm.module.clone(), )), None => "".to_string(), @@ -24006,10 +24009,8 @@ pub fn emit_main_rs( let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at( - (*m.type_env).clone().source_indices.clone(), - m.module.clone(), - ) == "v1.compiler.compile".to_string()) + if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -24144,12 +24145,12 @@ pub fn emit_main_rs( "".to_string() }; let resource_use = if (resource_imports_str.clone() != "".to_string()) { - v1_rt::concat(resource_imports_str, "\n".to_string()) + v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) } else { "".to_string() }; let svc_use = if (svc_imports_str.clone() != "".to_string()) { - v1_rt::concat(svc_imports_str, "\n".to_string()) + v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) } else { "".to_string() }; @@ -24197,7 +24198,7 @@ pub fn emit_main_rs( has_pipeline.clone(), crate_name.clone(), ); - let diagnostic_fns = if has_pipeline { + let diagnostic_fns = if has_pipeline.clone() { emit_main_diagnostic_fns(crate_name.clone()) } else { "".to_string() @@ -24284,7 +24285,7 @@ pub fn emit_main_mod_uses( { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); let core_mod = module_to_filename("v1.std.core".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(base, "\nuse std::collections::HashMap;\n".to_string()), "use std::rc::Rc;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult;\n".to_string()), "use ".to_string()), crate_name.clone()), "::".to_string()), core_mod), "::".to_string()), "{".to_string()), "\n diagnostic_to_message, diagnostic_to_span,\n".to_string()), " byte_to_line_col, source_line_at, NewlineIndex,\n".to_string()), " CompilerDiagnostic,\n".to_string()), "}".to_string()), ";\n".to_string()), "use ".to_string()), crate_name.clone()), "::cli_run;\n".to_string()) } } else { base @@ -24417,7 +24418,7 @@ pub fn emit_subcommand_enum( "#[derive(Subcommand)]\n".to_string(), "enum Commands {\n".to_string(), ), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), variants_str, ), @@ -24551,8 +24552,8 @@ pub fn emit_cli_param_type_node( { let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname) { - mapped + if (mapped.clone() != nname.clone()) { + mapped.clone() } else { "String".to_string() } @@ -24632,7 +24633,10 @@ pub fn emit_main_fn( } else { v1_rt::concat( v1_rt::concat( - v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), dry_run_line), + v1_rt::concat( + v1_rt::concat(parse_line, "\n".to_string()), + dry_run_line.clone(), + ), "\n".to_string(), ), result_handling, @@ -24642,7 +24646,7 @@ pub fn emit_main_fn( v1_rt::concat( v1_rt::concat( v1_rt::concat(async_attr, "{\n".to_string()), - make_indent((depth + 1)), + make_indent((depth.clone() + 1)), ), body_lines, ), @@ -24654,7 +24658,7 @@ pub fn emit_main_fn( pub fn emit_compile_match_arm(crate_name: String) -> String { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target, dependency_pool_index } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), " let pool_index = parse_dependency_pool_index(&dependency_pool_index);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " let index = build_module_index(&source_roots, pool_index);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dag\n".to_string()), " // means 'compile src/v1, using dag as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " let skipped_moduleless = cli_run::moduleless_dag_entry_paths(&entry_files);\n".to_string()), " cli_run::report_moduleless_dag_entry_skips(&skipped_moduleless);\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " if extract_module_path(&content).is_none() { continue; }\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) } } @@ -24677,7 +24681,7 @@ pub fn emit_main_pipeline_fns(crate_name: String) -> String { ), emit_resolve_transitively_fn(crate_name.clone(), pipeline_mod.clone()), ), - emit_compile_target_helpers(crate_name.clone(), pipeline_mod, artifact_mod), + emit_compile_target_helpers(crate_name.clone(), pipeline_mod.clone(), artifact_mod), ) } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 988059445b2..0525069bf0f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -14606,8 +14606,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::< String, Rc>, diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b19d756df6d..8dc46a13d29 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -83,8 +83,6 @@ pub struct EmitGraphInfo { pub movable: Rc>, pub variant_to_enum: Rc>, pub owned_bindings: Rc>, - pub move_sites_index: Rc>>>, - pub move_sites: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, pub corpus_repr: RustCorpusRepr, @@ -106,8 +104,6 @@ pub fn empty_emit_graph_info() -> Rc { movable: v1_rt::rc_empty_set::(), variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), - move_sites_index: v1_rt::rc_empty_map::>>(), - move_sites: v1_rt::rc_empty_map::(), read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 877a7cfd813..160e9fc850f 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -193,9 +193,9 @@ pub fn record_use( pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc { if (binding_fan_out(b.clone()) > binding_fan_out(a.clone())) { - b + b.clone() } else { - a + a.clone() } } @@ -271,7 +271,7 @@ pub fn walk_expr( binding_kind: bk, .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if in_tail { + if in_tail.clone() { record_use( accum, n, @@ -298,7 +298,7 @@ pub fn walk_expr( ExprData::ExprVar { binding_kind: bk, .. } => { - let vn = expr_var_name_at(base_node, si.clone()); + let vn = expr_var_name_at(base_node.clone(), si.clone()); let f = field_access_field_at(texpr.clone(), si.clone()); record_use( accum, @@ -309,7 +309,7 @@ pub fn walk_expr( texpr.span.clone().start.clone(), ) } - _ => walk_expr(accum, base_node, false, si.clone()), + _ => walk_expr(accum, base_node.clone(), false, si.clone()), } } ExprData::ExprCall { .. } => { @@ -344,7 +344,7 @@ pub fn walk_expr( ia_val.span.clone().start.clone(), ) } - _ => walk_expr(accum, ia_val, false, si.clone()), + _ => walk_expr(accum, ia_val.clone(), false, si.clone()), } } None => accum, @@ -359,7 +359,7 @@ pub fn walk_expr( __result }); non_init.iter().cloned().fold( - threaded_accum, + threaded_accum.clone(), |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -409,14 +409,14 @@ pub fn walk_expr( ia_val.span.clone().start.clone(), ) } - _ => walk_expr(recv_accum, ia_val, false, si.clone()), + _ => walk_expr(recv_accum, ia_val.clone(), false, si.clone()), } } None => recv_accum, }; let non_init = Rc::new({ let mut __result = Vec::new(); - for a in mc_args.iter().cloned() { + for a in mc_args.clone().iter().cloned() { if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } @@ -424,7 +424,7 @@ pub fn walk_expr( __result }); let walked = non_init.iter().cloned().fold( - threaded_accum, + threaded_accum.clone(), |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) }, @@ -440,7 +440,7 @@ pub fn walk_expr( } else { { let recv_accum = walk_expr(accum, recv, false, si.clone()); - mc_args.iter().cloned().fold( + mc_args.clone().iter().cloned().fold( recv_accum, |acc: Rc, a: Rc| { walk_expr(acc, arg_value(a.clone()), false, si.clone()) @@ -465,7 +465,7 @@ pub fn walk_expr( } __result }); - merge_branch_usages(s_accum, branch_accums) + merge_branch_usages(s_accum.clone(), branch_accums) } ExprData::ExprIf => { let c = if_condition(texpr.clone()); @@ -473,16 +473,16 @@ pub fn walk_expr( let c_accum = walk_expr(accum, c, false, si.clone()); let t_accum = walk_expr(c_accum.clone(), t, in_tail.clone(), si.clone()); let e_accum = match if_else_branch(texpr.clone()) { - Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail, si.clone()), + Some(eb) => walk_expr(c_accum.clone(), eb.clone(), in_tail.clone(), si.clone()), None => c_accum.clone(), }; - merge_branch_usages(c_accum, Rc::new(vec![t_accum, e_accum])) + merge_branch_usages(c_accum.clone(), Rc::new(vec![t_accum, e_accum])) } ExprData::ExprLet => { let v = let_value(texpr.clone()); let v_accum = walk_expr(accum, v, false, si.clone()); match let_body(texpr.clone()) { - Some(b) => walk_expr(v_accum, b.clone(), in_tail, si.clone()), + Some(b) => walk_expr(v_accum, b.clone(), in_tail.clone(), si.clone()), None => v_accum, } } @@ -520,10 +520,13 @@ pub fn walk_expr( walk_expr(acc, p.1.clone(), false, si.clone()) }, ); - match ss.last().cloned() { - Some(last_expr) => { - walk_expr(init_accum, last_expr.clone(), in_tail, si.clone()) - } + match ss.clone().last().cloned() { + Some(last_expr) => walk_expr( + init_accum, + last_expr.clone(), + in_tail.clone(), + si.clone(), + ), None => init_accum, } } @@ -576,7 +579,7 @@ pub fn walk_expr( .iter() .cloned() .fold( - coll_accum, + coll_accum.clone(), |acc: Rc, usage: Rc| { let a1 = record_use( acc, @@ -666,7 +669,7 @@ pub fn make_decision(usage: Rc) -> Rc { }); Rc::new(OwnershipDecision::SharedError { binding: usage.name.clone(), - consumer_count: sc, + consumer_count: sc.clone(), sites: sites, }) } @@ -687,39 +690,14 @@ pub fn is_owned_local(kind: Option>) -> bool { } } -pub fn whole_value_borrow_count(usage: Rc) -> i64 { - (Rc::new({ - let mut __result = Vec::new(); - for c in usage.consumers.clone().iter().cloned() { - if match c.kind.clone() { - EdgeKind::Read => true, - EdgeKind::Threaded => true, - _ => false, - } { - __result.push(c); - } - } - __result - }) - .len() as i64) -} - -pub fn build_movable_set( - proof: Rc, - param_names: Rc>, -) -> Rc> { +pub fn build_movable_set(proof: Rc) -> Rc> { Rc::new({ let mut __result = Vec::new(); for usage in Rc::new(v1_rt::map_values(&proof.bindings.clone())) .iter() .cloned() { - if ((match (*make_decision(usage.clone())).clone() { - OwnershipDecision::SoleOwner { .. } => true, - _ => false, - } && (whole_value_borrow_count(usage.clone()) == 0)) - && (is_owned_local(usage.binding_kind.clone()) - || v1_rt::set_contains(¶m_names, usage.name.clone()))) + if ((binding_fan_out(usage.clone()) == 1) && is_owned_local(usage.binding_kind.clone())) { __result.push(usage); } @@ -814,7 +792,7 @@ pub fn collect_callable_refs( } => { let recv = collect_callable_refs(method_receiver(texpr.clone()), si.clone()); method_arg_nodes(texpr.clone()).iter().cloned().fold( - recv, + recv.clone(), |acc: Rc>, a: Rc| { v1_rt::rc_set_union( acc, @@ -835,7 +813,7 @@ pub fn collect_callable_refs( ExprData::ExprMatch => { let scrut = collect_callable_refs(match_scrutinee(texpr.clone()), si.clone()); match_arm_nodes(texpr.clone()).iter().cloned().fold( - scrut, + scrut.clone(), |acc: Rc>, arm: Rc| { v1_rt::rc_set_union( acc, @@ -946,7 +924,7 @@ pub fn summarize_fold_acc_uses( binding_kind: _, .. } => { if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { - if inside_nested { + if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -968,11 +946,11 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base, si.clone()) == acc_name.clone()), + } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), _ => false, }; if is_direct { - if inside_nested { + if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, field_moves: Rc::new(vec![]), @@ -1030,7 +1008,7 @@ pub fn summarize_fold_acc_uses( foreach_collection(node.clone()), acc_name.clone(), si.clone(), - inside_nested, + inside_nested.clone(), ); let body_summary = summarize_fold_acc_uses( foreach_body(node.clone()), @@ -1094,7 +1072,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal) == acc_type_name) + (authored_name_at(si, terminal.clone()) == acc_type_name) } _ => false, } @@ -1144,7 +1122,7 @@ pub fn analyze_single_fold( Some(a) => arg_value(a.clone()), None => method_call.clone(), }; - let fold_lambda_node = match args.get(1 as usize).cloned() { + let fold_lambda_node = match args.clone().get(1 as usize).cloned() { Some(a) => arg_value(a.clone()), None => method_call.clone(), }; @@ -1182,17 +1160,20 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let cond_safe = - fold_body_safe_field_moves(fold_lambda_node, acc_param_name.clone(), si.clone()); + let cond_safe = fold_body_safe_field_moves( + fold_lambda_node.clone(), + acc_param_name.clone(), + si.clone(), + ); let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), - acc_param_name: acc_param_name, - acc_type_name: acc_type_name, - body_constructs_acc: cond_struct, - whole_acc_single_use: cond_whole_acc, - safe_field_moves: cond_safe, + acc_param_name: acc_param_name.clone(), + acc_type_name: acc_type_name.clone(), + body_constructs_acc: cond_struct.clone(), + whole_acc_single_use: cond_whole_acc.clone(), + safe_field_moves: cond_safe.clone(), eligible: eligible, }) } @@ -1210,7 +1191,7 @@ pub fn analyze_ownership( .iter() .cloned() .fold(empty_usage_accum(), |acc: Rc, p: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:23177:acc"); + let acc = Rc::try_unwrap(acc).unwrap_or_else(|rc| (*rc).clone()); { let p_name = authored_name_at(si.clone(), p.clone()); Rc::new(UsageAccum { @@ -1252,332 +1233,6 @@ pub fn analyze_ownership( } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct LiveState { - pub name: String, - pub whole: bool, - pub any_field: bool, - pub fields: Rc>, -} - -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct MoveLicenseAccum { - pub live: Rc>>, - pub licensed: Rc>, -} - -pub fn move_site_key(name: String, span_start: i64) -> String { - v1_rt::concat( - v1_rt::concat(name, "@".to_string()), - (span_start).to_string(), - ) -} - -pub fn empty_live_state(name: String) -> Rc { - Rc::new(LiveState { - name: name, - whole: false, - any_field: false, - fields: v1_rt::rc_empty_set::(), - }) -} - -pub fn live_state_of(acc: Rc, name: String) -> Rc { - match v1_rt::map_get(&acc.live.clone(), name.clone()) { - Some(st) => st.clone(), - None => empty_live_state(name.clone()), - } -} - -pub fn record_whole_use_site( - acc: Rc, - name: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !st.any_field.clone()); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: true, - any_field: st.any_field.clone(), - fields: st.fields.clone(), - }), - ), - licensed: licensed, - }) - } -} - -pub fn record_field_use_site( - acc: Rc, - name: String, - field: String, - span_start: i64, - in_capture: bool, -) -> Rc { - { - let st = live_state_of(acc.clone(), name.clone()); - let movable_here = (((!in_capture && (span_start.clone() != 0)) && !st.whole.clone()) - && !v1_rt::set_contains(&st.fields.clone(), field.clone())); - let licensed = if movable_here { - v1_rt::rc_map_insert( - acc.licensed.clone(), - move_site_key(name.clone(), span_start.clone()), - true, - ) - } else { - acc.licensed.clone() - }; - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_map_insert( - acc.live.clone(), - name.clone(), - Rc::new(LiveState { - name: name.clone(), - whole: st.whole.clone(), - any_field: true, - fields: v1_rt::rc_set_insert(st.fields.clone(), field.clone()), - }), - ), - licensed: licensed, - }) - } -} - -pub fn merge_live_states(a: Rc, b: Rc) -> Rc { - Rc::new(LiveState { - name: a.name.clone(), - whole: (a.whole.clone() || b.whole.clone()), - any_field: (a.any_field.clone() || b.any_field.clone()), - fields: v1_rt::rc_set_union(a.fields.clone(), b.fields.clone()), - }) -} - -pub fn merge_branch_licenses(branches: Rc>>) -> Rc { - branches.iter().cloned().fold( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - |acc: Rc, br: Rc| { - let acc = v1_rt::take_owned_counted(acc, "src/v1/ownership.dag:26035:acc"); - { - let live_merged = Rc::new(v1_rt::map_keys(&br.live.clone())) - .iter() - .cloned() - .fold( - acc.live, - |lm: Rc>>, k: String| { - let b_st = match v1_rt::map_get(&br.live.clone(), k.clone()) { - Some(s) => s.clone(), - None => empty_live_state(k.clone()), - }; - match v1_rt::map_get(&lm, k.clone()) { - Some(a_st) => v1_rt::rc_map_insert( - lm.clone(), - k.clone(), - merge_live_states(a_st.clone(), b_st.clone()), - ), - None => v1_rt::rc_map_insert(lm.clone(), k.clone(), b_st.clone()), - } - }, - ); - let lic_merged = Rc::new(v1_rt::map_keys(&br.licensed.clone())) - .iter() - .cloned() - .fold(acc.licensed, |l: Rc>, k: String| { - v1_rt::rc_map_insert(l, k.clone(), true) - }); - Rc::new(MoveLicenseAccum { - live: live_merged.clone(), - licensed: lic_merged.clone(), - }) - } - }, - ) -} - -pub fn license_walk( - acc: Rc, - texpr: Rc, - in_capture: bool, - si: Rc>>, -) -> Rc { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - match (*texpr.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_whole_use_site( - acc.clone(), - expr_var_name_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - ExprData::ExprLiteral { value: _, .. } => acc.clone(), - ExprData::ExprFieldAccess { .. } => { - let base_node = field_access_base(texpr.clone()); - match (*base_node.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => record_field_use_site( - acc.clone(), - expr_var_name_at(base_node, si.clone()), - field_access_field_at(texpr.clone(), si.clone()), - texpr.span.clone().start.clone(), - in_capture.clone(), - ), - _ => license_walk(acc.clone(), base_node, in_capture.clone(), si.clone()), - } - } - ExprData::ExprCall { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }), - ExprData::ExprMethodCall { .. } => { - let args_acc = v1_rt::reverse(method_arg_nodes(texpr.clone())) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, arg: Rc| { - license_walk(a, arg_value(arg.clone()), in_capture.clone(), si.clone()) - }); - license_walk( - args_acc, - method_receiver(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprIf => { - let t_acc = license_walk( - acc.clone(), - if_then_branch(texpr.clone()), - in_capture.clone(), - si.clone(), - ); - let e_acc = match if_else_branch(texpr.clone()) { - Some(eb) => { - license_walk(acc.clone(), eb.clone(), in_capture.clone(), si.clone()) - } - None => acc.clone(), - }; - let merged = merge_branch_licenses(Rc::new(vec![t_acc, e_acc])); - license_walk( - merged, - if_condition(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprMatch => { - let branch_accs = Rc::new({ - let mut __result = Vec::new(); - for arm_node in match_arm_nodes(texpr.clone()).iter().cloned() { - __result.push(license_walk( - acc.clone(), - arm_body(arm_node.clone()), - in_capture.clone(), - si.clone(), - )); - } - __result - }); - let merged = merge_branch_licenses(branch_accs); - license_walk( - merged, - match_scrutinee(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprLet => { - let body_acc = match let_body(texpr.clone()) { - Some(b) => license_walk(acc.clone(), b.clone(), in_capture.clone(), si.clone()), - None => acc.clone(), - }; - license_walk( - body_acc, - let_value(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprBlock => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprReturn => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - ExprData::ExprLambda => { - license_walk(acc.clone(), lambda_body(texpr.clone()), true, si.clone()) - } - ExprData::ExprForEach => { - let body_acc = - license_walk(acc.clone(), foreach_body(texpr.clone()), true, si.clone()); - license_walk( - body_acc, - foreach_collection(texpr.clone()), - in_capture.clone(), - si.clone(), - ) - } - ExprData::ExprRecordLit { .. } => v1_rt::reverse(texpr.children.clone()) - .iter() - .cloned() - .fold(acc.clone(), |a: Rc, field: Rc| { - license_walk(a, arg_value(field.clone()), in_capture.clone(), si.clone()) - }), - _ => v1_rt::reverse(texpr.children.clone()).iter().cloned().fold( - acc.clone(), - |a: Rc, child: Rc| { - license_walk(a, child.clone(), in_capture.clone(), si.clone()) - }, - ), - } - }) -} - -pub fn build_move_site_licenses( - body: Rc, - si: Rc>>, -) -> Rc> { - { - let walked = license_walk( - Rc::new(MoveLicenseAccum { - live: v1_rt::rc_empty_map::>(), - licensed: v1_rt::rc_empty_map::(), - }), - body, - false, - si, - ); - walked.licensed.clone() - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Consumed; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 5e92b0e22a9..f073e49662d 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -54,7 +54,7 @@ pub fn rt_unicode_ops() -> String { } pub fn rt_rc_container_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "// take_owned_counted: fail-closed replacement for the silent\n".to_string()), "// Rc::try_unwrap(x).unwrap_or_else(|rc| (*rc).clone()) fallback (DESIGN.md 5:\n".to_string()), "// a failure arm must refuse or be counted, never silently widen). A shared Rc\n".to_string()), "// at a proof-licensed take-owned site is a proof deficit; the clone arm counts\n".to_string()), "// per emitted site so the deficit frequency stays observable.\n".to_string()), "thread_local! {\n".to_string()), " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n".to_string()), " std::cell::RefCell::new(HashMap::new());\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n".to_string()), " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n".to_string()), " (*rc).clone()\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn take_owned_clone_fallback_counts() -> Vec<(String, u64)> {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| {\n".to_string()), " let mut v: Vec<(String, u64)> = m\n".to_string()), " .borrow()\n".to_string()), " .iter()\n".to_string()), " .map(|(site, n)| (site.to_string(), *n))\n".to_string()), " .collect();\n".to_string()), " v.sort();\n".to_string()), " v\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "pub fn reset_take_owned_clone_fallbacks() {\n".to_string()), " TAKE_OWNED_CLONE_FALLBACKS.with(|m| m.borrow_mut().clear());\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } pub fn rt_filesystem() -> String { From dc2d15570a2f22d912da9f7e30162cadf8cac97c Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:34:50 +0000 Subject: [PATCH 26/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- docs/plans/emitter-ownership-defork.md | 12 ++++++++++++ src/v1/runtime_rust.dag | 4 ++++ src/v1/stage0/src/v1_rt.rs | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/docs/plans/emitter-ownership-defork.md b/docs/plans/emitter-ownership-defork.md index 4c73f718544..6a9167355c2 100644 --- a/docs/plans/emitter-ownership-defork.md +++ b/docs/plans/emitter-ownership-defork.md @@ -124,6 +124,18 @@ Emitter changes (all *readers* of the proof): (`analyze_single_fold` stops being consulted at emit time — the proof rows in `OwnershipProof.fold_acc_unwrap` already exist and become the only surface). +## Ordering assumption in `license_walk` (review note, opus-4-7 on #6249) + +`license_walk` visits children in `reverse` for `ExprCall`/`ExprBlock`/`ExprReturn`/ +`ExprRecordLit`. The backward-liveness semantics ("the LAST whole/field use gets the +license") is correct only because those child lists are stored in source order — +`reverse` of source order is reverse evaluation order, which is what a backward walk +requires. The parser constructs all of these lists in source order (args as parsed, +block statements as parsed, record fields as written), so the assumption holds today; +if a future normalization pass reorders any of these child lists, `license_walk` must +switch to an explicit evaluation-order key rather than positional reverse. (`.dag` has +no comment syntax, so this note lives here rather than at `ownership.dag`'s walk.) + ## Gen-2 adjudication verdict (2026-07-05, pre-restoration seed, differential) Method: gen-1 (old binary emitting this corpus) vs gen-2 (gen-1 binary — which runs this diff --git a/src/v1/runtime_rust.dag b/src/v1/runtime_rust.dag index 4645b4b0864..80e8fbe0166 100644 --- a/src/v1/runtime_rust.dag +++ b/src/v1/runtime_rust.dag @@ -337,6 +337,10 @@ fn rt_rc_container_ops() -> String { " static TAKE_OWNED_CLONE_FALLBACKS: std::cell::RefCell> =\n", " std::cell::RefCell::new(HashMap::new());\n", "}\n\n", + "/// INVARIANT: site must be a string literal (the emitter always passes one).\n", + "/// Counts key on &'static str; a non-literal static with duplicate content\n", + "/// could fragment one site's count across entries and silently degrade the\n", + "/// per-site observability this function exists to provide (DESIGN.md 5).\n", "pub fn take_owned_counted(x: Rc, site: &'static str) -> T {\n", " Rc::try_unwrap(x).unwrap_or_else(|rc| {\n", " TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1);\n", diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 461ae3a8ccb..253e0ab3992 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -663,6 +663,10 @@ thread_local! { std::cell::RefCell::new(HashMap::new()); } +/// INVARIANT: `site` must be a string literal (the emitter always passes one). +/// Counts key on `&'static str`; a non-literal static with duplicate content +/// could fragment one site's count across entries and silently degrade the +/// per-site observability this function exists to provide (DESIGN.md 5). pub fn take_owned_counted(x: Rc, site: &'static str) -> T { Rc::try_unwrap(x).unwrap_or_else(|rc| { TAKE_OWNED_CLONE_FALLBACKS.with(|m| *m.borrow_mut().entry(site).or_insert(0) += 1); From f5644acb3e02d43c8ee797b08d5f596e74fc7aa2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 5 Jul 2026 05:45:19 +0000 Subject: [PATCH 27/27] WIP: Emitter ownership de-fork: kill silent clone-fallback O(n2) --- dag/test/claim/ownership_movable_test.dag | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dag/test/claim/ownership_movable_test.dag b/dag/test/claim/ownership_movable_test.dag index 0e1771a276f..6d8889f5fe0 100644 --- a/dag/test/claim/ownership_movable_test.dag +++ b/dag/test/claim/ownership_movable_test.dag @@ -104,3 +104,19 @@ fn witness_site_branch_licenses_are_per_path() -> Bool { && licensed_at(acc: before, name: "acc", span: 50) && licensed_at(acc: before, name: "acc", span: 10) == false } + +test fn ownership_movable_witnesses() -> Bool { + witness_read_then_consume_param_is_movable() + && witness_double_consume_is_not_movable() + && witness_zero_consume_is_not_movable() + && witness_whole_read_then_consume_is_not_movable() + && witness_threaded_then_consume_is_not_movable() + && witness_site_last_whole_use_is_licensed() + && witness_site_zero_span_fails_closed() + && witness_site_capture_fails_closed() + && witness_site_earlier_use_before_whole_is_not_licensed() + && witness_site_field_move_then_whole_use_same_path_blocked() + && witness_site_distinct_field_moves_both_licensed() + && witness_site_same_field_twice_only_last_licensed() + && witness_site_branch_licenses_are_per_path() +}